Skip to content

fix(glue): ingest AWS Glue table parameters as custom properties - #33333

Merged
harshsoni2024 merged 10 commits into
mainfrom
issue-31467-glue-custom-properties
Sep 18, 2026
Merged

harshsoni2024 merged 10 commits into
mainfrom
issue-31467-glue-custom-properties

Conversation

@harshsoni2024

@harshsoni2024 harshsoni2024 commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes #31467

Custom Properties ingestion existed for Athena/Iceberg but not for AWS Glue. This adds it and extracts the shared machinery so both connectors run one implementation.

Two gaps, and the second is the one that mattered:

  1. GlueSource extends DatabaseServiceSource, not CommonDbSourceService, so it inherited neither the get_table_extensions hook nor the extension= wiring, and never set extension.
  2. GlueTable.Parameters was typed as a closed model whose only field is table_type, so Pydantic silently dropped every other key at validation. Wiring extension= alone would have ingested nothing.

Scope: Table.Parameters only, all Glue table types, tables only. Python-ingestion only — includeCustomProperties already exists on databaseServiceMetadataPipeline.json, so no schema, UI, Java, or make generate change.

Manual testing

Screenshot 2026-09-17 at 10 07 40 PM

Run against a real AWS Glue catalog and a local server. Every generated property name matched the digest computed offline from the source before the run, so naming is deterministic against a live server and not just in unit tests.

Glue parameter key Resulting property Shows
owner_team, skip.header.line.count, retention-days unchanged valid names are never rewritten — no suffix, no migration
data/owner data__owner_3338169d the collision pair: before this PR both collapsed
data@owner data__owner_2fbae9ed to data__owner and one value was lost
_internal_flag p__internal_flag_413ad214 leading-char prefix the server would otherwise reject
cost:center, has space cost__center_5e777b40, has__space_53f8a8e7 invalid-char rewrite
200-char key of / 2a1d844d1cfe49248e52dc899a85c8e7 over-length fallback to the raw-key digest
empty_value: "" none empty values register no definition
retention skipped a seeded integer retention survived untouched, and the table's extension has no retention key
owner_team on a 2nd table reused one definition, two values — no second PUT

Upgrade continuity was tested separately, since a fresh install cannot reach that path. Hand-creating data__owner (no digest, displayName='data/owner') to stand in for a definition left by an earlier release, then re-ingesting:

data__owner            = 'team-alpha'   ← legacy definition reused, no duplicate
data__owner_2fbae9ed   = 'team-beta'    ← colliding key declined it, kept its own name
(no data__owner_3338169d)

The middle line is the point: the legacy lookup is keyed on the exact raw source key via displayName, so an upgrade keeps writing where it already wrote without swallowing a second key that shares a base name.

Type of change:

  • New feature
  • Bug fix

High-level design:

New CustomPropertyExtensionMixin holds the resolve → register → dedupe → value-filter loop that was inline in AthenaSource. Each connector supplies only its property source: Athena _fetch_iceberg_properties() (still Iceberg-gated), Glue table.Parameters.model_dump() (no table-type gate — every Glue table carries Parameters). Modelled on life_cycle_query_mixin.py, not the ABC in external_table_lineage_mixin.py, which only passes basedpyright via grandfathered baseline entries a new file wouldn't get.

TableParameters gets ConfigDict(extra="allow") — one line, deliberately not a retype to dict[str, str], so .table_type stays a declared field and both production call sites and every existing test keep working.

Latent defects found while extracting the Athena logic, all fixed:

  • Values were not coerced to str. The server validates each value against the registered string schema and rejects the whole entity. Athena was immune only because its fetch already did str(...); extra="allow" does not coerce, so Glue would have hit this.
  • The string type ref was fetched unconditionally, even with the feature off.
  • The sanitizer could emit names the server rejects — customPropertyName requires an alphanumeric first character, and EntityName carries no pattern to catch it client-side, so the property was silently dropped.

Naming and definition safety

