Items¶
Schema¶
- class rapid.items.schema.Column(*, name: str, data_type: str, partition_index: Optional[int] = None, allow_null: bool = True, format: Optional[str] = None)¶
Bases:
BaseModelCreate a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- allow_null: bool¶
- data_type: str¶
- format: Optional[str]¶
- name: str¶
- partition_index: Optional[int]¶
- class rapid.items.schema.Owner(*, name: str, email: str)¶
Bases:
BaseModelCreate a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- email: str¶
- name: str¶
- class rapid.items.schema.Schema(*, metadata: SchemaMetadata, columns: List[Column])¶
Bases:
BaseModelA Schema is a Pydantic class representing a rAPId schema. It allows you to programmatically define a schema to generate, create and update within rAPId.
Example
A Schema can be created by setting the values literally into the classes like example below:
schema = Schema( metadata=SchemaMetadata( domain="domain", dataset="dataset", sensitivity=SensitivityLevel.PUBLIC, owners=[Owner(name="test", version="test@email.com")] ), columns=[ Column( name="column_a", data_type="Float64", allow_null=True ) ] )
The alternative is you can create a schema directly from a Python dictionary specifying the values like in the example below:
schema = Schema( **{ "metadata": { .... }, "columns": { .... } } )
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- are_columns_the_same(new_columns: Union[List[Column], List[dict]]) bool¶
Checks that for a given Schema, does it’s columns match the columns being passed into this function.
- Parameters:
new_columns (Union[List[Column], List[dict]]) – The new columns can be passed as either a list of Column defined classes or as a list of Python dictionaries representing the values. If the later is chosen and there is an incorrect value passed the function will raise a
rapid.exceptions.ColumnNotDifferentException.- Returns:
If the new columns match the columns in the Schema
- Return type:
bool
- metadata: SchemaMetadata¶
- class rapid.items.schema.SchemaMetadata(*, domain: str, dataset: str, sensitivity: SensitivityLevel, owners: List[Owner], version: Optional[int] = None, key_value_tags: Optional[Dict[str, str]] = None, key_only_tags: Optional[List[str]] = None)¶
Bases:
BaseModelCreate a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- dataset: str¶
- domain: str¶
- key_only_tags: Optional[List[str]]¶
- key_value_tags: Optional[Dict[str, str]]¶
- sensitivity: SensitivityLevel¶
- version: Optional[int]¶
Query¶
- class rapid.items.query.Query(*, select_columns: Optional[List[str]] = None, filter: Optional[str] = None, group_by_columns: Optional[List[str]] = None, aggregation_conditions: Optional[str] = None, order_by_columns: Optional[List[SQLQueryOrderBy]] = None, limit: Optional[str] = None)¶
Bases:
BaseModelA Query is a Pydantic class representing a rAPId compatible data query. It allows for programmatic definition of data queries. See the rAPId specific documentation on how to write a valid query.
Example
A query can created by setting the values literally into the class like:
query = Query( select_columns=["column_a", "column_b"], limit="5" )
The alternative is you can create a schema directly from a Python dictionary:
query = Query( **{ "select_columns": ["column_a", "column_b"], "limit": "5" } )
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- aggregation_conditions: Optional[str]¶
- filter: Optional[str]¶
- group_by_columns: Optional[List[str]]¶
- limit: Optional[str]¶
- order_by_columns: Optional[List[SQLQueryOrderBy]]¶
- select_columns: Optional[List[str]]¶
- class rapid.items.query.SQLQueryOrderBy(*, column: str, direction: SortDirection = SortDirection.ASC)¶
Bases:
BaseModelCreate a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- column: str¶
- direction: SortDirection¶