Skip to content

Fixes 33374: allow Table.aliases through the entity patch - #33375

Merged
ulixius9 merged 1 commit into
mainfrom
fix/table-aliases-patch-allowlist
Sep 16, 2026
Merged

ulixius9 merged 1 commit into
mainfrom
fix/table-aliases-patch-allowlist

Conversation

@ulixius9

@ulixius9 ulixius9 commented Sep 16, 2026 •

Copy link
Copy Markdown
Member

Describe your changes:

Fixes #33374

Table.aliases was silently dropped on every table that already exists in OpenMetadata, so SQL Server synonyms (includeSynonyms, #31512) only ever landed on tables created for the very first time.

When an entity already exists, TopologyRunnerMixin.yield_and_update_context emits a PatchRequest rather than a create, and sink/metadata_rest.py::patch_entity builds that patch with allowed_fields=ALLOWED_COMMON_PATCH_FIELDS. build_patch diffs both models through model_dump_json(include=allowed_fields), so a field missing from that dict can never produce an operation. aliases was missing: the connector discovered the synonyms, put them on the create request, and the patch threw them away — with no error and a 100% success run.

This adds "aliases": True to the allow-list. It is deliberately not added to RESTRICT_UPDATE_LIST: aliases are source-managed and have to be replaceable and removable when a synonym is dropped at the source.

Type of change:

  • Bug fix

Tests

BuildPatchTableAliasesTest in ingestion/tests/unit/metadata/ingestion/models/test_patch_request.py drives build_patch through the exact argument set the sink uses (ALLOWED_COMMON_PATCH_FIELDS + RESTRICT_UPDATE_LIST + ARRAY_ENTITY_FIELDS) and covers first alias added, further alias appended, alias removed, and unchanged aliases. Four of the five fail without the one-line change:

$ pytest ingestion/tests/unit/metadata/ingestion/models/test_patch_request.py -q
# without the fix
4 failed, 16 passed
# with the fix
20 passed

Also verified end-to-end against a 1.13.6 server with the released openmetadata-ingestion==1.13.6.0 agent and a real SQL Server 2022 with synonyms, holding overrideMetadata constant so the allow-list is the only variable:

agent overrideMetadata new synonym at source result
stock 1.13.6.0 true dbo.prod_catalog_legacy alias not written
1.13.6.0 + this change true same alias written, entity v0.1 → v0.2, resolvable via aliases.keyword search

Notes for the release

sourceHash is in the allow-list, so a run on the broken build still advances the stored hash and the connector subsequently reports "no changes detected" and skips the table. Upgrading the agent alone therefore does not backfill existing tables — one run with Override Metadata enabled is needed after this ships.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is of the format Fixes <issue-number>: <short description>.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
Greptile Summary

This PR allows source-managed Table.aliases values to pass through the ingestion entity-patch allow-list.

  • Supports adding, extending, removing, and retaining table aliases on existing entities.
  • Adds focused tests using the same patch configuration as the metadata REST sink.
  • The changes since the previous review simplify the tests without changing their coverage.
Confidence Score: 5/5

The PR appears safe to merge, with no actionable correctness, security, or repository-rule issues identified.

The allow-list change directly enables the intended alias patch operations, and the tests cover the relevant state transitions; no outstanding or newly introduced failure remains.

Important Files Changed
Filename Overview
ingestion/src/metadata/ingestion/models/patch_request.py Adds aliases to the common patch-field allow-list so connectors can synchronize table aliases.
ingestion/tests/unit/metadata/ingestion/models/test_patch_request.py Verifies alias additions, removals, extensions, and unchanged values through the sink-equivalent patch configuration.

Reviews (2): Last reviewed commit: "Fixes 33374: allow Table.aliases through..." | Re-trigger Greptile

@ulixius9
ulixius9 requested a review from a team as a code owner September 16, 2026 05:45
@ulixius9
ulixius9 requested review from TeddyCr and a lite review from Copilot September 16, 2026 05:45

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.

@github-actions

github-actions Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

Aliases are recomputed from the source on every run, but every table that
already exists in OpenMetadata is updated through a PatchRequest, and
build_patch diffs both models through `include=allowed_fields`. With
`aliases` missing from the allow-list the field could never produce an
operation, so SQL Server synonyms only ever landed on tables created for
the first time - silently, with no error and a 100% success run.
@ulixius9
ulixius9 force-pushed the fix/table-aliases-patch-allowlist branch from 49adffb to 9ecc89b Compare September 16, 2026 06:22
Copilot AI review requested due to automatic review settings September 16, 2026 06:22

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 16, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

Fixes table aliases being silently dropped during entity patches by adding aliases to the ALLOWED_COMMON_PATCH_FIELDS allow-list. This enables SQL Server synonyms and other source-managed aliases to persist on existing tables, not just new ones. Comprehensive unit tests and end-to-end validation confirm the fix works correctly.

Review coverage

Rules No rules evaluated

Functional validation Not enabled · Set up

Auto-approval Not enabled · Set up

Options

Display: compact → Counting what did not apply, without listing it.

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

@github-actions

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit 9ecc89b8b356b1c11d05844d07c1e146c1c330e0 in Playwright run 35063458554, attempt 1.

✅ 109 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky

Performance

Blocking 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) 40m 52s