Review surfaced several ways this could lose data or damage unrelated tables. All are fixed at the mechanism level rather than warned about after the fact.

  • Collision-free names. Sanitizing is many-to-one (a/b and a@b both reduce to a__b), so one key's value was lost and the definition's displayName described the wrong key. Any rewritten name now carries an 8-hex digest of the raw key alone — never of iteration order or cache state, either of which would make the winner differ between runs. Names already valid are untouched.
  • Continuity for pre-digest names. An existing string definition whose displayName is that exact raw key keeps being used, so upgrades orphan nothing and create no duplicate.
  • Never retyping an existing definition. Definitions are global to the entity type, so registering over an existing integer retention would invalidate every other table's values. Incompatible → skip with a warning; compatible string → reuse with no PUT, so a curated displayName/description survives; unclaimed → create.
  • Fail closed on an unreadable listing. Treating it as empty would make every name look unclaimed and re-introduce exactly that corruption from nothing worse than a timeout.
  • Bounded caches. The registration cache was an unbounded set[str]; it and the definition snapshots are now the house LRUCache.
  • Scoped and shared caches. Processed names are keyed by entity type, since a definition registered for Table says nothing about another type and emitting an undefined property fails the whole entity. The definitions fetch sits behind a double-checked lock, so concurrent Athena schema workers share one snapshot instead of the last writer discarding the others' registrations.

Concurrency. Athena sets threads=True on databaseSchema and table is its child, so the caches are genuinely shared. That surfaced one bug: LRUCache.get() raises KeyError, so a concurrent eviction between the membership check and the collision-log read would fail the table. The per-property check-register-cache sequence stays non-atomic on purpose — both racing PUTs send a payload derived only from the source key, so they write identical content, and the snapshot write closes the window for every table after them.

Alternatives rejected: retyping Parameters to dict[str, str]; reading table_data off the topology context (untyped, and a second context read); suffixing only on a detected collision (the only in-run record is a bounded LRU that evicts, so the same key could sanitize differently between runs — permanent drift instead of a one-time rename).

Behaviour change for existing Athena services

A source key containing characters outside [A-Za-z0-9_.-] resolves to a different property name than before. The legacy lookup covers the normal upgrade, verified above. It does not cover two cases, each producing a new definition alongside the old one: the existing displayName was edited away from the raw key, or the definition is not of type string. Clean keys (write.format.default) are unaffected — they were never rewritten. Glue is unaffected entirely, since Glue custom properties never worked before this PR.

Tests:

Use cases covered

  • Glue Parameters appear as Custom Properties with a matching Table definition, for Regular/External/View/Iceberg.
  • Disabled by default: no definitions, no extension, and the server is never called.
  • Invalid keys are sanitized, registered, and keep the raw key as displayName; two keys sharing a base both survive with distinct definitions.
  • A key already registered under the pre-disambiguation name keeps writing to it.
  • An existing definition of another type is never replaced; unreadable definitions skip the extension; a failed registration drops that property rather than the table.
  • Athena's Iceberg behaviour is unchanged apart from the naming change above.

Unit tests

  • I added unit tests for the new/changed logic.
File Tests
tests/unit/topology/database/test_custom_property_extension_mixin.py (new) 66
tests/unit/topology/database/test_glue.py 21 → 46
tests/unit/topology/database/test_athena.py 49 → 56

Covers the bounded and scoped caches, concurrency (ThreadPoolExecutor, plus deterministic regressions for eviction between check and read, and for shared snapshot initialisation — these slow the listing on purpose, because with an instant mock the first worker finishes before the others look and the race never happens), the sanitizer table, collisions in both directions, legacy-name reuse, definition-type safety, and fail-closed listing. test_table_page_round_trips_parameters pins the root cause: it fails on main.

Result on tests/unit/topology/database/: 1799 passed, 0 failed, 6 skipped, against 1701 passed, 0 failed, 6 skipped at the merge base — +98, exactly the number added above. make py_format_check passes. make static-checks (basedpyright, --baselinemode=discard): 24 errors repo-wide, none in any file this PR touches.

Backend / ingestion integration / Playwright

  • Not applicable — no backend API or UI changes, and the repo has no Glue integration or CLI-E2E suite (matching how the Athena feature shipped).

