Repository navigation
fix(data-insights): declare the data asset types once and make the field catalog deterministic - #32115
Conversation
…eld catalog deterministic
✅ Playwright Results — workflow succeededValidated commit ✅ 1146 passed · ❌ 0 failed · 🟡 4 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky PerformanceBlocking targets: ✅ met · Optimization targets: 🟡 in progress Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting. 🕒 Full workflow signal wall (to summary) 52m 15s ⏱️ Max setup 5m 37s · max shard execution 18m 5s · max shard-job elapsed before upload 21m 9s · reporting 9s 🌐 205.62 requests/attempt · 2.25 app boots/UI scenario · 35.48% common-shard skew Optimization targets still in progress:
🟡 4 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
…instead of dropping it
563a212 to
4c941ef
Compare
Code Review ✅ Approved 1 resolved / 1 findingsCentralizes Data Insights asset types into a shared enum, makes field-catalog generation deterministic by deduplicating per entity type and stabilizing iteration order, aligns categorical axis bucket selection with metric filters, and safely skips null aggregate values. Four bugs fixed: ✅ 1 resolved✅ Quality: Broad RuntimeException catch may mask unrelated bugs
OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
|
…eld catalog deterministic (#32115) * fix(data-insights): declare the data asset types once and make the field catalog deterministic * perf(data-insights): dedupe chart fields through a seen-set instead of rescanning * refactor(data-insights): read a chart metric filter through one parser * fix(data-insights): rank a categorical axis by the wrappers the request builds * fix(data-insights): catch only a parse failure when reading a chart metric filter * fix(data-insights): fail a chart metric filter the client cannot map instead of dropping it
…eld catalog deterministic (open-metadata#32115) * fix(data-insights): declare the data asset types once and make the field catalog deterministic * perf(data-insights): dedupe chart fields through a seen-set instead of rescanning * refactor(data-insights): read a chart metric filter through one parser * fix(data-insights): rank a categorical axis by the wrappers the request builds * fix(data-insights): catch only a parse failure when reading a chart metric filter * fix(data-insights): fail a chart metric filter the client cannot map instead of dropping it



Fixes #31963
Four Data Insights bugs. The first three return a number that looks fine and is wrong, with nothing thrown and nothing logged. The fourth returns HTTP 500.
1.
metricfields never reach the chart builderThe set of entity types Data Insights covers was hand-written in three places: the chart field catalog, the ingestion app, and the keys of
dataInsights/config.json. The last two stay in sync only because a mismatch throws. Nothing checked the first.#26260 added
metricto the last two in March. It was never added to the first. Sodi-data-assets-metrichas been created and filled daily ever since, whilemetricType,unitOfMeasurementandgranularityhave never appeared in the chart builder.Fix: one enum,
dataAssetType.json, that all three derive from. Ingestion still excludes the two data-quality types, which reach the wildcard through a live-index alias, so its set is the same 16 as before and ingestion is unchanged.2. The field catalog changes on every server restart
getFieldNamesdeduplicated field names globally, so the first entity type iterated claimed a shared name permanently. The iteration order came from aSet.of, which Java salts per JVM start.Measured on a seeded instance: 277 records covering 14 of 17 types.
topicshares all 28 of its field names withtable, so it advertised zero fields despite holding 47,766 documents. Picking "Topic" in the field picker returned an empty list on roughly a coin flip.Fix: deduplicate by
(entityType, name)instead ofname, and iterate the enum in order so record order is stable too.3. Charts pick categories from data they don't count
A terms x-axis picks its 100 buckets first, then counts inside them with the metric filter applied. Picking ignored the filter.
So a "tables per service" chart ranked services by their total document count. A BI service with 5,000 dashboards and 3 tables took a slot and rendered as
3. A warehouse service with 800 tables was missing from the chart entirely.Fix: order the axis by the filter aggregation each metric is already wrapped in, so a category is ranked by how much it contributed to the metric.
Two details carry the weight:
minoutranks every real minimum, and an emptysumof0outranks a negative total, so ordering by value floats the empty categories to the top and pushes real data pastsize. A document count is never negative and is zero exactly when nothing matched, so empty categories sort last and stay in the response.The request itself is left wide. Narrowing it to the metric filter would align picking too, but
termsusesmin_doc_count: 1, so every category the filter emptied would lose its bucket and the chart could no longer say that a service holds none.Measured through the server, 120 services of which 10 hold tables, axis size 100:
Identical on Elasticsearch 9.3 and OpenSearch 3.4.
@timestampcharts are untouched: a date histogram has no top-N to align.4. An empty category returns HTTP 500
avg,minandmaxover a bucket the metric filter emptied returnnull, not0. There is no average of nothing. Both aggregators unbox that straight into a primitive:Nothing catches it, so the request dies and the user gets a 500 rather than a chart.
sumandcountreturn0.0, which is why only those three functions are affected.This exists on
maintoday and is not caused by this PR. §3 makes it reachable, because keeping the empty categories is what produces thenullbuckets.Fix: null-check before unboxing, on both engines. A category with no value is skipped rather than drawn as
0, since0is a legitimate average and would be a wrong answer. Elasticsearch had split the same job across three overloads, so the redundantValueCountAggregateone is gone andvalue_countnow binds to the guarded path. It never returns null, so nothing changes for it.Tests
Each verified to fail against the bug it guards:
metricremoved fromconfig.jsonmetricexpected: <[table, topic]> but was: <[table]>toUnmodifiableSet()commonlist mutated in place againexpected: <[id, service]> but was: <[id, columns, service]>data-000 must be selectedaFilterTheClientCannotMapLeavesTheAxisUnrankedInvalid aggregation order path [filter>id.keyword0]expected: <[filter1, filter0]> but was: <[filter0, filter1]>q=wrapper allowed to rank the axisaPerTermQueryAloneDoesNotRankTheAxisDouble.doubleValue()NPE, per engineElasticSearchCategoricalAxisRealEngineTestandOpenSearchCategoricalAxisRealEngineTestare new. They run the requestprepareSearchRequestactually builds against a real Elasticsearch 9.3 and OpenSearch 3.4 via testcontainers, about 12s each. Every defect in §3 was invisible at the serialization level, because a request that looks correct can still be rejected or silently mis-ordered by the engine. Both classes also assert the control,main's shape picking 0 of 10, so the fixture cannot quietly stop discriminating.Greptile Summary
This PR centralizes Data Insights asset types, makes field-catalog generation deterministic, aligns categorical bucket selection with metric filters, and safely skips null aggregate values.
DataAssetTypeenum shared by ingestion and chart-field discovery.Confidence Score: 3/5
The PR is not yet safe to merge because malformed empty filters still crash parsing and unmappable Elasticsearch filters can escape single-KPI result requests.
The bulk KPI recovery now handles conversion failures, but the same runtime exception remains uncaught in
getKpiResult; additionally, the previously reported null dereference for empty filter text is still present.Files Needing Attention: openmetadata-service/src/main/java/org/openmetadata/service/search/DataInsightMetricFilter.java; openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/dataInsightAggregators/ElasticSearchDynamicChartAggregatorInterface.java; openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/KpiRepository.java
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart LR C[Data Insights chart definition] --> P[Parse metric filter] P --> B[Build metric wrapper aggregation] B --> T[Terms axis ordered by wrapper document count] T --> E[Elasticsearch or OpenSearch] E --> R[Skip null metric values and return chart rows] K[KPI result request] --> CReviews (5): Last reviewed commit: "Merge branch 'main' into fix/di-data-ass..." | Re-trigger Greptile
Context used: