Repository navigation
fix(glue): ingest AWS Glue table parameters as custom properties - #33333
Conversation
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>
|
The Python checkstyle failed. Please run You can install the pre-commit hooks with |
There was a problem hiding this comment.
🟡 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/teamandowner__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-checkstylegate 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-checkstylecurrently 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.
✅ Playwright Results — workflow succeededValidated commit ✅ 110 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky PerformanceBlocking 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:
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>
|
The Python checkstyle failed. Please run You can install the pre-commit hooks with |
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>
There was a problem hiding this comment.
🔵 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_propertyare 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
There was a problem hiding this comment.
🟡 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/banda@b, for example, both becomea__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 GlueParameters; 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
There was a problem hiding this comment.
🟡 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_propertyis 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 asclassificationorownercan 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
|
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>
There was a problem hiding this comment.
🟡 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_propis keyed only bysanitized_name, while the definitions snapshot is scoped byentity_type. After a Table call cachesk, a laterbuild_entity_extension(..., entity_type=Other)skips registration forOtherand emitskeven 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 arbitraryentity_typesupport.
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>
Code Review ✅ Approved 2 closed / 2 findingsAdds AWS Glue table parameters as custom properties via a shared ✅ 2 closed✅ Edge Case: Distinct keys sanitizing to same name silently collapse
Closed: Edge Case: Digest suffix renames already-ingested Athena custom properties
OptionsDisplay: compact → Counting what did not apply, without listing it. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
There was a problem hiding this comment.
🔵 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_namefor a rewritten key such asowner/team, a real source key namedowner__teamstill resolves to that same name because clean names bypass thedisplayNamecheck. Across tables (or within one table), whichever key is processed first claimsTable:owner__teamand_owns_property_namedrops 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
EntityDefinitionsforTableis 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
GETplus a warning per table.build_entity_extensionruns 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
Thanks — looked at all three. None are data-corrupting, and I don't think any Legacy name vs. a clean competitor — On a fresh Definitions dict growth — this one I'd leave. It gains an entry per Retry on a persistent listing failure — fair, and I only reasoned about the |



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:
GlueSourceextendsDatabaseServiceSource, notCommonDbSourceService, so it inherited neither theget_table_extensionshook nor theextension=wiring, and never setextension.GlueTable.Parameterswas typed as a closed model whose only field istable_type, so Pydantic silently dropped every other key at validation. Wiringextension=alone would have ingested nothing.Scope:
Table.Parametersonly, all Glue table types, tables only. Python-ingestion only —includeCustomPropertiesalready exists ondatabaseServiceMetadataPipeline.json, so no schema, UI, Java, ormake generatechange.Manual testing
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.
owner_team,skip.header.line.count,retention-daysdata/ownerdata__owner_3338169ddata@ownerdata__owner_2fbae9eddata__ownerand one value was lost_internal_flagp__internal_flag_413ad214cost:center,has spacecost__center_5e777b40,has__space_53f8a8e7/2a1d844d1cfe49248e52dc899a85c8e7empty_value: ""retentionretentionsurvived untouched, and the table's extension has noretentionkeyowner_teamon a 2nd tableUpgrade 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: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:
High-level design:
New
CustomPropertyExtensionMixinholds the resolve → register → dedupe → value-filter loop that was inline inAthenaSource. Each connector supplies only its property source: Athena_fetch_iceberg_properties()(still Iceberg-gated), Gluetable.Parameters.model_dump()(no table-type gate — every Glue table carriesParameters). Modelled onlife_cycle_query_mixin.py, not theABCinexternal_table_lineage_mixin.py, which only passes basedpyright via grandfathered baseline entries a new file wouldn't get.TableParametersgetsConfigDict(extra="allow")— one line, deliberately not a retype todict[str, str], so.table_typestays a declared field and both production call sites and every existing test keep working.Latent defects found while extracting the Athena logic, all fixed:
str. The server validates each value against the registeredstringschema and rejects the whole entity. Athena was immune only because its fetch already didstr(...);extra="allow"does not coerce, so Glue would have hit this.stringtype ref was fetched unconditionally, even with the feature off.customPropertyNamerequires an alphanumeric first character, andEntityNamecarries 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.
a/banda@bboth reduce toa__b), so one key's value was lost and the definition'sdisplayNamedescribed 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.stringdefinition whosedisplayNameis that exact raw key keeps being used, so upgrades orphan nothing and create no duplicate.retentionwould invalidate every other table's values. Incompatible → skip with a warning; compatiblestring→ reuse with no PUT, so a curateddisplayName/descriptionsurvives; unclaimed → create.set[str]; it and the definition snapshots are now the houseLRUCache.Tablesays 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=TrueondatabaseSchemaandtableis its child, so the caches are genuinely shared. That surfaced one bug:LRUCache.get()raisesKeyError, 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
Parameterstodict[str, str]; readingtable_dataoff 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 existingdisplayNamewas edited away from the raw key, or the definition is not of typestring. 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
Parametersappear as Custom Properties with a matching Table definition, for Regular/External/View/Iceberg.displayName; two keys sharing a base both survive with distinct definitions.Unit tests
tests/unit/topology/database/test_custom_property_extension_mixin.py(new)tests/unit/topology/database/test_glue.pytests/unit/topology/database/test_athena.pyCovers 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_parameterspins the root cause: it fails onmain.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_checkpasses.make static-checks(basedpyright,--baselinemode=discard): 24 errors repo-wide, none in any file this PR touches.Backend / ingestion integration / Playwright
Known limitation (pre-existing, not introduced here)
Connector-supplied
extensionlands on an entity's first write only.EntityRepository.updateExtensionreverts any bot-supplied extension on a PUT:Ingestion authenticates as
ingestion-botand the table bulk path usesOperation.PUT.overrideMetadatais honoured elsewhere inEntityRepositorybut 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:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.includeCustomProperties(not even for Athena), and the ingestion form label comes from the schema'stitle.🤖 Generated with Claude Code
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.
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]Reviews (7) · Last reviewed commit: "Scope processed names by entity type, sh..."