Known limitation (pre-existing, not introduced here)

Connector-supplied extension lands on an entity's first write only. EntityRepository.updateExtension reverts any bot-supplied extension on a PUT:

if (updatedByBot() && operation == Operation.PUT) {
  updated.setExtension(origExtension);
  return;
}

Ingestion authenticates as ingestion-bot and the table bulk path uses Operation.PUT. overrideMetadata is honoured elsewhere in EntityRepository but never read here, so a changed or new Glue parameter does not propagate on re-ingestion either way. Re-running against an already-ingested service therefore shows nothing and looks exactly like the feature is broken — test against a fresh service. Athena has behaved this way since it shipped, so this PR is at parity. Filed separately as #33324.

UI screen recording / screenshots:

Not applicable.

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: not needed — no schema change and no migration.
  • For UI changes: not applicable.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • I have added a test that covers the exact scenario we are fixing.
  • For connector/ingestion changes: no docs update — no documentation page mentions includeCustomProperties (not even for Athena), and the ingestion form label comes from the schema's title.

🤖 Generated with Claude Code

RetriggerConfidence Score: 5/5

The PR appears safe to merge; no actionable new issue remains, and all previous findings are resolved.

Summary

The PR adds AWS Glue table parameters to table custom-property extensions and extracts Athena’s existing registration logic into a shared mixin.

  • Preserves arbitrary Glue parameter keys through Pydantic validation.
  • Registers compatible string properties while protecting existing definitions.
  • Uses deterministic, collision-resistant property names with Athena upgrade continuity.
  • Adds bounded, entity-scoped caches and synchronizes initial definition loading.
  • Adds extensive Glue, Athena, naming, compatibility, and concurrency tests.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
    A[Glue table Parameters] --> B[TableParameters validation]
    B --> C[CustomPropertyExtensionMixin]
    D[Athena Iceberg properties] --> C
    C --> E[Load existing Table definitions]
    E --> F[Resolve and sanitize names]
    F --> G[Reuse or register compatible string definitions]
    G --> H[CreateTableRequest extension]
Loading

Reviews (7) · Last reviewed commit: "Scope processed names by entity type, sh..."

Glue tables never carried custom properties. Two gaps: GlueSource builds its
own CreateTableRequest and never set `extension`, and GlueTable.Parameters was
typed as a model with a single `table_type` field, so Pydantic discarded every
other Glue parameter at validation. Wiring the extension alone would have
ingested nothing.

Glue parameters now map onto the table extension when `includeCustomProperties`
is enabled, for every table type rather than Iceberg only, since every Glue
table carries Parameters.

The sanitize/register/dedupe logic Athena had inline moves to a shared
CustomPropertyExtensionMixin so both connectors use one implementation. The
refactor is behaviour preserving: Athena's existing 49 tests pass untouched.

Three defects found while extracting it:

- Values were not coerced to str. Custom properties are registered as `string`
  and the server validates each value against that schema, so a non-string Glue
  parameter would have rejected the whole table, not just the property.
- The `string` property type ref was fetched even when the feature was off.
- The name sanitizer could emit names starting with `_`, `.` or `-`, which the
  server's customPropertyName pattern rejects. The failure was swallowed as a
  warning, so the property was silently dropped. Reachable for Glue because
  parameter keys are operator authored.

The registration cache is now a bounded LRUCache rather than an unbounded set.
Athena runs the table node multi threaded, so the collision check tolerates a
concurrent eviction between the membership test and the read.

Note: connector supplied extensions land on an entity's first write only.
EntityRepository.updateExtension reverts bot PUTs and does not consult
overrideMetadata, so later parameter changes do not propagate. Tracked
separately in #33324.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@harshsoni2024
harshsoni2024 requested a review from a team as a code owner September 15, 2026 11:15
@harshsoni2024
harshsoni2024 requested review from Khairajani and a lite review from Copilot September 15, 2026 11:15
@github-actions github-actions Bot added Ingestion safe to test Add this label to run secure Github workflows on PRs labels Sep 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

The Python checkstyle failed.

