Skip to content

Add has_no_sequence_gaps dataset-level check - #1456

Open
ghanse wants to merge 3 commits into
mainfrom
ghanse/has-no-sequence-gaps
Open

Add has_no_sequence_gaps dataset-level check#1456
ghanse wants to merge 3 commits into
mainfrom
ghanse/has-no-sequence-gaps

Conversation

@ghanse

@ghanse ghanse commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

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 of step, a windowed lead() 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_by is 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

  • manually tested
  • added unit tests
  • added integration tests
  • added end-to-end tests
  • added performance tests

Documentation and Demos

  • added/updated demos
  • added/updated docs
  • added/updated agent skills

This pull request and its description were co-written by Isaac.

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

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 25.00000% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.25%. Comparing base (f27b7d2) to head (8eca8f3).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/databricks/labs/dqx/check_funcs.py 25.00% 18 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (f27b7d2) and HEAD (8eca8f3). Click for more details.

HEAD has 2 uploads less than BASE
Flag BASE (f27b7d2) HEAD (8eca8f3)
integration 1 0
integration-serverless 1 0
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     
Flag Coverage Δ
anomaly 19.52% <0.00%> (-32.46%) ⬇️
anomaly-serverless 19.02% <0.00%> (-32.96%) ⬇️
integration ?
integration-serverless ?
mcp 77.73% <ø> (?)
unit 64.92% <25.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown
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)
AssertionError: `databricks bundle run -t CLOUD_ENV dqx_demo_job` failed with exit 1
--- stdout ---

--- stderr ---
Warning: The DATABRICKS_CLUSTER_ID variable is set but is ignored since the current target does not use 'mode: development'

Run URL: https://DATABRICKS_HOST/?o=841570839244994#job/505855800646650/run/234274045042541

2026-08-12 17:59:15 "[3fe685a1-96cc-4fec-8cdb-6944f5c9787e] DQX Demo Job (ujbeumayyy)" RUNNING
2026-08-12 18:29:08 "[3fe685a1-96cc-4fec-8cdb-6944f5c9787e] DQX Demo Job (ujbeumayyy)" INTERNAL_ERROR FAILED Task dqx_demo_notebook failed with message: Cluster '0812-175916-47xc5on4' was terminated. Reason: AZURE_QUOTA_EXCEEDED_EXCEPTION (CLIENT_ERROR). Parameters: databricks_error_message:The VM size you are specifying is not available. [details] QuotaExceeded: Operation could not be completed as it results in exceeding approved Total Regional Cores quota. Additional details - Deployment Model: Resource Manager, Location: eastus2, Current Limit: 350, Current Usage: 350, Additional Required: 4, (Minimum) New Limit Required: 354. Setup Alerts when Quota reaches threshold. Learn more at https://aka.ms/quotamonitoringalerting . Submit a request for Quota increase at https://aka.ms/ProdportalCRP/#blade/Microsoft_Azure_Capacity/UsageAndQuota.ReactView/Parameters/%7B%22subscriptionId%22:%22bf472657-510a-4fad-a050-87cfb4e1a2ce%22,%22command%22:%22openQuotaApprovalBlade%22,%22quotas%22:[%7B%22location ...
***WARNING: message truncated. Skipped 113 bytes of output**


Task dqx_demo_notebook FAILED:
Run failed with error message
 Cluster '0812-175916-47xc5on4' was terminated. Reason: AZURE_QUOTA_EXCEEDED_EXCEPTION (CLIENT_ERROR). Parameters: databricks_error_message:The VM size you are specifying is not available. [details] QuotaExceeded: Operation could not be completed as it results in exceeding approved Total Regional Cores quota. Additional details - Deployment Model: Resource Manager, Location: eastus2, Current Limit: 350, Current Usage: 350, Additional Required: 4, (Minimum) New Limit Required: 354. Setup Alerts when Quota reaches threshold. Learn more at https://aka.ms/quotamonitoringalerting . Submit a request for Quota increase at https://aka.ms/ProdportalCRP/#blade/Microsoft_Azure_Capacity/UsageAndQuota.ReactView/Parameters/%7B%22subscriptionId%22:%22bf472657-510a-4fad-a050-87cfb4e1a2ce%22,%22command%22:%22openQuotaApprovalBlade%22,%22quotas%22:[%7B%22location%22:%22eastus2%22,%22providerId%22:%22Micros ...
***WARNING: message truncated. Skipped 1605 bytes of output**




Error: Task dqx_demo_notebook failed!
Error:
Run failed with error message
 Cluster '0812-175916-47xc5on4' was terminated. Reason: AZURE_QUOTA_EXCEEDED_EXCEPTION (CLIENT_ERROR). Parameters: databricks_error_message:The VM size you are specifying is not available. [details] QuotaExceeded: Operation could not be completed as it results in exceeding approved Total Regional Cores quota. Additional details - Deployment Model: Resource Manager, Location: eastus2, Current Limit: 350, Current Usage: 350, Additional Required: 4, (Minimum) New Limit Required: 354. Setup Alerts when Quota reaches threshold. Learn more at https://aka.ms/quotamonitoringalerting . Submit a request for Quota increase at https://aka.ms/ProdportalCRP/#blade/Microsoft_Azure_Capacity/UsageAndQuota.ReactView/Parameters/%7B%22subscriptionId%22:%22bf472657-510a-4fad-a050-87cfb4e1a2ce%22,%22command%22:%22openQuotaApprovalBlade%22,%22quotas%22:[%7B%22location%22:%22eastus2%22,%22providerId%22:%22Micros ...
