diepvries.role_playing_hub module

A role playing Hub.

class diepvries.role_playing_hub.RolePlayingHub(schema, name, fields)

Bases: Hub

A role playing Hub.

A role playing Hub is a hub that is not materialized as a table, but is a view pointing to a main Hub. The concept is essentially the same as a role playing dimension in a star schema.

One conceptual example of a Role Playing Hub can be a Hub that represents an account, that can assume different roles (supplier, transporter, administrator, etc…). All of them are accounts, but each of them represent a different role. Using this example, only the Hub account would be materialized and populated (as a table), as all other hubs (Hub Account Supplier/Transporter/etc…) would be views pointing to the main hub.

__init__(schema, name, fields)

Instantiate a role RolePlayingHub.

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

  • name (str) – Role playing hub name.

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

property sql_load_statement: str

Get the SQL query to populate the current role playing hub.

If table has a parent table - role playing hub.

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

Return type:

str

Returns:

SQL query to load target hub.

property sql_placeholders: Dict[str, str]

Role playing hub specific SQL placeholders.

These placeholders are used to format the RolePlayingHub loading query.

The results are joined with the results from super().sql_placeholders(), as most placeholders calculated in Table (parent class) are applicable in a RolePlayingHub. The only placeholder that is calculated in the parent class and replaced in this method is target_table, that points to the parent hub in this case.

Return type:

Dict[str, str]

Returns:

Role playing hub specific SQL placeholders.

staging_table: StagingTable