Please run make py_format and py_format_check in the root of your repository and commit the changes to this PR.
You can also use pre-commit to automate the Python code formatting.

You can install the pre-commit hooks with make install_test precommit_install.

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

Ruff G004 violations and unresolved falsy-value and sanitization-collision issues remain.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds AWS Glue table parameters as custom properties and shares processing logic with Athena.

Changes:

  • Preserves arbitrary Glue parameters and attaches them to table extensions.
  • Centralizes registration, sanitization, conversion, and caching.
  • Adds Glue, Athena, and shared-mixin unit tests.
File summaries
File Summary
ingestion/tests/unit/topology/database/test_glue.py Tests Glue parameter ingestion and wiring.
ingestion/tests/unit/topology/database/test_custom_property_extension_mixin.py Tests shared processing, caching, and sanitization.
ingestion/tests/unit/topology/database/test_athena.py Tests Athena compatibility and sanitizer behavior.
ingestion/src/metadata/ingestion/source/database/glue/models.py Preserves arbitrary Glue parameters.
ingestion/src/metadata/ingestion/source/database/glue/metadata.py Attaches Glue parameters to table extensions.
ingestion/src/metadata/ingestion/source/database/custom_property_extension_mixin.py Implements shared custom-property processing.
ingestion/src/metadata/ingestion/source/database/athena/metadata.py Refactors Athena to use shared logic.
Review details

Suppressed comments (3)

ingestion/src/metadata/ingestion/source/database/custom_property_extension_mixin.py:104

  • Two Glue parameter keys can sanitize to the same name, such as owner/team and owner__team. The second key then reuses the first definition and both values are written under one dictionary key, so one source parameter is silently lost; this is reachable now that arbitrary Glue keys are ingested. Generate a stable collision-free name (and test both keys) instead of only logging the collision.
            if sanitized_name in self._processed_prop:
                self._log_name_collision(sanitized_name, prop_name)
            elif not self._register_custom_property(
                sanitized_name, prop_name, entity_type, source_label, property_type
            ):

ingestion/src/metadata/ingestion/source/database/custom_property_extension_mixin.py:163

  • Ruff's G004 check also rejects this new logging f-string, leaving the required py-checkstyle gate red. Use lazy %-style arguments here as well.
            logger.debug(f"Custom property [{sanitized_name}] is shared by source keys [{previous}] and [{prop_name}]")

ingestion/src/metadata/ingestion/source/database/custom_property_extension_mixin.py:147

  • Ruff's G004 check rejects this new logging f-string, so py-checkstyle currently fails. Please pass the values as lazy %-style logging arguments instead of interpolating them eagerly.
            logger.warning(f"Failed to register custom property [{prop_name}] for {source_label}: {exc}")
  • Files reviewed: 7/7 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

github-actions Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit 85a05941e52d02273651a9cc7b273731d5e360e3 in Playwright run 35252120067, attempt 1.

✅ 110 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) 49m 7s

⏱️ Max setup 4m 36s · max shard execution 12m 39s · max shard-job elapsed before upload 18m 20s · reporting 4s

🌐 236.27 requests/attempt · 1.79 app boots/UI scenario · 0.00% common-shard skew

