Skip to content

Fixes 31512: Ingest SQL Server synonyms as Table.aliases - #31829

Merged
ulixius9 merged 45 commits into
mainfrom
hangzhou
Sep 9, 2026
Merged

ulixius9 merged 45 commits into
mainfrom
hangzhou

Conversation

@ulixius9

@ulixius9 ulixius9 commented Aug 20, 2026 •

Copy link
Copy Markdown
Member

Describe your changes:

Fixes #31512

I worked on ingesting SQL Server synonyms because the MSSQL connector discovers tables and views through INFORMATION_SCHEMA.TABLES, so synonyms — a separate object type — were invisible, and any query or view definition referencing a synonym produced no lineage.

A deliberate design divergence worth flagging up front: the issue text asks for synonyms "represented as entities." This PR instead implements the embedded-aliases model — a synonym is recorded as an alternate fully-qualified name on the canonical Table, not as a second entity. That follows the recommendation in the design note, which compares three models and rejects the standalone-entity option: it would create two pages and two search identities for one governed asset, force every generic feature to either support or exclude the alias, make owners/tags/domains/policies ambiguous, inflate asset counts, and need special lineage rules to avoid target -> alias -> consumer edges. If reviewers want the entity model instead, that is a scope decision to settle before this merges.

Screen.Recording.2026-08-20.at.6.26.04.PM.mov

Type of change:

  • New feature

High-level design:

A synonym's alternate FQN is stored in a new source-managed Table.aliases[] array. One governed asset, one page, one search identity.

The ordering problem and how it's solved. The alias has to be written onto the target table's create request, but the target usually lives in a different database than the synonym, and get_database_names() walks databases one at a time re-pointing the inspector — so when analytics_core is being ingested we cannot reach into analytics_master. The connector therefore sweeps sys.synonyms across every in-scope database up front in prepare() (which runs before the topology produces anything), builds a bounded target FQN -> [alias FQNs] map, and resolves targets by construction: a new get_table_aliases() hook looks the current table's own FQN up in that map.

Consequences of that choice:

  • Nothing consults Elasticsearch on the write path. skip_es_search=True is load-bearing — on an index miss fqn.build returns a literal FQN string that no later exact lookup matches.
  • Reconciliation is free. The full alias list ships inside the create request every run, so created / dropped / retargeted synonyms all reconcile through ordinary upsert semantics — no diffing stage, no reconciliation logic. This depends on a PUT replacing the array, which is verified by integration test rather than assumed.

Key components:

  • mssql/synonyms.py (new) — bracket-aware T-SQL identifier tokenizer, base_object_name normalization, and the bounded SynonymMap.
  • common_db_source.py — a generic get_table_aliases() hook (returns None by default) beside the existing get_source_url / get_location_path hooks. No SQL Server knowledge enters this shared file.
  • TableMapper + TableRepository — the two server-side wirings that make the field actually persist. recordListChange (not recordChange) follows GlossaryTerm.synonyms, the closest analogue: plain recordChange compares lists with Object::equals, which is order-sensitive and does not normalize null against [], so it would bump the version and emit a change event on every run for an unchanged alias set.
  • sql_lineage.py + es_mixin.py — an exact-alias fallback in the generic resolver. This is deliberate: MssqlLineageSource is a separate source class in a separate workflow, so a lineage run never executes MssqlSource.prepare() and cannot see that map. Putting the fallback in search_table_entities covers both workflows and any future connector that populates aliases. Matching is keyword-exact only — a fuzzy hit would silently attach an edge to the wrong table.
  • searchSettings.json + v210/MigrationUtil — aliases added to the table searchFields and highlightFields, with a migration so upgraded instances get it too, not just fresh installs.

Backward compatibility. Tables with no aliases are unaffected: the hook returns None for every non-MSSQL connector, and recordListChange short-circuits when both sides are empty, so there is no version bump, change event, or feed entry. One expected one-time effect: aliases now participates in sourceHash, so the first ingestion run after upgrade recomputes a different digest for every table in every SQL connector and skips none. That is inherent to adding any CreateTableRequest field.

Known limitation. sys.synonyms.base_object_name preserves the casing typed in CREATE SYNONYM with no normalization to the target's stored casing, so under SQL Server's default case-insensitive collation the map lookup is case-folded. The inverse trade is that under a case-sensitive (CS_AS) collation two targets differing only in case would merge — strictly rarer than the bug it fixes.

Tests:

