Repository navigation
Fixes #37896: Data Insights categorical axis lists only the categories its chart counts - #37897
Conversation
…ts chart counts
A categorical (terms) x-axis bucketed every document of the day and applied each metric's filter
only inside each bucket, so a breakdown scoped to tables listed every category held by other asset
types at 0 (an owner of dashboards only, a dashboard-only service). Those rows read as real zeros
in custom charts, pinned charts and AI chat answers ("45 owners hold tables" where 17 do).
The request now queries the chart's population, the documents at least one metric's filter
matches, and a categorical chart's groupBy draws its groups from it too. A category the chart
counts keeps its bucket: a term's own q= never narrows the population, and with several metrics
one metric still reads 0 where only another counts. A metric without a filter keeps the request
wide, and @timestamp charts are untouched. Built-in categorical charts read for one service or
domain are narrowed as well, because the repository merges that filter into every metric.
ADR:2026-11-16-a-categorical-axis-lists-only-the-categories-its-chart-counts
Co-Authored-By: Claude Opus 5.5 <[email protected]>
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
Code Review ✅ Approved 🟡 Medium riskNarrowing categorical Data Insights queries to metric-filter populations could omit zero-valued categories and change chart breakdowns and AI chat results. Categorical Data Insights axes now list only the categories their chart counts, by querying the chart's population from metric filters and the snapshot range, so breakdowns scoped to tables no longer show other asset types' categories at 0. No issues found. VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
There was a problem hiding this comment.
🟡 Changes recommended
The decision record overstates the change’s scope by implying that historical total_data_assets categories are narrowed when only total_data_assets_live is affected.
1 open issue
What changed in this PR
No blocking issues.
This PR addresses #37896 by limiting categorical Data Insights charts to categories matched by at least one metric’s filter, replacing the wide-query behavior retained by #32115.
Changes:
- Shares population-filter selection across Elasticsearch and OpenSearch, preserving snapshot ranges and leaving timestamp charts unchanged.
- Preserves categories with zero counts from formula conditions or other metrics.
- Adds unit and real-engine regression coverage and records the behavior change in a decision record.
| File | Description |
|---|---|
openmetadata-service/src/test/java/org/openmetadata/service/search/opensearch/dataInsightAggregator/OpenSearchLineChartAggregatorTest.java |
Verifies OpenSearch population queries and unfiltered fallback. |
openmetadata-service/src/test/java/org/openmetadata/service/search/elasticsearch/dataInsightAggregators/ElasticSearchLineChartAggregatorTest.java |
Verifies Elasticsearch population queries and unfiltered fallback. |
openmetadata-service/src/test/java/org/openmetadata/service/search/DataInsightMetricFilterTest.java |
Tests filter deduplication and unrestricted population handling. |
openmetadata-service/src/test/java/org/openmetadata/service/search/dataInsight/OpenSearchCategoricalAxisRealEngineTest.java |
Supports varied charts in real-engine tests. |
openmetadata-service/src/test/java/org/openmetadata/service/search/dataInsight/ElasticSearchCategoricalAxisRealEngineTest.java |
Supports varied charts in real-engine tests. |
openmetadata-service/src/test/java/org/openmetadata/service/search/dataInsight/CategoricalAxisSelectionTestBase.java |
Tests category selection, retained zeros, grouping, and service scope. |
openmetadata-service/src/main/java/org/openmetadata/service/search/opensearch/dataInsightAggregator/OpenSearchLineChartAggregator.java |
Applies population filtering to OpenSearch categorical requests. |
openmetadata-service/src/main/java/org/openmetadata/service/search/elasticsearch/dataInsightAggregators/ElasticSearchLineChartAggregator.java |
Applies population filtering to Elasticsearch categorical requests. |
openmetadata-service/src/main/java/org/openmetadata/service/search/DataInsightMetricFilter.java |
Extracts distinct metric filters for population selection. |
docs/decisions/2026-11-16-a-categorical-axis-lists-only-the-categories-its-chart-counts.md |
Records the categorical-axis contract and its consequences. |
Review effort: Balanced
| their own, but `DataInsightSystemChartRepository` merges the caller's filter and the navbar domain | ||
| into every metric. So a built-in chart read for one service or domain no longer lists other | ||
| services, tag groups or entity types at 0. That applies to the service page's PII and tier | ||
| distributions, and to the total data assets chart under a domain. |

