diepvries.satellite module

A Satellite.

class diepvries.satellite.Satellite(schema, name, fields, *_args, **_kwargs)

Bases: DataVaultTable

A Satellite.

A Satellite is a Data Vault table that contains all properties of a link or a hub. The data in this table is totally historized. Each row has a start and end timestamp. There are no deletes in this type of tables. If something changes, a new record is inserted and the start and end timestamps adjusted accordingly.

Example: Customer Satellite will hold all customer properties: name, date of registration, address, etc…

property hashdiff_sql: str

Get the SQL expression that should be used to calculate a hashdiff field.

The hashdiff formula is the following::

MD5(business_key_1   + |~~|
    + business_key_n + |~~|
    + child_key_1    + |~~|
    + descriptive_field_1)

To ensure that a hashdiff does not change if a new field is added to the table, it is assumed that all |~~| character sequences placed at the end of the string are removed.

Returns:

Hashdiff SQL expression.

property loading_order: int

Get loading order (satellites are the third and last tables to be loaded).

Returns:

Table loading order.

parent_table: Union[Link, Hub, None] = None
property parent_table_name: str

Get the name the parent table.

It is calculated by removing the _hashkey suffix from the table’s hashkey field.

Returns:

Parent table name.

property sql_load_statement: str

Get the SQL query to populate the satellite.

All needed placeholders are calculated, in order to match template SQL (check template_sql.satellite_dml.sql).

Returns:

SQL query to load target satellite.

property sql_placeholders: Dict[str, str]

Satellite specific SQL placeholders.

These placeholders are used to format the Satellite loading query.

The results are joined with the results from super().sql_placeholders(), as all placeholders calculated in Table (parent class) are applicable in a Satellite.

Returns:

Satellite specific SQL placeholders.