Skip to content

tableCustomSQLQuery: passing test with operator "==" and threshold 0 reports 100% failed rows #38561

Backlog

Description

@ashdam

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

  1. Take a table with N rows (N > 0).
  2. Create a tableCustomSQLQuery test on it with:
    • sqlExpression: any query returning 0 rows, e.g. SELECT * FROM <table> WHERE 1 = 0
    • strategy: ROWS, operator: ==, threshold: 0
    • computePassedFailedRowCount: true
  3. Run the test suite pipeline.
  4. Read the test case result.

Actual result:

  • testCaseStatus: Success, result Found 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

  1. added
    bug
    on Nov 24, 2026
  2. added 2 commits that reference this issue on Nov 25, 2026
    45892ee
    bd773ac
  3. added a commit that references this issue on Nov 26, 2026
    fdb2c07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Ingestionbug

    Type

    No type

    Projects

    • Status
      No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions