Skip to content

Fixes #37896: Data Insights categorical axis lists only the categories its chart counts - #37897

Merged
pmbrull merged 1 commit into
mainfrom
pmbrull/di-scoped-terms-axis
Nov 16, 2026
Merged

pmbrull merged 1 commit into
mainfrom
pmbrull/di-scoped-terms-axis

Conversation

@pmbrull

@pmbrull pmbrull commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

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
filter matches, combined with the snapshot range when the request is not live. A breakdown scoped
to 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:

  • Real zeros keep their bucket. A term's own q= never narrows the population. With several
    metrics, a metric still reads 0 for a category that only another metric counts.
  • A metric with no filter keeps the request wide, and an unreadable filter still counts as none.
  • @timestamp charts are untouched, groups included.

What else changes:

  • Groups: a categorical chart's groupBy draws its groups from the same population.
  • Built-in categorical charts read for one service or domain are narrowed too, because
    DataInsightSystemChartRepository merges the caller's filter and the navbar domain into every
    metric. 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.
  • Empty scope: a scope that matches no document returns no buckets, instead of a breakdown of
    zeros.
  • Condition filters: a filter that holds a condition rather than a scope now drops a category
    where nothing matches it. Collate's chart builder in function mode writes such filters. To keep
    that 0, put the scope in filter and the condition in a formula's q=.

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:

  • Bug fix

High-level design:

  • One rule, both engines. DataInsightMetricFilter.populationFilters returns the distinct
    query JSON of every metric filter, or nothing when any metric is unfiltered. Each engine's line
    chart aggregator turns that into one should clause per filter (minimum_should_match: 1) and,
    when the request is not live, combines it with the @timestamp range.
  • Built after the metrics loop. The Elasticsearch client has therefore already rejected an
    unmappable filter, and the request can never disagree with the wrappers about the population.
  • No response change. The response shape is unchanged, so parsing does not change; the only
    difference is fewer buckets.

Tests:

Use cases covered

  • A tables-per-service chart lists only services that hold tables. Before this change it listed
    dashboard-only services at 0, up to the 100-bucket axis size.
  • A q= count that matches nothing in a counted service keeps that service at 0.
  • Two metrics (tables, dashboards) still report a dashboard-only service at 0 tables.
  • A grouped categorical chart lists only the groups its metric counts.
  • A built-in chart read for one service, with the filter merged by
    DataInsightSystemChartRepository.combineFilters, lists only that service.
  • A metric without a filter, and an @timestamp axis, keep the request wide.

Unit tests

  • I added unit tests for the new/changed logic.
  • Real-engine tests on OpenSearch 3.4 and Elasticsearch 9.3 (Testcontainers):
    • CategoricalAxisSelectionTestBase, five cases;
    • DataInsightMetricFilterTest;
    • the line chart aggregator unit tests on both engines.
  • Red against main's aggregators:
    • 10 failures in the first pass.
    • The second pass covered the grouped and built-in cases. They failed on Elasticsearch, and the
      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.
    • The guard tests pass on main, as designed.
  • Green: 110 run, 0 failures. This set covers the line chart aggregators (unit and real-engine, both
    engines), chart scope, chart-scope SQL migrations, type coverage, KPI and metric filter tests.
  • mvn spotless:apply and the decision record check are clean.
  • The branch was rebased onto main after these runs. None of the 27 new commits touch these files.

Integration tests

  • Not run locally: openmetadata-integration-tests.
  • DataInsightTestCaseCoverageIT already treats "no bucket" as uncovered, and its filtered live
    chart answers the same either way.

Manual / UI

  • Not run: the UI service Insights tab, PII and tier distributions.

Self-review

  • An independent review against REVIEW.md found 1 🔴 and 4 🟡, all fixed in this commit:
    • 🔴 the built-in charts claim;
    • 🟡 grouped charts untested;
    • 🟡 a termsAxis Javadoc case;
    • 🟡 the rule duplicated per engine;
    • 🟡 a context sentence that assumed every filter is a scope.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed. (no schema change)
  • I have added tests that prove my fix is effective or that my feature works.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence 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.

  • Categorical charts now list only categories their metrics count.

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]
Loading

Reviews (1) · Last reviewed commit: "fix(data-insights): draw a categorical a..." · Reviewed by Greptile

…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]>
@pmbrull
pmbrull requested a review from a team as a code owner November 16, 2026 12:35
@pmbrull
pmbrull requested review from TeddyCr and a balanced review from Copilot November 16, 2026 12:35
@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR checks passed

The linked issue has a description and all required Shipping project fields set. Thanks!

@gitar-bot

gitar-bot Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved 🟡 Medium risk

Narrowing 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.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.
@pmbrull
pmbrull merged commit e93e70f into main Nov 16, 2026
55 of 57 checks passed
@pmbrull
pmbrull deleted the pmbrull/di-scoped-terms-axis branch November 16, 2026 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Data Insights: a filtered breakdown lists categories held only outside its filter, at 0

3 participants