_transformation_utils#
Useful functions to be used with transformations.
Functions#
Generate a nested transformation. |
|
Renames tables. |
|
Deletes tables. |
|
Persists tables. |
|
Unpersists tables. |
|
Returns a GetValue transformation finding the table specified. |
- generate_nested_transformation(base_transformation, parent_reference, generator_dict, table_identifier=None)#
Generate a nested transformation.
At a high level, this function chooses an appropriate transformation by keying into the generator dictionary at the parent_reference’s Metric, then applies the selected transformation at parent_reference in the output of base_transformation.
- Parameters
base_transformation (tmlt.core.transformations.base.Transformation) – Transformation to be used as a starting point.
parent_reference (tmlt.analytics._table_reference.TableReference) – The parent TableReference of base_transformation’s associated TableReference.
generator_dict (Dict[Type[tmlt.core.metrics.Metric], Callable[[tmlt.core.domains.base.Domain, tmlt.core.metrics.Metric, tmlt.analytics._table_identifier.Identifier], tmlt.core.transformations.base.Transformation]]) – a dictionary of the form { Metric : generator() }, where generator() is a function which takes the associated domain and metric of the parent_reference and generates a transformation using the Metric, e.g. generator(parent_domain, parent_metric, target_identifier)
table_identifier (Optional[tmlt.analytics._table_identifier.Identifier]) – identifier for new table in case of rename and original table in case of delete/persist/unpersist
- Return type
Tuple[tmlt.core.transformations.base.Transformation, tmlt.analytics._table_reference.TableReference]
- rename_table(base_transformation, base_ref, new_table_id)#
Renames tables.
A single value is transformed and added to the dictionary at a new key. Note that the original value is left unchanged in the dictionary.
- Parameters
base_transformation (tmlt.core.transformations.base.Transformation) –
base_ref (tmlt.analytics._table_reference.TableReference) –
new_table_id (tmlt.analytics._table_identifier.Identifier) –
- Return type
Tuple[tmlt.core.transformations.base.Transformation, tmlt.analytics._table_reference.TableReference]
- delete_table(base_transformation, base_ref)#
Deletes tables.
- Parameters
base_transformation (tmlt.core.transformations.base.Transformation) –
base_ref (tmlt.analytics._table_reference.TableReference) –
- Return type
tmlt.core.transformations.base.Transformation
- persist_table(base_transformation, base_ref, new_table_id=None)#
Persists tables.
- Parameters
base_transformation (tmlt.core.transformations.base.Transformation) –
base_ref (tmlt.analytics._table_reference.TableReference) –
new_table_id (Optional[tmlt.analytics._table_identifier.Identifier]) –
- Return type
Tuple[tmlt.core.transformations.base.Transformation, tmlt.analytics._table_reference.TableReference]
- unpersist_table(base_transformation, base_ref)#
Unpersists tables.
- Parameters
base_transformation (tmlt.core.transformations.base.Transformation) –
base_ref (tmlt.analytics._table_reference.TableReference) –
- Return type
tmlt.core.transformations.base.Transformation
- get_table_from_ref(transformation, ref)#
Returns a GetValue transformation finding the table specified.
- Parameters
transformation (tmlt.core.transformations.base.Transformation) –
- Return type
tmlt.core.transformations.base.Transformation