diepvries.effectivity_satellite module

An effectivity satellite.

class diepvries.effectivity_satellite.EffectivitySatellite(schema, name, fields, driving_keys, *args, **kwargs)

Bases: Satellite

Effectivity satellite.

An effectivity satellite is a special type of satellite with the purpose of keeping “versions open” based on a subset of fields in the parent link.

Example: A Data Vault model that has a link between a Customer and a Contact. It is required (for this specific example) to keep only one contact, per customer open at a given point in time. This means that, if a customer changes contacts, only the latest relationship between the Customer and its Contact is kept as an open relationship. Hub Customer’s hashkey would be the driving key.

__init__(schema, name, fields, driving_keys, *args, **kwargs)

Instantiate an EffectivitySatellite.

Parameters:
  • schema (str) – Data Vault schema name.

  • name (str) – Satellite name.

  • fields (List[Field]) – List of fields that this Satellite holds.

  • driving_keys (List[DrivingKeyField]) – Define the set of link (parent table) fields that should be used as driving keys (in the example presented above, the driving key would be the h_customer_hashkey).

  • args – Unused here, useful for children classes.

  • kwargs – Unused here, useful for children classes.

property sql_load_statement: str

Get the SQL query to populate current effectivity satellite.

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

Returns:

SQL query to load target satellite.

property sql_placeholders: Dict[str, str]

Calculate effectivity satellite specific placeholders.

They are needed to generate SQL.

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

Returns:

Effectivity satellite specific placeholders, to use in effectivity

satellites.