Skip to content

215 feat add mandatory satellites parameter to pit#483

Open
jstendel wants to merge 8 commits into
mainfrom
215-feat_add_mandatory_satellites_parameter_to_pit
Open

215 feat add mandatory satellites parameter to pit#483
jstendel wants to merge 8 commits into
mainfrom
215-feat_add_mandatory_satellites_parameter_to_pit

Conversation

@jstendel

Copy link
Copy Markdown
Contributor

Description

Adds optional satellite coverage filtering to the PIT macro, so a PIT can be limited to entities that actually have descriptive data, rather than every hub × snapshot combination:

  • Per-satellite mandatory flag: sat_names now accepts either a plain satellite name or a {name, mandatory} dict. When mandatory: true, a PIT row is only emitted where that satellite has a record at the snapshot time
  • Top-level mandatory_strategy: 'any' (row kept if at least one satellite matched, OR) or 'all' (row kept only if every satellite matched, AND), applied across all satellites. Mutually exclusive with the per-satellite flags
  • When any mandatory filtering is active, the unknown and ghost records are dropped (te.hashkey != unknown_key)
  • Fully backward compatible: plain-string sat_names still work and the default behaviour (no filtering) is unchanged. Implemented consistently across all adapters and documented in 22_pit.md

Fixes: 215

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

Verified end-to-end on a local Postgres instance and the 215-feat_add_mandatory_satellites_parameter_to_pit branch inside the datavault4dbt-automatic-tests repo where additional pit models and test for those new models were created.

Test Configuration:

  • datavault4dbt-Version: branch 215-feat_add_mandatory_satellites_parameter_to_pit
  • dbt-Version: core version 1.11.10
  • dbt-adapter-Version: dbt-postgres 1.10.0

Checklist:

  • I have performed a self-review of my code
  • I have made corresponding changes to the documentation or included information that needs updates (e.g. in the Wiki)

@jstendel

Copy link
Copy Markdown
Contributor Author

CI/CD Run

@jstendel jstendel marked this pull request as ready for review June 24, 2026 11:10
@jstendel jstendel requested review from tkiehn and tkirschke June 29, 2026 08:20
Comment thread macros/tables/pit.sql
Comment thread macros/tables/synapse/pit.sql Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds optional “satellite coverage” filtering to the PIT macro so PIT rows can be restricted to entities that have matching satellite records at the snapshot time (via per-satellite mandatory flags or a global mandatory_strategy of 'any'/'all'). It also updates adapter-specific PIT implementations and the PIT documentation accordingly.

Changes:

  • Extend pit/adapter PIT macros with mandatory_strategy and support sat_names entries as {name, mandatory} dicts (with normalization for backward compatibility).
  • Apply mandatory satellite match filtering consistently across supported adapters, and drop unknown/ghost records when mandatory filtering is active.
  • Document the new sat_names dict form and mandatory_strategy behavior in 22_pit.md.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
macros/tables/pit.sql Adds mandatory_strategy, documents it, and normalizes sat_names entries to dicts before dispatch.
macros/tables/bigquery/pit.sql Updates PIT SQL generation to use satellite.name and apply mandatory filtering (default implementation).
macros/tables/databricks/pit.sql Updates PIT SQL generation to use satellite.name and apply mandatory filtering.
macros/tables/exasol/pit.sql Updates PIT SQL generation to use satellite.name and apply mandatory filtering.
macros/tables/fabric/pit.sql Updates PIT SQL generation to use satellite.name and apply mandatory filtering.
macros/tables/oracle/pit.sql Updates PIT SQL generation to use satellite.name and apply mandatory filtering.
macros/tables/postgres/pit.sql Updates PIT SQL generation to use satellite.name and apply mandatory filtering (with WHERE composition).
macros/tables/redshift/pit.sql Updates PIT SQL generation to use satellite.name and apply mandatory filtering via HAVING.
macros/tables/snowflake/pit.sql Updates PIT SQL generation to use satellite.name and apply mandatory filtering (including snapshot optimization path).
macros/tables/sqlserver/pit.sql Updates PIT SQL generation to use satellite.name and apply mandatory filtering.
macros/tables/synapse/pit.sql Updates PIT SQL generation to use satellite.name and apply mandatory filtering.
macros/tables/trino/pit.sql Updates PIT SQL generation to use satellite.name and apply mandatory filtering.
docs/01_macro-instructions/22_business-vault/22_pit/22_pit.md Documents the new sat_names dict entries and the mandatory_strategy parameter.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread macros/tables/pit.sql
Comment on lines +102 to +111
{# Normalize sat_names: plain strings become {'name': ..., 'mandatory': false} for backward compatibility. #}
{%- set sat_names_normalized = [] -%}
{%- for sat in sat_names -%}
{%- if sat is string -%}
{%- do sat_names_normalized.append({'name': sat, 'mandatory': false}) -%}
{%- else -%}
{%- do sat_names_normalized.append({'name': sat['name'], 'mandatory': sat.get('mandatory', false)}) -%}
{%- endif -%}
{%- endfor -%}
{%- set sat_names = sat_names_normalized -%}
Comment thread macros/tables/pit.sql
{%- set refer_to_ghost_records = datavault4dbt.yaml_metadata_parser(name='refer_to_ghost_records', yaml_metadata=yaml_metadata, parameter=refer_to_ghost_records, required=False, documentation=pit_type_description) -%}
{%- set refer_to_ghost_records = datavault4dbt.yaml_metadata_parser(name='refer_to_ghost_records', yaml_metadata=yaml_metadata, parameter=refer_to_ghost_records, required=False, documentation=refer_to_ghost_records_description) -%}
{%- set snapshot_optimization = datavault4dbt.yaml_metadata_parser(name='snapshot_optimization', yaml_metadata=yaml_metadata, parameter=snapshot_optimization, required=False, documentation=snapshot_optimization_description) -%}
{%- set mandatory_strategy = datavault4dbt.yaml_metadata_parser(name='mandatory_strategy', yaml_metadata=yaml_metadata, parameter=mandatory_strategy, required=False, documentation=mandatory_strategy_description) -%}
| tracked_entity | string | mandatory | – | Name of the tracked Hub entity. Must be available as a model inside the dbt project. |
| hashkey | string | mandatory | – | The name of the hashkey column inside the previously referred Hub entity. |
| sat_names | list of strings| mandatory | – | A list of all the satellites that should be included in this PIT table. Can only be satellites that are attached to the tracked Hub, and should typically include all those satellites. You should always refer here to the version 1 satellites, since those hold the load-end-date. The macro currently supports regular satellites and nh-satellites. |
| sat_names | list of strings or dicts| mandatory | – | A list of all the satellites that should be included in this PIT table. Can only be satellites that are attached to the tracked Hub, and should typically include all those satellites. You should always refer here to the version 1 satellites, since those hold the load-end-date. The macro currently supports regular satellites and nh-satellites. Each entry can be a plain satellite name, or a dict with `name` and an optional `mandatory` (boolean, default `false`). When `mandatory` is `true`, PIT rows are only included where that satellite found a match at the snapshot time. |
@tkiehn

tkiehn commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Hi @jstendel, could you please also add a test with defined input and expected output per setting to the testing-repo and mention this PR there?

@tkiehn tkiehn added the waiting-on-response Waiting on a response from the author or others, except maintainers. label Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting-on-response Waiting on a response from the author or others, except maintainers.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants