Reference¶
eimerdb package¶
eimerdb.functions module¶
A collection of useful functions.
The template and this example uses Google style docstrings as described at: https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html
- arrow_schema_from_json(json_schema)¶
A function that converts a JSON schema to an Arrow schema.
- Parameters:
json_schema (list[dict]) – A JSON schema with name, type, and label.
- Returns:
The PyArrow schema.
- Return type:
pa.Schema
- create_eimerdb(bucket_name, db_name)¶
Creates an EimerDB instance.
- Parameters:
bucket_name (
str
) – A GCP bucket.db_name (
str
) – Name of the instance.
- Return type:
None
- filter_partition_select_on_table(table_name, partition_select)¶
A function that gets the partition select for a table.
- Supports both:
- {
- “table1”: {
“col1”: [“value1”, “value2”]
}
} and: {
“col1”: [“value1”, “value2”]
}
- Parameters:
table_name (str) – The name of the table.
partition_select (dict) – The partition select.
- Returns:
The partition select for the table, or None.
- Return type:
dict
- get_datetime()¶
A function that returns a datetime string.
- Return type:
str
- Returns:
datetime string.
- get_initials()¶
A function that returns user initials.
- Return type:
str
- Returns:
The user’s initials or “user” if the user is None.
- get_json(bucket_name, blob_path)¶
A function that retrieves a JSON file from Google Cloud Storage.
- Parameters:
bucket_name (str) – Name of the bucket.
blob_path (str) – Path to the blob.
- Returns:
The JSON content.
- Return type:
str
- parse_sql_query(sql_query)¶
A function that parses the provided SQL query.
- Parameters:
sql_query (str) – An SQL query.
- Returns:
A dictionary with keys: Operation, columns, table_name, and sql_filter.
- Return type:
dict
- Raises:
ValueError – If there is a syntax error or if the query is not supported.