Repository navigation
Description
Affected module
Data Quality / Profiler
Describe the bug
A tableCustomSQLQuery test with computePassedFailedRowCount = true, strategy ROWS,
operator == and threshold 0 that passes (the query returns 0 rows) stores
passedRows = 0 and failedRows = <table row count> (100% failed), although the
status is Success.
When the same test fails (the query returns N > 0 rows) the counts are correct:
failedRows = N, passedRows = rowCount - N.
To Reproduce
- Take a table with N rows (N > 0).
- Create a
tableCustomSQLQuerytest on it with:sqlExpression: any query returning 0 rows, e.g.SELECT * FROM <table> WHERE 1 = 0strategy:ROWS,operator:==,threshold:0computePassedFailedRowCount:true
- Run the test suite pipeline.
- Read the test case result.
Actual result:
testCaseStatus:Success, resultFound 0 row(s). Test query is expected to return == 0 row(s).passedRows:0,failedRows:N,failedRowsPercentage:100
Expected behavior
passedRows = N, failedRows = 0, failedRowsPercentage = 0.
Root cause
ingestion/src/metadata/data_quality/validations/table/base/tableCustomSQLQuery.py,
_calculate_passed_rows_success:
elif operator == "==":
passed_rows = len_rows
failed_rows = row_count - len_rows
For == the rows returned by the query are counted as passed rows and the rest of
the table as failed. With threshold 0, which is the usual "this query returns the
offending rows and none are expected" setup, a passing test therefore reports the
whole table as failed. The < / <= branch does the opposite
(passed_rows = row_count - len_rows, failed_rows = len_rows) and gives correct
counts for the same test.
Workaround
Use operator <= with threshold 0 instead of ==. Verdict is identical and the
counts are correct both when the test passes and when it fails.
Version
- OpenMetadata 2.0.7 (logic still present on
main) - Source: Snowflake (the code path is not connector-specific for SQLAlchemy sources)
- Ingestion run from the OpenMetadata UI (Airflow)
OS
Ubuntu 22.04
Python version
No response
OpenMetadata version
2.0.7 (logic still present on main)
OpenMetadata Ingestion package version
No response
Additional context
Reproduced on five different passing tests and on four SQL variants of the same
check (with/without LIMIT, with/without OR in the WHERE, different join
conditions): all store passedRows = 0, failedRows = rowCount.
Pre-submission checklist
- I searched for duplicate issues.
- I removed credentials, hostnames, emails, and other sensitive data from logs and config.
Activity
Fixes open-metadata#38561: expect no failed rows for a passing == 0 o…
Fixes open-metadata#38561: count the returned rows as failed for a pa…
Fixes open-metadata#38561: count == custom SQL failed rows as the dis…