Refactor generic tests to use batch start and end dates#225
Open
sydneynotthecity wants to merge 1 commit intorelease-v20260413from
Open
Refactor generic tests to use batch start and end dates#225sydneynotthecity wants to merge 1 commit intorelease-v20260413from
sydneynotthecity wants to merge 1 commit intorelease-v20260413from
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
PR Structure
otherwise).
Thoroughness
Release planning
semver, and I've changed the name of the BRANCH to major/* , minor/* or patch/* .
What
Migrated all generic and singular tests from the
dbt_airflow_macrospackage to usebatch_start_date/batch_end_datevariables, allowing for more targeted testing during backfilling. Also optimized the uniqueness tests for BigQuery performance on high-cardinality tables. The refactor supports improving the entity attribution pipeline runtime, which is now consistent 75+ minutes for a single day.Specifically:
dbt_airflow_macros.ts(timezone=none)dbt_airflow_macros.ts(timezone=none)with var("batch_end_date") as the anchor timestampless_than_equal_toparameter from all generic tests (was unused by every caller)greater_than_equal_toas a deprecated fallback that widens the lower bound: [batch_start_date - interval, batch_end_date)Why
Models and macros were fully migrated to
batch_start_date/batch_end_datein a prior refactor, but all tests still depended on thedbt_airflow_macrospackage. The old pattern anchored on a single Airflow timestamp with hardcoded intervals, which was brittle and didn't align with flexible date range backfills. Tests should validate exactly the window that was loaded.The GROUP BY / HAVING pattern in uniqueness tests is expensive on BigQuery for tables with 15-30M daily rows. QUALIFY ROW_NUMBER() avoids this by streaming through partitions without aggregation. This will speed up the entity attribution models by several minutes where we're seeing a bottleneck due to long running tests (7+ min to finish)
The anomaly detection tests were not measuring anything actionable and have been removed in favor of Datafold tests. The rest of the singular tests can be removed after confirming they run properly in Datafold.
Known limitations
This does not refactor any specific model configurations that use these tests. We will need to audit
greater_than_or_equal_tousage and remove/adjust as necessary.This also does not refactor any references to
airflow_start_timestampwhich is another env var passed from airflow at runtime. That can be done at a future date