Describe your changes:
Fixes #37896
A categorical Data Insights axis now lists only the categories its chart counts. For a terms
x-axis, the request queries the chart's population: the documents that at least one metric's
filtermatches, combined with the snapshot range when the request is not live. A breakdown scopedto tables therefore no longer lists every category held by other asset types at 0. This covers
custom charts, AI chat charts and Collate's pinned-chart refresh.
What stays:
q=never narrows the population. With severalmetrics, a metric still reads 0 for a category that only another metric counts.
@timestampcharts are untouched, groups included.What else changes:
groupBydraws its groups from the same population.DataInsightSystemChartRepositorymerges the caller's filter and the navbar domain into everymetric. The service page's PII and tier distributions, and the total data assets chart under a
domain, stop listing other services, tag groups or entity types at 0.
zeros.
where nothing matches it. Collate's chart builder in function mode writes such filters. To keep
that 0, put the scope in
filterand the condition in a formula'sq=.This reverses #32115's choice to keep the request wide. Its reason was that a single-metric
chart could then say a service holds none. Those zeros only ever covered categories other asset
types held, and only while fewer than 100 categories matched, so they never formed a complete
list. A two-metric chart still shows them.
ADR:2026-11-16-a-categorical-axis-lists-only-the-categories-its-chart-counts.
Type of change:
High-level design:
DataInsightMetricFilter.populationFiltersreturns the distinctquery JSON of every metric filter, or nothing when any metric is unfiltered. Each engine's line
chart aggregator turns that into one
shouldclause per filter (minimum_should_match: 1) and,when the request is not live, combines it with the
@timestamprange.unmappable filter, and the request can never disagree with the wrappers about the population.
difference is fewer buckets.
Tests:
Use cases covered
dashboard-only services at 0, up to the 100-bucket axis size.
q=count that matches nothing in a counted service keeps that service at 0.DataInsightSystemChartRepository.combineFilters, lists only that service.@timestampaxis, keep the request wide.Unit tests
CategoricalAxisSelectionTestBase, five cases;DataInsightMetricFilterTest;main's aggregators:grouped unit test failed on both engines. The OpenSearch container did not start in that run
because of local Docker contention, so the shared real-engine cases have no OpenSearch red result
for those two.
main, as designed.engines), chart scope, chart-scope SQL migrations, type coverage, KPI and metric filter tests.
mvn spotless:applyand the decision record check are clean.mainafter these runs. None of the 27 new commits touch these files.Integration tests
openmetadata-integration-tests.DataInsightTestCaseCoverageITalready treats "no bucket" as uncovered, and its filtered livechart answers the same either way.
Manual / UI
Self-review
REVIEW.mdfound 1 🔴 and 4 🟡, all fixed in this commit:termsAxisJavadoc case;Checklist:
Fixes <issue-number>: <short explanation>🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge; no actionable defects were found.Summary
Categorical Data Insights charts now draw categories and groups only from documents matched by at least one metric's
filter.Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Chart request] --> B{Categorical axis?} B -->|No| C[Keep existing query] B -->|Yes| D{Every metric has a readable filter?} D -->|No| C D -->|Yes| E[Match any distinct metric filter] E --> F{Historical request?} F -->|Yes| G[Also apply snapshot range] F -->|No| H[Use live index] G --> I[Build category and group buckets] H --> I I --> J[Each metric still applies its own filter]Reviews (1) · Last reviewed commit: "fix(data-insights): draw a categorical a..." · Reviewed by Greptile