Repository navigation
Description
Bug
Data Quality undercounts the total number of tables, causing its asset total and coverage denominator to disagree with Data Insights.
User-reported observations for the same catalog:
- Data Insights → Total Data Assets: 10,233 tables (correct).
- Data Quality → Summary → Data Assets Coverage: 10,206 tables.
- Data Quality → Test Cases: the same 10,206 denominator is used for the displayed 3.95% coverage.
- Replacing the total-count aggregation with
value_countreturns 10,233, according to the reported investigation.
The total is understated by 27 tables, which also inflates the coverage percentage. The expected denominator is the exact number of matching table documents.
Root cause, grounded in code
fetchTotalEntityCount queries the table index using:
bucketName=count:aggType=cardinality:field=fullyQualifiedName
This estimates the number of distinct indexed fully qualified names (FQNs—the full service/database/schema/table name), rather than counting tables.
Both affected views consume this helper:
- Data Assets Coverage widget reads the returned
fullyQualifiedNamevalue as its total. - DataQualityProvider uses it to populate
totalEntityCountfor the Test Cases summary.
Two effects explain the reported discrepancy:
- Case normalization: 1 table. The table index mapping applies
lowercase_normalizertofullyQualifiedName; the normalizer definition lowercases values. The reported pair of Snowflake tables whose names differ only by case therefore contributes one distinct indexed name instead of two table documents. - Approximate cardinality: 26 tables. The Elasticsearch cardinality builder sets only the field, with no precision override. Elasticsearch documents cardinality as approximate, with a default precision threshold of 3,000. The reported remaining difference is estimation error at this catalog size. The threshold is an accuracy/memory tradeoff, not a guarantee of exactness below 3,000.
Thus the reported breakdown is 10,233 documents → 10,232 distinct normalized names → 10,206 estimated distinct names. The numerical breakdown and successful user-index query are supplied by the reporter; the code inspection independently confirms the mechanisms and shared callers.
This aggregation was introduced with the DQ dashboard in PR #18146: original implementation at the merge commit. The total-count expression remains unchanged.
Proposed fix
Change the aggregation type in fetchTotalEntityCount:
- aggregationQuery: `bucketName=count:aggType=cardinality:field=fullyQualifiedName`,
+ aggregationQuery: `bucketName=count:aggType=value_count:field=fullyQualifiedName`,value_count counts values without deduplicating them. With one populated, single-valued FQN per table document, this gives the exact table count, including case-colliding names, without cardinality estimation. It preserves the bucket name, field, filters, domain scope, and response consumed by both views.
The backend already implements this aggregation for Elasticsearch and OpenSearch.
Scope this change to the table denominator. fetchEntityCoveredWithDQ counts distinct assets across test-case documents, where multiple tests can belong to one table; replacing that aggregation with a value count would count tests rather than assets.
Reproduction and acceptance criteria
- Compare the three views with equivalent catalog scope and filters.
- On the affected catalog, confirm the existing cardinality query returns 10,206 and the proposed value-count query returns 10,233.
- Confirm Summary and Test Cases both use 10,233 after the fix and recalculate coverage using that denominator.
- Add regression coverage for two distinct table documents with case-only FQN differences and for a catalog above 3,000 tables; verify exact totals on Elasticsearch and OpenSearch.
- Update the API helper tests to expect
value_count, retaining filter/domain coverage. Confirm the field remains populated and single-valued for counted table documents.
User deployment version was not supplied. This issue records the diagnosis and proposed fix; no implementation or user-environment test was performed while filing it.
Source rationale: Repository code and the introducing PR establish the actual request, mapping, consumers, and history. Elasticsearch's implementation documentation establishes aggregation semantics and precision defaults. user-specific counts are explicitly attributed to the report.
Activity