Optimization targets still in progress:

  • Browser traffic was 236.27 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 1.79 per UI scenario (216 boots / 121 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 28 0 0 0 0 0
✅ Shard ingestion-02 36 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

- Use lazy %-style logging arguments. The repo grandfathers existing f-string
  logging via .ruff-g004-baseline.json, so a new file gets none and
  check_ruff_suppressions.py rejected all three call sites. This is what the
  py-checkstyle job was failing on; G004 is also in FORBIDDEN_SUPPRESSION_CODES,
  so a noqa is not an option.

- Drop only None and empty string, not every falsy value. Glue extras are not
  coerced by the model, so a parameter can arrive as 0 or False, and the old
  `if not prop_value` discarded those before the str() conversion. Absent
  table_type still dumps as None and is still dropped.

- Report a sanitized-name collision at warning rather than debug. Two distinct
  source keys that sanitize alike write to the same extension entry, so one
  value is lost; Glue parameter keys are operator authored, so this is
  reachable. Kept last-wins rather than appending a hash, which would produce
  cryptic property names for a rare case, but the loss is no longer silent.
  The common case, one key seen across many tables, stays quiet.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings September 17, 2026 04:50
@github-actions

Copy link
Copy Markdown
Contributor

The Python checkstyle failed.

Please run make py_format and py_format_check in the root of your repository and commit the changes to this PR.
You can also use pre-commit to automate the Python code formatting.

You can install the pre-commit hooks with make install_test precommit_install.

Moving Athena's custom property logic onto the shared mixin removed two
f-string logging calls that were grandfathered in .ruff-g004-baseline.json.
check_ruff_suppressions.py --check fails on a stale baseline, so py-checkstyle
was still red after the lazy-logging fix.

Note for anyone regenerating this file locally: .nox is not in the script's
EXCLUDED_DISCOVERY_DIRS, so `--prune` will fold site-packages violations into
the baseline unless that directory is moved aside first.

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

Custom-property registration and cache updates are not atomic, allowing concurrent duplicate registrations and nondeterministic display names.

Review details

Suppressed comments (1)

ingestion/src/metadata/ingestion/source/database/custom_property_extension_mixin.py:105

  • __contains__ and _register_custom_property are separate operations, so two schema workers can both observe an uncached name and issue concurrent PUTs. Besides defeating the deduplication this cache is meant to provide, two different raw keys that sanitize to the same name can race without either call reaching _log_name_collision, making the definition's display name nondeterministic. Guard the check/register/cache-update sequence with a per-source lock or provide an atomic registration path.
            if sanitized_name in self._processed_prop:
                self._log_name_collision(sanitized_name, prop_name)
            elif not self._register_custom_property(
                sanitized_name, prop_name, entity_type, source_label, property_type
  • Files reviewed: 8/8 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 17, 2026 04:56

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

Sanitized-key collisions can lose distinct parameters, and registration can overwrite existing custom-property definitions.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (1)

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

ingestion/src/metadata/ingestion/source/database/custom_property_extension_mixin.py:110

  • Distinct source keys are still lossy after sanitization: a/b and a@b, for example, both become a__b, so this assignment overwrites the earlier value and both tables share one definition whose display name can describe the wrong key. The added test explicitly codifies the dropped value, but a warning does not preserve Glue Parameters; use a deterministic collision-resistant name for keys that require replacement and use it for both registration and the extension payload.
  • Files reviewed: 8/8 changed files
  • Comments generated: 1
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 17, 2026 05:06

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

Existing custom-property definitions can be overwritten, and distinct sanitized keys can collide and lose values.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (1)

ingestion/src/metadata/ingestion/source/database/custom_property_extension_mixin.py:134

  • create_or_update_custom_property is a PUT that replaces a matching Table custom-property definition by name. Because this call is unconditional on a cache miss, a Glue parameter such as classification or owner can overwrite an existing user-defined enum/integer property, including its type/configuration and display name, and invalidate existing extensions. Check existing Table definitions and reuse only a compatible one (otherwise skip or namespace the source key) instead of updating it.
            self.metadata.create_or_update_custom_property(  # pyright: ignore[reportUnknownMemberType, reportUnusedCallResult]
  • Files reviewed: 8/8 changed files
  • Comments generated: 1
  • Review effort level: Lite

@sonarqubecloud

Copy link
Copy Markdown

Conflict in athena/metadata.py was imports only: main added the TagItem import
for Lake Formation tag registration next to the custom-property imports this
branch had removed when that logic moved into CustomPropertyExtensionMixin.
Kept TagItem (used by _register_lf_tag); dropped CustomPropertyDataTypes and
OMetaCustomProperties, which this branch no longer references.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings September 17, 2026 16:47

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

Unresolved custom-property name-collision and cache-scope/concurrency findings remain.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (1)

ingestion/src/metadata/ingestion/source/database/custom_property_extension_mixin.py:125

  • _processed_prop is keyed only by sanitized_name, while the definitions snapshot is scoped by entity_type. After a Table call caches k, a later build_entity_extension(..., entity_type=Other) skips registration for Other and emits k even when that entity type has no such definition, causing the server's extension validation to reject it. Scope the processed/ownership cache key by entity type or remove the arbitrary entity_type support.
            if sanitized_name in self._processed_prop:
                if not self._owns_property_name(sanitized_name, prop_name):
                    continue
            elif not self._register_custom_property(
                sanitized_name, prop_name, entity_type, source_label, property_type, definitions
  • Files reviewed: 8/8 changed files
  • Comments generated: 2
  • Review effort level: Lite

Two issues from review, both in how the caches relate to each other.

_processed_prop was keyed by sanitized name alone while the definitions it
stands in for are scoped by entity type. Once a Table call cached a name, a
call for another entity type skipped registration and emitted the property
anyway, although that type has no definition for it - which the server rejects
for the whole entity, not just the property. Only Table is passed today, but
build_entity_extension accepts any entity type, so the API invites it. The
cache key is now "<entity type>:<name>".

_existing_definitions checked, fetched and stored without holding anything, so
concurrent Athena schema workers could each build their own snapshot and the
last store would replace the rest, discarding the definitions those workers had
recorded and re-sending them once the processed-name cache evicted. The fetch
is now behind a double-checked lock, so every worker shares one snapshot and a
name recorded by any of them is visible to all. It serialises one listing per
entity type per run, unlike the per-property PUT, which is still deliberately
unsynchronised.

The concurrency tests slow the listing on purpose: with an instant mock the
first worker finishes before the others look, so the race never happens and the
tests pass against the unfixed code.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings September 17, 2026 17:20
@gitar-bot

gitar-bot Bot commented Sep 17, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 2 closed / 2 findings

Adds AWS Glue table parameters as custom properties via a shared CustomPropertyExtensionMixin, with collision-resistant naming, bounded caches, and safety guards against definition overwrites. Distinct source keys that sanitize to the same base name now receive deterministic disambiguating suffixes, and legacy Athena property names are preserved on upgrade. All changes are ingestion-only; no schema, UI, or Java changes needed.

✅ 2 closed
✅ Edge Case: Distinct keys sanitizing to same name silently collapse

📄 ingestion/src/metadata/ingestion/source/database/custom_property_extension_mixin.py:96-109
Within one table, two distinct source keys that sanitize to the same name (e.g. a/b and a@b both become a__b) both write to registered_properties[sanitized_name], so the last value wins and the earlier one is silently dropped from the extension — the only trace is a logger.debug collision line. Glue parameter keys are operator-authored, so this is reachable. Consider surfacing the collision at warning level, or disambiguating the second name (e.g. append a short hash) so both values survive.

Closed: Edge Case: Digest suffix renames already-ingested Athena custom properties

📄 ingestion/src/metadata/ingestion/source/database/custom_property_extension_mixin.py:122-134 📄 ingestion/tests/unit/topology/database/test_athena.py:523 📄 ingestion/tests/unit/topology/database/test_athena.py:536 📄 ingestion/tests/unit/topology/database/test_athena.py:617 📄 ingestion/tests/unit/topology/database/test_athena.py:628 📄 ingestion/tests/unit/topology/database/test_athena.py:639
This commit makes _sanitize_property_name append an 8-char md5 digest to every name it rewrites (sanitized_name != prop_name). On main, Athena's custom-property ingestion registered rewritten keys without this suffix (e.g. myprop__airflow__dag__id__prod), and the updated assertions in test_athena.py confirm the produced names changed. For an Athena service already ingested before this change, re-running now registers a parallel definition under the new suffixed name (..._<digest>) while the old definition and any values tables hold against it are left orphaned, rather than being a behaviour-preserving refactor. Impact is limited to keys containing characters that require rewriting (leading/invalid chars); clean keys like write.format.default are unchanged. Consider documenting this migration effect, or only appending the digest when a genuine base-name collision is detected rather than for every rewritten name.

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

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

Resolve the legacy-name collision, unbounded per-entity definition state, and repeated retries after definition-listing failures.

Review details

Suppressed comments (3)

ingestion/src/metadata/ingestion/source/database/custom_property_extension_mixin.py:185

  • When an upgraded Athena definition reuses legacy_name for a rewritten key such as owner/team, a real source key named owner__team still resolves to that same name because clean names bypass the displayName check. Across tables (or within one table), whichever key is processed first claims Table:owner__team and _owns_property_name drops the other, so legacy continuity can reintroduce the collision this digest scheme is meant to avoid. Resolve names with awareness of legacy-owned names—preserving the old key while deterministically disambiguating the clean competitor—and add a regression test.
        data_type, display_name = definitions.get(legacy_name, (None, None))
        if data_type == CustomPropertyDataTypes.STRING.value and display_name == prop_name:
            # An earlier release registered this exact source key under the undisambiguated name,
            # and every table ingested since holds its values there. Moving to the disambiguated
            # name would orphan them and leave two properties for one key. A legacy name claimed by

ingestion/src/metadata/ingestion/source/database/custom_property_extension_mixin.py:267

  • The LRU here bounds only the number of entity-type entries, but the cached EntityDefinitions for Table is mutated with every newly registered key. A catalog with many distinct Glue parameters therefore grows this single dict for the entire run, so the snapshot still has unbounded memory usage despite the LRU wrapper. Bound the per-entity definitions/ownership state as well (or scope and evict the snapshot) while preserving the no-repeat-registration behavior.
            definitions[sanitized_name] = (CustomPropertyDataTypes.STRING.value, prop_name)

ingestion/src/metadata/ingestion/source/database/custom_property_extension_mixin.py:296

  • Because a failed definitions listing is never cached, a persistent error such as missing type permissions causes one GET plus a warning per table. build_entity_extension runs for every Glue/Athena table, so a large catalog turns an unavailable endpoint into an N+1 API storm and warning flood. Preserve transient retry semantics with a bounded or short-lived negative cache/backoff instead of retrying the same failure for every entity.
            if definitions is None:
                # Not cached, so a transient failure costs this entity its extension rather than
                # disabling custom properties for the rest of the run.
                return None
  • Files reviewed: 8/8 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@harshsoni2024

Copy link
Copy Markdown
Contributor Author

🔵 Needs a closer look

Resolve the legacy-name collision, unbounded per-entity definition state, and repeated retries after definition-listing failures.

Review details

Thanks — looked at all three. None are data-corrupting, and I don't think any
blocks this PR.

Legacy name vs. a clean competitor — On a fresh
install owner/team and owner__team resolve to distinct names; it's only when
an earlier release already registered owner__team that both land on it, and
the second is dropped with a warning rather than silently overwritten. Worth
closing, but the fix has to be narrower than keying on displayName != prop_name
— that would also fire on a hand-curated definition (property retention with
displayName "Retention Days"), renaming it and orphaning its values, which trades
a rare problem for a common one. The safe test is whether the existing
displayName is itself a raw key this code would have rewritten to exactly that
name; a human label doesn't satisfy it.

Definitions dict growth — this one I'd leave. It gains an entry per
definition actually created on the server, and the initial listing already
materialises everything the server holds, so it tracks server-side definition
count rather than catalog size. Bounding it reopens the redundant-PUT path fixed
in 0ca4388 (eviction caused a second PUT that rewrites displayName/description/
config). The LRU bounds what actually varies — entity types.

Retry on a persistent listing failure — fair, and I only reasoned about the
transient case when I chose not to cache failures. For a lasting 403 it's one GET
plus warnings per table across the catalog. A bounded consecutive-failure count
(stop after a few, log once) keeps transient retry without the noise; the
per-table warning needs to drop to debug at the same time or the flood survives.

@harshsoni2024
harshsoni2024 added this pull request to the merge queue Sep 18, 2026
Merged via the queue into main with commit 43ddb8a Sep 18, 2026
122 checks passed
@harshsoni2024
harshsoni2024 deleted the issue-31467-glue-custom-properties branch September 18, 2026 11:33

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.

Support Custom Properties for AWS Glue Catalog

3 participants