Use cases covered

  • A cross-database synonym (analytics_core.dbo.orders -> analytics_master.dbo.orders) attaches as an alias on the canonical table in analytics_master.
  • A synonym pointing at a non-existent object is reported as an unresolved-synonym warning in the pipeline status, not silently dropped.
  • A synonym pointing at a linked server (4-part name) is reported RemoteTargetUnmapped.
  • Dropping a synonym at the source clears the alias on the next run; retargeting moves it, leaving no stale entry.
  • Lineage from a query referencing the synonym name attaches its edge to the canonical table, never to the synonym.
  • The table detail page shows a read-only Aliases section; a table with no aliases shows no widget.

Unit tests

  • I added unit tests for the new/changed logic.
  • Ingestion: tests/unit/topology/database/test_mssql_synonyms.py (45 tests — tokenizer, base_object_name parsing, bounded map, case-folding, sweep, source wiring, unresolved reporting), test_common_db_source_aliases.py, test_source_hash.py, test_table_aliases_schema.py, tests/unit/lineage/test_alias_resolution.py.
  • Backend: TableIndexTest.java, migration/utils/v210/MigrationUtilTest.java.
  • UI: TableAliases.test.tsx (3 tests).
  • Results on this branch: ingestion unit suite 8780 passed; mvn -pl openmetadata-service test -Dtest='TableIndexTest,MigrationUtilTest' 148 passed, 0 failures; yarn test --testPathPattern TableAliases 3 passed. spotless:check and make py_format_check clean.
  • Coverage %: not measured — jacoco:report / --cov were not run. Stating that rather than guessing a number.

Backend integration tests

  • I added integration tests in openmetadata-integration-tests/ for new/changed API endpoints.
  • TableResourceIT#put_tableAliases_replaceNotMerge — covers initial set, retarget, and clear, asserting on the entity re-fetched from the server rather than the mutation response. This test is why the "reconciliation is free" claim above is a verified property and not an assumption; the first version of it passed while persistence was actually broken, because it only proved the response echoed the request.

Ingestion integration tests

  • I added/updated ingestion integration tests for connector changes.
  • Verified against a real SQL Server 2022 container (created and torn down): the sweep discovers synonyms from live sys.synonyms, cross-database resolution works, and an unresolvable synonym lands in the unresolved report. Real base_object_name format observed: fully bracket-quoted three-part, case preserved as typed.

Playwright (UI) tests

  • I added Playwright E2E tests under openmetadata-ui/.../ui/playwright/.
  • playwright/e2e/Pages/TableAliases.spec.ts — executed and passing against a live stack built from this branch (5 passed, 42.4s).

Manual testing performed

  1. Started a standalone SQL Server 2022 container on non-conflicting ports.
  2. Created analytics_master with dbo.orders, and analytics_core with CREATE SYNONYM dbo.orders FOR analytics_master.dbo.orders plus CREATE SYNONYM dbo.missing_orders FOR analytics_master.dbo.does_not_exist.
  3. Drove the connector's sweep and confirmed the map keyed ...analytics_core.dbo.orders against target ...analytics_master.dbo.orders.
  4. Confirmed missing_orders appeared in unresolved() rather than being dropped.
  5. Inspected the real base_object_name values returned by sys.synonyms to validate the parser against actual server output rather than assumed formatting.

Since opening this PR, the whole flow has been verified end to end against a live stack built from this branch (server revision 2418c14062, Elasticsearch 9.3.0) plus a real SQL Server 2022 CU26 container. Every claim above is now backed by execution rather than tracing:

Check Result
Cross-database synonym attaches to canonical table analytics_master.dbo.orders -> aliases: [...analytics_core.dbo.orders]
Case-mismatched synonym (FOR ...dbo.customers vs actual table Customers) resolves correctly — the case-folding fix works against a real server
Unresolved + linked-server synonyms reported as Unresolved / RemoteTargetUnmapped in pipeline status; run stayed 100% / 0 errors
Alias free-text search canonical table returned and ranked first; highlight returns the matched alias; the synonym never appears as its own entity
Exact aliases.keyword lookup (the resolver's ES call) exactly 1 hit -> canonical table, and case-insensitive
Real lineage edge through a synonym a view in analytics_core selecting FROM dbo.orders_v2 (a synonym) produced the edge analytics_master.dbo.orders -> analytics_core.dbo.orders_summary — resolved across databases, with the synonym never appearing as a lineage node
Model-1 invariant analytics_core.dbo contains only the view; no synonym leaked in as an entity
sourceHash stability two full ingestion runs, both tables stayed at version 0.1 — no spurious bump
Retarget / drop reconciliation renaming the synonym replaced the array wholesale: stale alias gone, version 0.1 -> 0.2, search returns 0 hits for the dropped alias and 1 for the new one

One caveat found while testing, not shipped-breaking: MssqlSource.close() is not idempotent — calling it twice duplicates the unresolved-synonym warnings. The normal workflow path calls it once (runs correctly report 2 warnings, not 4), so this is a latent robustness nit rather than a live defect.

A correction to my own earlier wording: the exact-keyword check above proves the resolver's lookup, not that an edge gets created. Those are different claims, so I tested the second one separately by adding a view that selects from a synonym and running the lineage workflow — the edge lands on the canonical table, which is the row now in the table above.

One note on the spec's "searching an alias returns one result" wording: an exact keyword lookup does return exactly one. An analyzed free-text search returns the canonical table ranked first, but sibling tables whose alias FQNs share tokens can also match — ordinary analyzed-search behaviour. The property that matters holds: one governed asset is never duplicated, and the synonym is never its own result.

UI screen recording / screenshots:

TODO — opening as draft. The UI change is a read-only Aliases widget on the table detail page; a recording needs a stack with ingested alias data, which I could not stand up here.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.
  • 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.
  • For UI changes: I attached a screen recording and/or screenshots above.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • The issue properly describes why the new feature is needed, what's the goal, and how we are building it.
  • I have updated the documentation.
  • I have added tests around the new logic.

ulixius9 and others added 28 commits August 19, 2026 17:08
Adds an aliases[] array of alternate fully-qualified SQL names (e.g.
SQL Server synonyms) to Table and CreateTableRequest, so a synonym can
be recorded on the canonical table it resolves to instead of creating
a second entity.
…digests

Source hash should be stable regardless of alias list ordering, since
sys.synonyms in MSSQL provides no row ordering guarantee. This change sorts
the aliases list before hashing to ensure consistent digest generation
across ingestion runs.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…fiers

Implement split_sql_server_identifier() for bracket-aware T-SQL identifier
splitting and parse_base_object_name() to normalize synonym base_object_name
into a three-part target (database.schema.table), with handling for missing
parts (defaulting schema to 'dbo' and database to the synonym's database),
remote references, and edge cases.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add SynonymMap class to track SQL Server synonyms with bounded memory
usage and consumption tracking. Implements the following:

- MAX_SYNONYM_ENTRIES: bounded cache with 5000-entry default cap
- add(): stores aliases by target, rejects new targets beyond cap
- aliases_for(): returns sorted aliases and marks target consumed
- record_unresolved(): explicitly records unresolved synonyms
- unresolved(): reports both explicit and unconsumed targets
- is_empty(): checks if the map contains any entries

Includes 9 unit tests covering all core behaviors and edge cases:
alias sorting, deduplication, cap enforcement, consumption tracking,
and unresolved reporting. All 29 tests (20 existing + 9 new) pass.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…de effect

Finding 1 (Critical): _explicit_unresolved is now capped at max_entries to
prevent unbounded memory growth on catalogs with many malformed synonyms.
Uses a separate warn-once flag _unresolved_cap_warned to avoid silencing
target-cap warnings.

Finding 2 (Minor): aliases_for method now has a docstring documenting that
calling it marks the target consumed and signals successful ingestion. This
establishes the contract for the "call exactly once per table" expectation.

Includes new test test_unresolved_cap_bounds_explicit_entries verifying the cap
applies correctly to record_unresolved calls.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sweeps sys.synonyms across every in-scope database in MssqlSource.prepare()
(before the topology produces anything), builds a target FQN -> alias FQNs
map, and resolves each table's aliases by construction via a get_table_aliases
override. close() reports synonyms that never resolved to an ingested table.
…prepare

Adds coverage for the keystone routing logic that decides which databases
prepare() sweeps for synonyms: the ingestAllDatabases=False short-circuit,
databaseFilterPattern exclusion, prepare() wiring build_synonym_map's result
into self.synonym_map, and prepare()'s resilience path leaving a usable
empty SynonymMap (not None) when the sweep raises.
… entity

TableMapper.createToEntity never copied create.getAliases() onto the
Table it builds, so the aliases field added in the Table/CreateTable
schema (feat(spec): add source-managed aliases field to Table entity)
was silently dropped on both POST and PUT: it could never reach the
entity to be created, updated, replaced, or merged in the first place.
Discovered while writing the Task 9 integration test for the mssql
synonym-aliases design (out of that task's stated file scope, but a
blocking prerequisite for it to test anything at all).
…ly drop changes

TableUpdater.entitySpecificUpdate never registered "aliases" with
recordChange, so a PUT that changed only aliases produced no field
diff: entityChanged/versionChanged stayed false and storeUpdate()
skipped persisting the new version entirely. The PUT response still
echoed the caller's in-memory Table (with the new aliases), masking
that the database row kept the stale value — confirmed by re-fetching
the entity after the PUT in the Task 9 integration test.

Registering aliases here, alongside the other plain-field
recordChange calls, makes updateVersion() see the change and persist
it, so a PUT with a new aliases list replaces the array wholesale
(matching default List<String> semantics) instead of being ignored.
This is required for the mssql synonym design's "the connector
resends the full list every run, no diffing needed" property to hold.
Gate on the mssql synonym-aliases design assumption that a PUT
CreateTable with a full aliases list replaces the array wholesale, so
created/dropped/retargeted synonyms reconcile through plain upsert
semantics with no diffing stage. Covers initial set, retarget (old
alias gone), and clear (empty list clears aliases), re-fetching the
entity after each PUT rather than trusting the mutation response's
in-memory echo.

Running it against unpatched code (git stash the two preceding fix
commits) confirmed the assumption did NOT hold by default: aliases
never reached the entity at all (TableMapper gap), and once that was
fixed, a retarget silently failed to persist (TableUpdater gap) while
the PUT response still reported the new value. Both gaps are fixed in
the two preceding commits; default array replace semantics were not
sufficient on their own.
recordChange compares aliases with List::equals, which is order-sensitive
and does not normalize null against empty. GlossaryTerm.synonyms (also a
List<String> of alternate names) already uses recordListChange with
listOrEmpty normalization for exactly this reason; Topic.cleanupPolicies
follows the same pattern. Two concrete problems with recordChange here:

- Order churn: ["b","a"] vs ["a","b"] would record as a change, bumping
  the table's version and firing a change event on every re-ingestion
  even when the alias set is unchanged. This was only masked by
  SynonymMap.aliases_for returning a sorted list, making the server
  contract silently depend on every producer sorting.
- Null/empty asymmetry: original=null, updated=[] took the "orig == null"
  branch and recorded a fieldAdded, bumping the version for a table whose
  alias set went from nothing to nothing.

Switch to recordListChange with listOrEmpty-normalized inputs and
stringMatch, following GlossaryTermRepository.updateSynonyms exactly.
Verified via TableResourceIT#put_tableAliases_replaceNotMerge that all
three transitions (set, retarget, clear) still replace wholesale:
retarget now records added+deleted, clear records deleted, and each
correctly marks entityChanged so the new version persists.
…r value

Two fixes to put_tableAliases_replaceNotMerge from review:

- The initial-set leg only asserted on the create response (the in-memory
  echo of the request), not on a re-fetched entity, so it proved echo
  rather than persistence. A mapper that wired aliases into the create
  path but dropped them at store time would have passed this leg while
  legs 2/3 (which do re-fetch) still passed via the original=null ->
  fieldAdded path on the first PUT. Added an explicit re-fetch assertion
  so the create path is actually covered.
- The clear leg sent aliases=[] and accepted either null or empty back.
  Now that aliases uses recordListChange (previous commit), the
  persisted value is deterministic, so assert on it directly. Changed
  the leg to send aliases=null instead of aliases=[], matching what
  SynonymMap.aliases_for (ingestion/src/metadata/ingestion/source/database/mssql/synonyms.py)
  actually returns on a miss (None, not an empty list) -- this is the
  production clear path the mssql connector takes, not a hypothetical one.
Add es_search_from_alias to the ES mixin and a fallback in
search_table_entities so lineage resolves a source-managed alias
(e.g. a SQL Server synonym) to the canonical table it points at.
Generic, service-agnostic: works for any connector that populates
Table.aliases, without depending on connector-specific in-memory state.
Adds a TableAliases widget that lists a table's source-managed alternate
FQNs (e.g. SQL Server synonyms) on the table detail page. Display-only by
design: the MSSQL connector recomputes and overwrites aliases on every
run, so an edit control would silently discard user input.

Also regenerates the UI's TS types for Table/CreateTable/BulkCreateTable
from the JSON Schema to pick up the aliases field added in a prior schema
change; the previous change updated only the schema, never the generated
UI types (make update_typescript_types), leaving Table.aliases absent
from the frontend contract. Verified the regeneration touched only the
aliases addition with no unrelated churn.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Creates a table with source-managed aliases via the API, visits its
page, and asserts the display-only widget renders each alias and
offers no edit control (the connector overwrites aliases on every
ingestion run, so an editable field would silently discard input).
Also covers the negative case: a table with no aliases renders no
widget at all.
- common_db_source.py: wrap get_table_aliases() strings in
  FullyQualifiedEntityName before assigning to CreateTableRequest.aliases,
  which is invariantly typed list[FullyQualifiedEntityName] | None.
- source_hash.py: cast the result of _remove_volatile_fields to
  dict[str, Any] before the new "aliases" sort block indexes it by string
  key; narrows the same union for the pre-existing columns/tags/
  tableConstraints/owners blocks too, so their baselined errors also
  clear (baseline.json untouched -- discard mode tolerates unused entries).
- sql_lineage.py: inline-suppress the new search_cache.put(search_tuple, ...)
  call with a narrow pyright:ignore, matching the pre-existing baselined
  call a few lines above -- LRUCache.put's `key: str` annotation is too
  narrow for the tuple keys this cache actually uses everywhere.

make static-checks now reports zero errors attributable to this branch.
…us MagicMock matches

search_table_entities' Task-10 alias fallback treats any truthy return from
metadata.es_search_from_alias as a resolved alias. TestDbUtils.setUp builds a
bare MagicMock() metadata client; any test that reaches the fallback without
stubbing this call gets an unconfigured, auto-truthy MagicMock back instead of
None, which the fallback short-circuits on and returns as if it were real
Table entities -- breaking test_get_view_lineage_success_with_fallback, whose
schema-fallback scenario reaches this exact branch.

es_search_from_alias's real contract is Optional[List[Table]]; production
code has no bug here since a real client only ever returns that shape. The
gap is purely a missing test stub, so the fix is stubbing it (return None)
once in setUp, covering every test in the class the same way es_search_from_fqn
and get_by_name are already stubbed, rather than papering over it per-test.

Audited every other MagicMock-metadata test in tests/unit/lineage,
tests/unit/test_db_utils.py, and tests/unit/topology that exercises
search_table_entities/get_table_entities_from_query/get_view_lineage without
mocking the function away entirely (test_cross_database_lineage_sql.py,
test_stored_procedure_lineage.py, test_grafana.py, test_hex_lineage.py,
test_snowflake_access_history_lineage.py, test_dbtcloud.py): none reach the
alias-fallback branch today (confirmed by temporary instrumentation), so no
other test file needed a stub.
Verified against a real SQL Server 2022 instance: sys.synonyms.base_object_name
preserves the exact casing typed in CREATE SYNONYM ... FOR ..., never the
target object's actual stored casing. Under SQL Server's default
case-insensitive collation this is routine (CREATE SYNONYM dbo.o FOR
analytics_master.dbo.Orders against a table stored as "orders" is completely
normal T-SQL), but SynonymMap's dict/set lookups were case-sensitive Python
string comparisons, so the alias silently missed its target and got reported
as an unresolved synonym even though the target exists and was ingested --
defeating the feature's primary use case of cross-database synonyms.

Fix: _targets is now keyed on target_fqn.casefold() in add()/aliases_for();
_consumed stores the same folded key so a target consumed via a differently
cased lookup is correctly excluded from unresolved(). Alias FQN values are
never folded -- OpenMetadata FQNs are case-preserving, so aliases[] must keep
the source's original casing. Bounded caps and warn-once flags on both
_targets and _explicit_unresolved are untouched.

Added 3 tests to TestSynonymMap covering case-insensitive lookup in both
casing directions, original-case preservation of the returned alias, and
consumption-tracking correctness across a case mismatch; all pre-existing
exact-case tests continue to pass unmodified.
I1: the aliases field was added to the search document and to
searchSettings.allowedFields, but neither is consulted when building
the actual Explore query -- ElasticSearchSourceBuilderFactory builds
data-asset queries solely from assetTypeConfigurations[table].searchFields,
which never listed aliases. Searching an alias FQN therefore returned
zero results, contradicting the design spec's search guarantee.

Add aliases (boost 5.0, standard match, mirroring TableIndex's intended
columns.name weight) and aliases.keyword (boost 10.0, exact match, for
FQN-precise ranking) to the table searchFields, and aliases to
highlightFields so a match actually produces highlight fragments.

Also remove TableIndex.getFields()'s dead "aliases" boost entry --
getFields() has zero production callers for TableIndex, so the entry
did nothing -- and replace the vacuous test that asserted on it with
one that asserts against the settings-driven path search actually
uses.
I2: searchSettings.json is seed data merged additively on startup --
only whole missing asset types get added to an already-installed
instance's stored settings, so upgraded clusters would keep their old
table entry forever and never pick up the aliases searchField/
highlightField from the previous commit. Alias search would work on
fresh installs but stay broken on every upgrade.

Add v210.MigrationUtil.addAliasesSearchSettings(), following the
get/load/merge/save/log skeleton from v200's
backfillSearchRankingSettings() and the hand-rolled boolean-returning
merge-helper pattern from v1132/v11210's search-settings fixes.
Idempotent.

Neither mysql/v210/Migration.java nor postgres/v210/Migration.java
existed yet (2.1.0's data migration was SQL-only so far), so both are
added here to carry the call -- migration class resolution is purely
reflective on the version-derived package name.
M1: fullyQualifiedName's keyword has no ignore_above, and the schema
permits FQNs up to 3072 chars, but aliases.keyword was capped at 256 --
an alias FQN longer than that is silently dropped from the index with
no diagnostic, and es_search_from_alias can never resolve it.

SearchIndexSettings.harden() already backfills ignore_above on any
keyword field lacking one, using the dynamically computed safe char
threshold (well above 3072) -- the same mechanism fullyQualifiedName
relies on -- so removing the static cap does not leave the field
unbounded. Applied identically to all four locale mapping files.
M4: "if table_entities: return table_entities" two lines above the
alias-fallback block already guarantees table_entities is empty by the
time "if not table_entities:" is reached, so the guard was always
true. Drop it and de-indent; no behavior change.
M5: _normalize_for_hash and generate_source_hash's docstrings still
listed only columns/tags/tableConstraints/owners as sorted, but
aliases was added to the sort list when the mssql synonym feature
landed. Update both to mention it.
@github-actions github-actions Bot added Ingestion safe to test Add this label to run secure Github workflows on PRs labels Aug 20, 2026
The Playwright fixture mockEntitySearchConfig deep-equals the table config
returned by PUT /system/settings/reset/searchSettings. Adding the aliases
search fields and highlight field to searchSettings.json made that assertion
fail in all three SearchSettings specs that call restoreDefaultSearchSettings.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

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.

🔵 Needs a closer look

The v202 search-settings migration can throw on null/odd assetType entries (schema allows missing assetType) and a new UI unit test assertion is overly broad/misleading due to WidgetCard rendering buttons.

Review details

Suppressed comments (2)

Previously missed (1) — in code that hasn't changed since the last review.

openmetadata-ui/src/main/resources/ui/src/pages/TableDetailsPageV1/TableAliases/TableAliases.test.tsx:107

  • This test asserts that there are no elements at all, but the real WidgetCard renders an expand/collapse button. The test currently passes only because WidgetCard is mocked. Narrow the assertion to the widget content (the aliases table) so it verifies “no edit controls” without depending on WidgetCard internals.

openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v202/TableAliasesSearchSettingsMigration.java:81

  • findTableConfiguration compares assetType using String.equals without guarding against null. SearchSettings schema does not require assetType, so a null entry would throw a NullPointerException and skip the migration. Using equalsIgnoreCase on the constant avoids NPEs and also tolerates operator-provided case differences.
  private static AssetTypeConfiguration findTableConfiguration(SearchSettings settings) {
    AssetTypeConfiguration match = null;
    if (settings != null) {
      for (AssetTypeConfiguration config : listOrEmpty(settings.getAssetTypeConfigurations())) {
        if (TABLE_ASSET_TYPE.equals(config.getAssetType())) {
          match = config;
          break;
        }
  • Files reviewed: 46/69 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

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

There are at least two concrete UI issues likely to break lint/type-checking (useEffect deps and missing React/ReactNode import in the new Jest test).

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

openmetadata-ui/src/main/resources/ui/src/pages/TableDetailsPageV1/TableAliases/TableAliases.test.tsx:31

  • This test references React.ReactNode but doesn’t import React (or ReactNode). In this codebase tests typically import React when using the React.* namespace; without it, TS type-checking / linting can fail.
  • Files reviewed: 46/69 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment on lines +84 to +88
useEffect(() => {
if (isEmpty(aliasRows)) {
filterWidgets?.([DetailPageWidgetKeys.TABLE_ALIASES]);
}
}, [aliasRows]);

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.

🔵 Needs a closer look

It is a broad cross-layer change (schema + ingestion + lineage + search + migration + UI) that warrants a final maintainer review despite strong automated test coverage.

Review details
  • Files reviewed: 46/69 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

IceS2
IceS2 previously approved these changes Sep 3, 2026
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

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.

🔵 Needs a closer look

It’s a large cross-layer change (spec/schema, ingestion, backend persistence+migrations, search, lineage, UI) that warrants final human maintainer review of upgrade/migration semantics and system-wide compatibility.

Review details
  • Files reviewed: 46/69 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Resolve three conflicts from main's new v202 migration:

- migration/{mysql,postgres}/v202/Migration.java (add/add): main added
  repairNameKeywordSearchFields + repairAllowedFields at the same version this
  branch used for the table-aliases backfill. All three are idempotent, so run
  all three rather than picking a side.
- utils/TableTabsUtils.tsx: keep both the TableAliases lazy widget and main's
  new isDbtTabHidden / getSampleDataTabChildren / getTableQueriesTabChildren
  helpers; they don't overlap.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

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.

🔵 Needs a closer look

There are a few concrete correctness/CI-blocking issues in the newly added UI and migration logic (e.g., missing React import in the new test and a hooks dependency omission) that should be fixed before approval.

Review details

Suppressed comments (3)

openmetadata-ui/src/main/resources/ui/src/pages/TableDetailsPageV1/TableAliases/TableAliases.component.tsx:88

  • The effect uses filterWidgets but it is not included in the dependency array, which will violate the exhaustive-deps rule and can also capture a stale filterWidgets reference if the context changes.
    openmetadata-ui/src/main/resources/ui/src/pages/TableDetailsPageV1/TableAliases/TableAliases.test.tsx:14
  • This test file references React.ReactNode in the WidgetCard mock props type, but React is not imported, which can cause a TypeScript compile error (Cannot find namespace 'React').
    openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v202/TableAliasesSearchSettingsMigration.java:81
  • findTableConfiguration matches the table asset type with a case-sensitive equals. Other search-settings repairs use equalsIgnoreCase, and operator-modified settings could reasonably differ in case; using equalsIgnoreCase makes the migration more robust and avoids silently skipping the merge.
  private static AssetTypeConfiguration findTableConfiguration(SearchSettings settings) {
    AssetTypeConfiguration match = null;
    if (settings != null) {
      for (AssetTypeConfiguration config : listOrEmpty(settings.getAssetTypeConfigurations())) {
        if (TABLE_ASSET_TYPE.equals(config.getAssetType())) {
          match = config;
          break;
        }
  • Files reviewed: 46/65 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Adding the TABLE_ALIASES case pushed the getWidgetHeight switch to a
cyclomatic complexity of 11, over the sonarjs limit of 10. Replace the
switch with a lookup against an explicit list of the keys it handled, so
widgets absent from that list still fall back to height 1 (notably
CUSTOM_PROPERTIES and KNOWLEDGE_ARTICLE, which have entries in
defaultWidgetHeight but were never cased). Add TableClassBase.test.ts to
pin that behaviour; it passes against both the old switch and the lookup.

This also clears the Licence Header check, which only failed because
`yarn lint:base --fix` aborted on the ESLint error before the lint step
could revert organize-imports' writes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@gitar-bot

gitar-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown
Code Review 👍 Approved with suggestions 3 resolved / 4 findings

Ingests SQL Server synonyms as embedded aliases on canonical tables, enabling lineage resolution through synonym references and cross-database table discovery. The implementation uses an opt-in includeSynonyms flag, resolves aliases by construction during prepare, and reconciles through standard upsert semantics.

Consider improving the Aliases widget to disambiguate entries with identical trailing names (e.g., orders from different databases) — currently they display indistinguishably in the table, distinguishable only via hover tooltip.

💡 Edge Case: Aliases with same trailing name render as indistinguishable rows

📄 openmetadata-ui/src/main/resources/ui/src/pages/TableDetailsPageV1/TableAliases/TableAliases.component.tsx:41-49 📄 openmetadata-ui/src/main/resources/ui/src/pages/TableDetailsPageV1/TableAliases/TableAliases.component.tsx:59-67 📄 openmetadata-ui/src/main/resources/ui/src/pages/TableDetailsPageV1/TableAliases/TableAliases.component.tsx:76-78

getAliasName reduces each alias FQN to its trailing name only, so two synonyms differing solely in service/database/schema (e.g. svc.db1.dbo.orders and svc.db2.dbo.orders) both display as orders with no visible distinction in the widget — they are only distinguishable via the hover title. This is a display-only issue (row keys stay unique via the full FQN, so there is no React key collision), but the table becomes ambiguous for cross-database synonym sets. Consider showing a fuller path when trailing names collide, or displaying schema.name.

✅ 3 resolved
✅ Performance: Alias fallback adds an ES query to every failed lineage lookup

📄 ingestion/src/metadata/ingestion/lineage/sql_lineage.py:250-264
In search_table_entities, when the canonical FQN lookup misses, the code caches an empty list (line 251) and then always issues a second ES call (es_search_from_alias). Because the negative cache is only honored when truthy (if result: return result at lines 217-220), an empty cached entry falls through and re-runs BOTH es_search_from_fqn and the new alias query on every repeated reference to a genuinely-unresolvable table (temp tables, CTEs, un-ingested targets) during lineage parsing. This roughly doubles ES traffic for missing-table lookups. Consider short-circuiting the alias query when the built alias_fqn equals the already-searched canonical FQN's intent, or caching the None result so repeated misses don't re-query.

✅ Quality: includeSynonyms defaults to true, silently enabling sweep on upgrade

📄 openmetadata-spec/src/main/resources/json/schema/entity/services/connections/database/mssqlConnection.json:91-96 📄 ingestion/src/metadata/ingestion/source/database/mssql/metadata.py:302-305
The new includeSynonyms field defaults to true, so every existing MSSQL service picks it up on upgrade with no user action: prepare() will run one sys.synonyms catalog query per in-scope database (N queries when ingestAllDatabases is on) and lineage runs gain a per-unresolved-name ES alias lookup. This contradicts the code's stated 'connectors must not pay for it unless they opt in' framing (the PR itself notes the resulting one-time sourceHash recompute for every table). If opt-in is the intended semantics, set the schema default to false; if on-by-default is deliberate, this is acceptable but worth confirming the added upgrade-time load is intended.

✅ Bug: Alias backfill moved to v1135 will be skipped on 2.x upgrades

📄 openmetadata-service/src/main/java/org/openmetadata/service/migration/mysql/v1135/Migration.java:23-30 📄 openmetadata-service/src/main/java/org/openmetadata/service/migration/postgres/v1135/Migration.java:23-30
Native migrations are version-gated: MigrationWorkflow filters out any migration whose version is already recorded in SERVER_CHANGE_LOG (MigrationWorkflow.resolveApplyMigrations / getMigrationsToApply). The project on main is 2.0.0-SNAPSHOT and migration packages v200/v201/v210 already exist, so existing deployments have long since recorded the 1.13.5 (v1135) migration as applied. Adding addAliasesSearchSettings() to the v1135 Migration.runDataMigration means it will NOT re-run on any instance already upgraded past 1.13.5 — the whole v1135 version is skipped — so the aliases/aliases.keyword searchFields and highlightField are never backfilled and alias search silently returns zero results, which is exactly what this migration exists to prevent. Placing it in the newest unreleased version package (e.g. v210 as before, or wherever the current dev head points) is what guarantees it runs on the next upgrade. Only move it to v1135 if this is a deliberate backport to the 1.13.5 release line and a matching entry is also present in the current dev-version package.

🤖 Prompt for agents
Code Review: Ingests SQL Server synonyms as embedded aliases on canonical tables, enabling lineage resolution through synonym references and cross-database table discovery. The implementation uses an opt-in `includeSynonyms` flag, resolves aliases by construction during prepare, and reconciles through standard upsert semantics.
  
  Consider improving the Aliases widget to disambiguate entries with identical trailing names (e.g., `orders` from different databases) — currently they display indistinguishably in the table, distinguishable only via hover tooltip.

1. 💡 Edge Case: Aliases with same trailing name render as indistinguishable rows
   Files: openmetadata-ui/src/main/resources/ui/src/pages/TableDetailsPageV1/TableAliases/TableAliases.component.tsx:41-49, openmetadata-ui/src/main/resources/ui/src/pages/TableDetailsPageV1/TableAliases/TableAliases.component.tsx:59-67, openmetadata-ui/src/main/resources/ui/src/pages/TableDetailsPageV1/TableAliases/TableAliases.component.tsx:76-78

   getAliasName reduces each alias FQN to its trailing name only, so two synonyms differing solely in service/database/schema (e.g. `svc.db1.dbo.orders` and `svc.db2.dbo.orders`) both display as `orders` with no visible distinction in the widget — they are only distinguishable via the hover `title`. This is a display-only issue (row keys stay unique via the full FQN, so there is no React key collision), but the table becomes ambiguous for cross-database synonym sets. Consider showing a fuller path when trailing names collide, or displaying schema.name.

Options

Display: compact → Showing less information.

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

@sonarqubecloud

sonarqubecloud Bot commented Sep 8, 2026

Copy link
Copy Markdown

@sonarqubecloud

sonarqubecloud Bot commented Sep 8, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-09-09T00:52:33Z)

Blocked the queue: playwright-summary

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ingestion safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MSSQL Connector Support for SQL Server Synonyms

4 participants