Skip to content

dbt: match data quality assertions in any order - #360

Draft
tnazarew wants to merge 1 commit into
mainfrom
dbt/unordered-assertions
Draft

tnazarew wants to merge 1 commit into
mainfrom
dbt/unordered-assertions

Conversation

@tnazarew

Copy link
Copy Markdown
Collaborator

dbt runs tests on 4 threads, so the order of dataQualityAssertions.assertions in the test COMPLETE events changes from run to run. The csv_to_postgres expectations added in #357 therefore fail at random, e.g. run 43859743388:

In .inputs.[0].facets.dataQualityAssertions.assertions.[0].name: Expected value not_null_customer_analytics_total_revenue does not equal result not_null_customer_analytics_customer_id

Changes

  • The three csv_to_postgres data quality expectations compare assertions with unordered_list.
  • compare_events.diff: unordered_list never matched. It called the module's own any() jinja helper (which returns a string) instead of the builtin and compared with is []. Now it uses builtins.any(... == []). No expectation used unordered_list before, so nothing else changes.

Testing

Replayed the real events from run 43859743388 (dbt 1.8.0 × OpenLineage 1.55.0):

expectation old new new, assertions reversed new with a wrong column
analytics 4 errors pass pass fails ("no matching elements")
customers pass pass pass fails
orders pass pass pass fails

Unit tests for unordered_list are in #353 (scripts/tests/test_compare_events.py); main has no script test setup until #352.

🤖 Generated with Claude Code

dbt runs tests on 4 threads, so the order of
dataQualityAssertions.assertions in the test COMPLETE events changes from
run to run, and the csv_to_postgres expectations fail at random (seen on
customer_analytics: total_revenue and customer_id not_null swapped).

Compare the assertions with unordered_list. That needed a fix in
compare_events: unordered_list called the module's own any() (the jinja
helper, which returns a string) instead of the builtin and compared lists
with `is []`, so it never matched anything. No expectation used it until
now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: tnazarew <tomasz.nazarewicz@getindata.com>
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