⏱️ Max setup 4m 23s · max shard execution 12m 41s · max shard-job elapsed before upload 17m 34s · reporting 4s

🌐 238.74 requests/attempt · 1.77 app boots/UI scenario · 0.00% common-shard skew

Optimization targets still in progress:

  • Browser traffic was 238.74 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 1.77 per UI scenario (213 boots / 120 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 46 0 0 0 0 0
✅ Shard ingestion-01 29 0 0 0 0 0
✅ Shard ingestion-02 34 0 0 0 0 0

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

@sonarqubecloud

Copy link
Copy Markdown

@ulixius9
ulixius9 added this pull request to the merge queue Sep 16, 2026
Merged via the queue into main with commit c4fce13 Sep 16, 2026
116 of 118 checks passed
@ulixius9
ulixius9 deleted the fix/table-aliases-patch-allowlist branch September 16, 2026 08:21
ulixius9 added a commit that referenced this pull request Sep 30, 2026
…the Data Insights chart rescope, both on 2.0.3 (#33415)

* Fixes 31512: Ingest SQL Server synonyms as Table.aliases (#31829)

* feat(spec): add source-managed aliases field to Table entity

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.

* fix(ingestion): sort aliases in source hash normalization for stable 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>

* feat(mssql): add sys.synonyms query and synonym result models

* feat(mssql): parse and normalize sys.synonyms base_object_name identifiers

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>

* feat(mssql): add bounded synonym map with consumption tracking

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>

* style(ingestion): apply ruff formatting to alias test files

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

* fix(mssql): bound unresolved synonym list and document aliases_for side 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>

* feat(ingestion): add get_table_aliases hook to the shared table producer

* fix(ingestion): remove connector-specific vocabulary from get_table_aliases docstring and add wiring test

* feat(mssql): discover synonyms up front and attach them as table aliases

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.

* test(mssql): cover synonym-sweep routing in _in_scope_database_names/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.

* feat(search): index table aliases for exact and partial matching

* fix(service): wire CreateTable.aliases through to the persisted Table 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).

* fix(service): replace table aliases wholesale on update, don't silently 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.

* test(service): assert table aliases are replaced wholesale across runs

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.

* fix(service): use recordListChange for table aliases, not recordChange

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.

* test(service): assert aliases persistence on create, and pin the clear 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.

* feat(lineage): resolve alias FQNs to their canonical table

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.

* feat(ui): show read-only table aliases on the table detail page

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>

* test(ui): add Playwright coverage for the table aliases widget

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.

* fix(mssql): resolve 3 basedpyright errors from the alias feature

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

* fix(lineage): stub es_search_from_alias in TestDbUtils to prevent bogus 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.

* fix(mssql): case-fold SynonymMap's lookup key, not the stored alias FQN

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.

* fix(search): wire aliases into the table query and drop the dead boost

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.

* fix(migration): backfill the aliases search settings on upgrade

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.

* fix(search): drop ignore_above 256 on aliases.keyword in index mappings

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.

* refactor(lineage): remove tautological guard in search_table_entities

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.

* docs(ingestion): fix stale source_hash docstrings after aliases sort

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.

* feat(ui): show the alias name instead of the full FQN in the Aliases widget

The service, database and schema are already established by the table page
the widget sits on, so only the trailing name carries new information. The
full FQN stays available as the cell's title attribute.

Also drops the direct antd/lib/table import that tw-guard rejects for new
files, deriving the column type from the shared Table wrapper's own props.

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

* feat(mssql): gate synonym ingestion and alias lineage resolution behind includeSynonyms

The alias fallback in search_table_entities fired for every connector's
lineage resolution, costing an extra exact-match search per unresolved
table name even for sources that can never produce aliases.

Adds includeSynonyms to the MSSQL connection. It gates both halves:
prepare() skips the sys.synonyms sweep entirely when disabled, and the
lineage resolver consults aliases only for services that opt in.

The resolver reads the opt-in by field name rather than by service type,
so a connector adding the same field (Oracle synonyms) participates
without this service-agnostic module learning connector names. The
per-service result is cached in a bounded LRU, so an opted-out service
costs one lookup per run rather than one per unresolved name.

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

* refactor(migration): move the table aliases search-settings backfill from v210 to v1135

The backfill ships with 1.13.5, not 2.1.0, so it belongs on that release
train. Extracted out of v210.MigrationUtil into its own
v1135.TableAliasesSearchSettingsMigration, matching the one-class-per-concern
shape the rest of v1135 uses, and v210 is back to exactly what main has.

* feat(mssql): make includeSynonyms opt-in

Synonym discovery costs an extra sys.synonyms query per in-scope database and
turns on an extra exact-match search per unresolved name during lineage, so
every MSSQL service paid for it on upgrade whether or not it has synonyms.
Default to false and let the operator turn it on.

The gate already treated an absent field as off (service_resolves_aliases
reads it with getattr(..., False)), so this only changes what a service that
never set the toggle gets.

* Update generated TypeScript types and dereferenced schemas

* refactor(migration): move the table aliases search-settings backfill to a new v202

v1135 was the wrong home: MigrationWorkflow drops an already-recorded version
from the apply list unless it is the max recorded one, and reprocessing only
runs runDataMigration when the version equals that max. Any instance carrying
1.13.5 alongside something newer would therefore never backfill the aliases
searchFields, and alias search would keep returning nothing.

2.0.2 is a fresh version no deployment has recorded, so it is picked up exactly
once on the next upgrade whatever train the instance is on -- an unrecorded
version is applied regardless of its ordering against the recorded max.

Adds the native 2.0.2 SQL directories for both engines (empty, like 2.0.1 --
this is a data migration only) and MigrationWiringTest, because a mismatch
between the directory name and the Java package silently resolves to the
default no-op migration class with no error.

* Fix UI checkstyle

Prettier collapses the ALIAS_NAMES array onto one line. The playwright lint
step is new to this branch -- it arrived with #31994 in the merge from main, so
this spec had never been format-gated.

* Fix Python checkstyle

py_format_check gained a suppressions ratchet in the merge (#31643, the same
commit as the typing modernization). It rejects two things this branch had:
five f-string logging calls not in the G004 baseline, and two '# noqa: UP045'
suppressions -- the ratchet forbids suppressing the codes it enforces rather
than fixing them.

Converted the logging to lazy %-style and the annotations to 'X | None', which
made the typing import in synonyms.py unused. The G004 baseline is untouched:
its fingerprints are content-based, so the pre-existing debt in sql_lineage.py
and mssql/metadata.py still matches.

* test(ui): add table aliases to the default search settings fixture

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>

* Fix UI checkstyle: reduce getWidgetHeight complexity in TableClassBase

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>

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Shailesh Parmar <shailesh.parmar.webdev@gmail.com>
(cherry picked from commit ab788cf)

* Fixes 33374: allow Table.aliases through the entity patch (#33375)

Aliases are recomputed from the source on every run, but every table that
already exists in OpenMetadata is updated through a PatchRequest, and
build_patch diffs both models through `include=allowed_fields`. With
`aliases` missing from the allow-list the field could never produce an
operation, so SQL Server synonyms only ever landed on tables created for
the first time - silently, with no error and a 100% success run.

(cherry picked from commit c4fce13)

* refactor(migration): move the table aliases search-settings backfill to 2.0.3

2.0.2 is already released, and MigrationWorkflow selects versions by exact
set membership against SERVER_CHANGE_LOG: a cluster that has already recorded
2.0.2 never re-applies it, so a data migration retro-fitted into that slot
never runs and alias search keeps returning nothing on exactly the upgraded
instances it was written for.

2.0.3 is unrecorded everywhere, so it is picked up exactly once on the next
upgrade. v202 keeps its own two search-settings repairs, which shipped with
2.0.2 and are out of scope here.

Adds the native 2.0.3 SQL directories for both engines (empty, like 2.0.1 --
this is a data migration only) and a MigrationWiringTest for 2.0.3, because a
mismatch between the directory name and the Java package silently resolves to
the default no-op migration class with no error.

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

* chore(playwright): auto-refresh impact-map.generated.json [skip ci]

* Fixes 31478: stop Data Insights summary cards counting test case results (#31759)

* fix(data-insights): exclude data-quality docs from data-asset totals

The di-data-assets-* pattern the charts read also resolves the data-quality
aliases (di-data-assets-testcaseresult, -testcaseresolutionstatus) that #29963
attached to the live test case indices. TestCaseResult and
TestCaseResolutionStatus are EntityTimeSeriesInterface, not EntityInterface, so
SearchIndex.populateCommonFields never runs for them and their documents carry
no entityType.

That split the two "total data assets" charts. total_data_assets groups with a
terms aggregation on entityType.keyword, which puts a document missing the field
in no bucket, so those documents vanished. total_data_assets_summary_card
filtered with a list of bool.must_not.term clauses on the same field, every one
of which a document lacking it satisfies, so they were counted. The card ran
ahead of the breakdown beneath it by exactly the number of test case results in
the window, and the same inflated denominator depressed the description, owner
and tier percentages.

Give the charts one definition of a data asset in
DataInsightSystemChartRepository: DATA_ASSET_FILTER now requires
exists(entityType) alongside the exclusions, and NON_DATA_ASSET_ENTITY_TYPES
feeds both the filter and the breakdown's excludeGroups so the two cannot drift
again. That also closes a second gap in the opposite direction, where the filter
excluded dataProduct but excludeGroups did not.

The 1.13.4 migration re-applies the scope to the fourteen stored charts,
rewriting only the filter and excludeGroups so anything else in a stored
definition survives.

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

* fix(data-insights): move the chart scope migration to 1.13.5

1.13.4 is frozen: #31386 deliberately made main's copy byte-identical to the
1.13 branch, and any deployment that already ran it under a 2.0.0-rc build would
skip a data migration added there, because shouldRunDataMigration only re-runs a
reprocessed version when it equals the current max.

A new 1.13.5 directory has been executed by nobody, so processNativeMigrations
applies it to every deployment regardless of it sorting below the current max
version. The SQL files are empty because the change is pure data migration,
matching the existing 0-byte 1.13.3 schemaChanges.sql.

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

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: IceS2 <pablo.takara@getcollate.io>
(cherry picked from commit 1b5914c)

* Fixes #31478: re-scope the Data Insights data asset charts in 1.13.6 SQL (#33049)

PR #31759 rewrote the stored chart definitions from a Java data migration hung
off 1.13.5. 1.13.5-release had already shipped and been recorded by then, and
MigrationWorkflow never reaches runDataMigration() for a recorded version once
it is no longer the release train's highest: processNativeMigrations drops it
outright, and even while it is the highest, filterAndGetMigrationsToRun skips a
reprocessing version whose SQL has all run. So no deployment ran it, and
release-1-13 still serves the pre-fix definitions — its breakdown shows a Data
Products bucket the migrated excludeGroups excludes, and the summary card sits
28 above the sum of the buckets.

Express the repair as SQL in 1.13.6 instead. runSchemaChanges and
runPostDDLChanges are not behind shouldRunDataMigration, and parseSQLFiles keeps
any statement whose checksum is absent from SERVER_MIGRATION_SQL_LOGS, so new
SQL in the train's highest version runs even where that version is already
recorded. That covers all three states: release-1-13 (1.13.6 recorded,
reprocessed), a customer whose max is 1.13.5 (1.13.6 fresh), and 2.x on main
(1.13.6 fresh). Both statements are guarded on the stored value, so a deployment
that already holds the corrected definitions is untouched.

The 1.13.5 Java migration and DataInsightChartMigration are removed;
DataInsightSystemChartRepository keeps DATA_ASSET_FILTER and
NON_DATA_ASSET_ENTITY_TYPES as the scope the aggregators and the OpenSearch
regression test read, and the SQL is pinned to them by test. Its SearchClient
moved out of a static initializer, which made the class NPE before the
application is up — that is also why the old migration's unit test only passed
when co-run with the OpenSearch test that installs a SearchRepository.

Verified end to end against the engine versions OpenMetadata ships (mysql:8.0.46
and postgres:15.19), on the 1.5.0 table DDL seeded with pre-fix definitions as
1.5.0/1.6.0 leave them. Both engines report identical row counts — 5 filter
rewrites and 2 breakdown rewrites, then 0 and 0 on a second run — and converge
on identical JSON, with filter stored as a JSON string and excludeGroups as an
array:
- the breakdown gains the filter and drops dataProduct; the cards' stale
  must_not filter is replaced; a chart grouped on tier.keyword gets the filter
  but is not given entity-type excludeGroups
- an already-migrated definition, and a user's own chart grouped on
  entityType.keyword, are both left byte-identical
- a definition with two metrics is skipped by the JSON_LENGTH/jsonb_array_length
  guard rather than half-rewritten

The rollout claim was also driven through the real MigrationWorkflow against a
real MySQL and the real bootstrap/sql/migrations tree: with 1.13.6 recorded in
SERVER_CHANGE_LOG it is still offered, and once its two statement checksums are
in SERVER_MIGRATION_SQL_LOGS it drops out — so the repair reaches an
already-upgraded deployment exactly once.

Tests:
- DataAssetChartScopeSqlMigrationTest: the SQL embeds DATA_ASSET_FILTER and the
  excludeGroups verbatim, both dialects scope the same 14 charts, every UPDATE is
  guarded, each file parses into exactly 2 statements through the same Flyway
  dialect parser the workflow uses, and the post-migration JSON captured from the
  real database deserializes into LineChart/SummaryCard with the scope applied.
- MigrationWorkflowReprocessingTest: the 1.13.4/1.13.5/1.13.6 rollout the Java
  migration was lost to, and that new SQL on the highest recorded version is what
  brings a version back.
- DataAssetChartScopeTest (real OpenSearch node): summary card equals the
  breakdown sum.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
(cherry picked from commit c489498)

* refactor(migration): carry the #31478 Data Insights chart rescope in the 2.0.3 slot

On main the re-scope ships as SQL under bootstrap/sql/migrations/native/1.13.6,
which is the right slot for the 1.13 train but unreachable on this one.
MigrationWorkflow selects versions by exact set membership against
SERVER_CHANGE_LOG and drops an already-recorded version unless it is the
recorded maximum. On a 2.0.x deployment a 1.13.6 directory is therefore either
already recorded (upgraded from the 1.13 train, where it was the max) or is no
longer the max because 2.0.x sits above it -- in both cases the statements are
never offered, and the summary cards keep out-counting the breakdown beneath
them.

2.0.3 is unrecorded everywhere on this train, so the statements are applied
exactly once on the next upgrade. Both UPDATEs are guarded on the stored value,
so a deployment that already picked the fix up on 1.13.6 before upgrading is
left untouched.

- bootstrap/sql/migrations/native/{1.13.5,1.13.6}/ dropped -- 2.0's native
  directories stop at 1.13.4, and nothing references them now that #33049's
  revert removed the v1135 Java classes.
- The SQL moves verbatim into the 2.0.3 postDataMigrationSQLScript.sql that the
  table-aliases commit already created (its header note is rewritten for this
  train); the v203 Java data migration and this SQL share the slot without
  interacting.
- DataAssetChartScopeSqlMigrationTest moves to the v203 package and reads the
  2.0.3 path, with its fixtures under test/resources/migration/v203.
  migrationParsesWithTheDialectParser now drives the real MigrationFile
  instance API, because 2.0 has no static MigrationFile.parseSQLFile -- which
  exercises the same parse path the workflow takes rather than a helper.

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

* test: fix 2.0.3 unit tests after merging 2.0

Declare om:aliases in the RDF ontology for the new Table.aliases field, and
scope DataAssetChartScopeSqlMigrationTest to di_chart_entity statements now
that 2.0.3 postDataMigrationSQLScript.sql also carries the RdfIndexApp updates.

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Shailesh Parmar <shailesh.parmar.webdev@gmail.com>
Co-authored-by: IceS2 <pablo.takara@getcollate.io>
Co-authored-by: Anujkumar Yadav <anujf0510@gmail.com>

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 synonyms: Table.aliases is dropped on every table that already exists in OpenMetadata

3 participants