***WARNING: message truncated. Skipped 1605 bytes of output**


Trace:

Error: failed to reach TERMINATED or SKIPPED, got INTERNAL_ERROR: Task dqx_demo_notebook failed with message: Cluster '0812-175916-47xc5on4' was terminated. Reason: AZURE_QUOTA_EXCEEDED_EXCEPTION (CLIENT_ERROR). Parameters: databricks_error_message:The VM size you are specifying is not available. [details] QuotaExceeded: Operation could not be completed as it results in exceeding approved Total Regional Cores quota. Additional details - Deployment Model: Resource Manager, Location: eastus2, Current Limit: 350, Current Usage: 350, Additional Required: 4, (Minimum) New Limit Required: 354. Setup Alerts when Quota reaches threshold. Learn more at https://aka.ms/quotamonitoringalerting . Submit a request for Quota increase at https://aka.ms/ProdportalCRP/#blade/Microsoft_Azure_Capacity/UsageAndQuota.ReactView/Parameters/%7B%22subscriptionId%22:%22bf472657-510a-4fad-a050-87cfb4e1a2ce%22,%22command%22:%22openQuotaApprovalBlade%22,%22quotas%22:[%7B%22location ...
***WARNING: message truncated. Skipped 113 bytes of output**
17:59 INFO [tests.conftest] Overriding DATABRICKS_CLUSTER_ID with DATABRICKS_DQX_CLUSTER_ID: DATABRICKS_DQX_CLUSTER_ID
17:59 INFO [databricks.sdk] Using Databricks Metadata Service authentication
[gw2] linux -- Python 3.12.3 /home/runner/work/dqx/dqx/.venv/bin/python
17:59 INFO [tests.conftest] Overriding DATABRICKS_CLUSTER_ID with DATABRICKS_DQX_CLUSTER_ID: DATABRICKS_DQX_CLUSTER_ID
17:59 INFO [databricks.sdk] Using Databricks Metadata Service authentication
17:59 INFO [databricks.labs.pytester.fixtures.baseline] Created dqx.dummy_smhhymwac schema: https://DATABRICKS_HOST/#explore/data/dqx/dummy_smhhymwac
17:59 INFO [tests.conftest] Overriding DATABRICKS_CLUSTER_ID with DATABRICKS_DQX_CLUSTER_ID: DATABRICKS_DQX_CLUSTER_ID
17:59 INFO [databricks.sdk] Using Databricks Metadata Service authentication
17:59 INFO [databricks.labs.pytester.fixtures.baseline] Created dqx.dummy_smhhymwac schema: https://DATABRICKS_HOST/#explore/data/dqx/dummy_smhhymwac
[gw2] linux -- Python 3.12.3 /home/runner/work/dqx/dqx/.venv/bin/python

Flaky tests:

  • 🤪 test_run_anomaly_distributed_scoring_notebook (3m3.142s)
  • 🤪 test_run_dqx_demo_summary_metrics (20m16.744s)
  • 🤪 test_run_save_dataframe_as_table_notebook (20m15.466s)
  • 🤪 test_run_dqx_dlt_demo[dqx_ldp_demo_foreach_batch.py] (30m8.523s)
  • 🤪 test_run_dqx_dlt_demo[dqx_ldp_demo.py] (30m12.864s)

Running from acceptance #5599

@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

❌ 1 failed, 9m20s total

❌ test_mcp_server_end_to_end: AssertionError: run 1068278235765617 not finished within 300s (last status=running) (9m19.908s)
AssertionError: run 1068278235765617 not finished within 300s (last status=running)
  run URL: https://DATABRICKS_HOST/#job/464139949680210/run/1068278235765617
17:53 INFO [databricks.sdk] Using Databricks Metadata Service authentication
[gw1] linux -- Python 3.12.3 /home/runner/work/dqx/dqx/.venv/bin/python
17:53 INFO [databricks.sdk] Using Databricks Metadata Service authentication
17:57 INFO [databricks.sdk] Using Databricks Metadata Service authentication
18:03 INFO [databricks.sdk] Using Databricks Metadata Service authentication
17:53 INFO [databricks.sdk] Using Databricks Metadata Service authentication
17:57 INFO [databricks.sdk] Using Databricks Metadata Service authentication
18:03 INFO [databricks.sdk] Using Databricks Metadata Service authentication
[gw1] linux -- Python 3.12.3 /home/runner/work/dqx/dqx/.venv/bin/python

Running from mcp #348

@github-actions

github-actions Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

✅ 192/192 passed, 1 flaky, 1 skipped, 7h27m51s total

Flaky tests:

  • 🤪 test_train_anomaly_cli (29m19.468s)

Running from anomaly #1713

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant