Add has_no_sequence_gaps dataset-level check - #1456
Open
ghanse wants to merge 3 commits into
Open
Conversation
Adds a dataset-level check that flags gaps in a numeric sequence, i.e. expected values that are missing between values that are present (for example no invoice numbered 1002 while 1001 and 1003 are present). This is the numeric counterpart of has_no_gaps_per_time_window: distinct values are bucketed onto a fixed grid of `step` aligned to zero, a window lead() finds the next present bucket, and a gap is flagged wherever the next present bucket starts more than one step after the current one. Since a missing value has no row to attach a violation to, the gap is reported on every row in the last present bucket before the gap. With the default `step` of 1 the grid is the integers, so detection is exact sequence-gap detection - the common case for invoice numbers, ledger entries and sequence IDs. Only interior gaps are detected. The bounds of a sequence are its own lowest and highest present values, so missing values beyond either end are not reported because there is no row to anchor them to. When `group_by` is provided, gaps are detected independently within each group and each group is bounded by its own lowest and highest present value, so a group whose sequence simply stops earlier than another group's is not flagged. Null values are ignored and pass with no violation.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1456 +/- ##
===========================================
- Coverage 93.53% 78.25% -15.29%
===========================================
Files 133 141 +8
Lines 12523 13601 +1078
Branches 0 151 +151
===========================================
- Hits 11714 10643 -1071
- Misses 809 2889 +2080
- Partials 0 69 +69
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
|
❌ 24/25 passed, 5 flaky, 1 failed, 3h50m10s total ❌ test_run_dqx_demo_asset_bundle: AssertionError: `databricks bundle run -t CLOUD_ENV dqx_demo_job` failed with exit 1 (30m8.749s)Flaky tests:
Running from acceptance #5599 |
Contributor
|
❌ 1 failed, 9m20s total ❌ test_mcp_server_end_to_end: AssertionError: run 1068278235765617 not finished within 300s (last status=running) (9m19.908s)Running from mcp #348 |
Contributor
|
✅ 192/192 passed, 1 flaky, 1 skipped, 7h27m51s total Flaky tests:
Running from anomaly #1713 |
…as-no-sequence-gaps
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.
Changes
Adds a new dataset-level check
has_no_sequence_gaps(column, step=1, group_by=None)that detects gaps in a numeric sequence.This follows the approach established in #1370 for
has_no_gaps_per_time_window. Distinct values are bucketed onto a fixed grid ofstep, a windowedlead()finds the next bucket, and a gap is flagged whenever the next bucket starts more than one step after the current bucket. Gaps are reported for every row in the last present bucket before the gap.The bounds of a sequence are its own lowest and highest present values. When
group_byis provided, gaps are detected independently within each group (e.g. to detect missing primary keys by source system) and each group is bounded by its own lowest and highest value.Linked issues
Tests
Documentation and Demos
This pull request and its description were co-written by Isaac.