Repository navigation
Fixes #17323: Inherit query domains from associated tables - #32130
Conversation
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
There was a problem hiding this comment.
Pull request overview
This PR fixes the domain-filtered query visibility bug by ensuring Query entities inherit effective domains from every associated Table, and by reindexing affected query documents when either query usage or upstream domain sources (service/database/schema/table) change.
Changes:
- Compute and return inherited query domains as the deduplicated union of effective domains across all
queryUsedIntables (while preserving the existing “explicit query domains override” behavior). - Reindex impacted queries in search when table usage or table/ancestor domain relationships change.
- Add unit, integration, and Playwright coverage validating multi-table inheritance and search/domain filter behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/DomainFilterQueryFilter.spec.ts | Adds E2E coverage ensuring queries are visible under each applicable domain when a query references multiple tables. |
| openmetadata-service/src/test/java/org/openmetadata/service/search/SearchRepositoryBehaviorTest.java | Extends unit test expectations to ensure query domain fields are included in partial search update scripts/params when query usage changes. |
| openmetadata-service/src/test/java/org/openmetadata/service/jdbi3/QueryDomainInheritanceTest.java | Adds unit tests covering unioned inheritance, explicit override behavior, and replacement of stale inherited domains on usage changes. |
| openmetadata-service/src/main/java/org/openmetadata/service/search/SearchRepository.java | Triggers query reindexing when domain sources change and ensures partial updates also refresh domains on query usage updates. |
| openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/QueryRepository.java | Loads effective table domains in bulk and resolves inherited query domains whenever domains are requested or query usage changes. |
| openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/QueryDomainInheritance.java | Implements domain inheritance resolution logic for queries based on associated tables’ effective domains. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/QueryResourceIT.java | Adds integration tests validating domain inheritance, and search behavior on table domain changes and query usage changes. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
A query inherits the union of the domains of the tables in its queryUsedIn, so a query spanning tables in different domains legitimately carries multiple domains. The "Multiple Domains are not allowed" and "Data Product Domain Validation" rules only exempt user/team/persona/bot, and the rule engine counts inherited domains (JsonUtils.getMap of the entity) unlike getValidatedDomains, which skips all-inherited sets. As a result a full-body update that echoed the inherited domains back was rejected with a 400. - entityRulesSettings.json: add "query" to ignoredEntities of both domain rules (applies to fresh installs, which seed from this file). - v210 migration: reconcile the persisted setting on existing instances, since SettingsCache seeds the JSON only when the setting is absent. The logic is idempotent and scoped to the two system domain rules; other rules and user customizations are preserved. - Tests: unit test for the exemption logic (add, idempotency, scoping, null-safety) and an IT regression proving a read-modify-write of a multi-domain query is no longer blocked by the rule.
…tion Harden the v210 migration: a customized or older persisted domain rule could carry a null ignoredEntities list, in which case the exemption was silently skipped and the query would still trip the single-domain rule after upgrade. Initialize the list when null so the exemption always applies.
…-inheritance # Conflicts: # openmetadata-service/src/main/java/org/openmetadata/service/migration/mysql/v210/Migration.java # openmetadata-service/src/main/java/org/openmetadata/service/migration/postgres/v210/Migration.java # openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v210/MigrationUtil.java
Code Review ✅ Approved 5 resolved / 5 findingsAdds query domain inheritance from associated active tables with batched keyset-paginated propagation and search reindexing. Issues including unbounded query fan-out on domain change, duplicate set declarations, null ✅ 5 resolved✅ Performance: Unbounded query fan-out on service/db/schema domain change
✅ Quality: Two divergent QUERY_DOMAIN_SOURCE_TYPES sets with same name
✅ Edge Case: Rule with null ignoredEntities is silently skipped
✅ Quality: v210 runDataMigration omits archiveLegacyThreadStorage
✅ Edge Case: Inherited domains include soft-deleted tables
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 |
| // Reconcile the persisted entityRulesSettings so upgraded instances allow queries to carry the | ||
| // multiple domains they inherit from their associated tables. Fresh installs get this from the | ||
| // packaged JSON default; existing installs only through this migration. | ||
| exemptQueryFromMultiDomainRules(); |
Describe your changes:
Fixes #17323
Queries now inherit the effective domains of every associated table so a multi-table query appears under each applicable domain.
Type of change:
High-level design:
QueryRepositorycomputes a deduplicated union of effective domains from non-deletedqueryUsedIntables, while explicit query domains preserve the existing override behavior. Domain propagation now resolves distinct affected query IDs directly from active table relationships with keyset pagination in batches of 100, avoiding descendant-table materialization and unboundedINlists; exact-table lookup remains available during soft deletion so dependent query search documents can drop stale domains. Reindexing still runs after commit for usage, table/ancestor domain, and table deletion-state changes; no migration is required.Tests:
Use cases covered
Unit tests
QueryDomainInheritanceTest,QueryRepositoryDomainReindexTest,SearchRepositoryBehaviorTest,SearchRepositoryTestBackend integration tests
openmetadata-integration-tests/for the changed API/search behaviorQueryResourceITIngestion integration tests
Playwright (UI) tests
openmetadata-ui/.../ui/playwright/DomainFilterQueryFilter.spec.tsManual testing performed
No manual testing was performed; the behavior was verified with isolated PostgreSQL/Elasticsearch integration tests.
UI screen recording / screenshots:
Not applicable -- there are no production UI changes.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.Greptile Summary
The PR makes queries inherit the deduplicated effective domains of their active associated tables while preserving explicit query-domain overrides.
Confidence Score: 5/5
The PR appears safe to merge.
No blocking failure remains; the previous deleted-table finding is addressed by loading domain sources with non-deleted semantics and is covered by an integration test that verifies both API and search domains after table soft deletion.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart LR T[Active associated tables] --> E[Resolve effective table domains] E --> U[Deduplicate domain union] Q[Query] --> X{Explicit domains present?} X -->|Yes| O[Keep explicit query domains] X -->|No| U U --> I[Inherited query domains] I --> A[Query API response] I --> S[Query search document] D[Table or ancestor domain/lifecycle change] --> P[Page affected query IDs] P --> SReviews (9): Last reviewed commit: "fix(playwright): match dotted domain fil..." | Re-trigger Greptile