fix(aws): apply column comments when syncing to Glue - #19488
Conversation
setComments built a Column carrying the comment and dropped the result, so updateTableComments never changed anything, always returned false, and no column or partition column comment reached Glue. Before the AWS SDK v2 upgrade (apache#9347) this called column.setComment(...) on the mutable v1 model, which worked; the v2 models are immutable, so the columns have to be rebuilt. Rebuilding the column list is not sufficient on its own: StorageDescriptor is immutable too, and the request was sending the original descriptor, so its columns would still have carried no comments. The descriptor is now rebuilt from the updated columns and it is that descriptor which is sent. A column the storage schema says nothing about is left untouched rather than cleared. The pre-SDK-v2 code cleared it, but that has been a no-op for three years so nothing depends on it, and clearing is the riskier reading: storage field names keep the Avro schema's case while a catalog may hold them lowercased, and a name that failed to match would silently wipe a comment. This also matches HMSDDLExecutor.applyFieldComments, added for the Hive side in apache#19289. The change-detection also compared a freshly fetched table against the local objects it had not modified, which was trivially equal and cost two extra Glue GetTable calls per sync. It now compares the fetched table against the rebuilt values, so one GetTable call does the job. Closes apache#19316
hudi-agent
left a comment
There was a problem hiding this comment.
Thanks for working on this! This PR fixes AWSGlueCatalogSyncClient column/partition comment syncing, which had been a silent no-op since the AWS SDK v2 upgrade — SDK v2 model classes are immutable, so the old setComments built a Column and discarded it. The fix rebuilds the columns and, importantly, the enclosing StorageDescriptor so the UpdateTableRequest actually carries the comments, and reworks change detection to compare the original against the rebuilt descriptor. The immutability handling, unchanged-column short-circuit, and unknown-column preservation all look correct and are well covered by the new tests. No correctness issues found. A few style/readability suggestions in the inline comments. Please take a look, and this should be ready for a Hudi committer or PMC member to take it from here. Code looks clean overall — the withComments rename, immutability fix, and test coverage are all well-done; one minor doc phrasing note below.
cc @yihua
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #19488 +/- ##
=========================================
Coverage 76.97% 76.97%
- Complexity 33855 33862 +7
=========================================
Files 2575 2575
Lines 143378 143378
Branches 17573 17573
=========================================
+ Hits 110362 110368 +6
+ Misses 24755 24751 -4
+ Partials 8261 8259 -2
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Review nit: "a no-op for three years" dates badly. The load-bearing fact is that the pre-SDK-v2 code built a Column and discarded it, so no comment was ever applied - say that instead.
hudi-agent
left a comment
There was a problem hiding this comment.
Thanks for working on this! This PR fixes AWS Glue column-comment syncing that had silently no-op'd since the SDK v2 upgrade, by rebuilding the immutable Column/StorageDescriptor objects instead of discarding the built result. The withComments logic (preserving unknown columns, clearing known-but-undoc'd ones) and the switch to comparing the rebuilt descriptor against the already-fetched one both trace out correctly, and the tests cover the key cases. No issues flagged from this automated pass — a Hudi committer or PMC member can take it from here for a final review.
cc @yihua
codecov reported 58% patch coverage with 5 uncovered lines, all inside updateTableComments. The tests drove withComments directly because the method itself was unreachable from this module: it calls getTableDoc(), which resolves the table schema, and the fixture had none. Root cause of that, which the earlier revision only described vaguely: GlueTestUtil wrote its commit as JSON into .hoodie, but this is a table-version-8+ table whose active timeline lives under .hoodie/timeline and is read through CommitMetadataSerDe. The instant was therefore not on the timeline at all, and writing it there by hand still failed because CommitMetadataSerDe exposes only deserialize. Write the commit through HoodieTestTable instead, which is what the rest of the repo uses, and add the two test-jar dependencies it needs - hudi-hadoop-common for HoodieTestTable and hudi-common for the FileCreateUtils it delegates to. Both are declared exactly as the sibling hudi-gcp and hudi-azure modules declare them; 27 modules already depend on the hudi-hadoop-common test-jar, and there is no cycle. GlueTestUtil's hand-rolled createMetaFile is now dead and goes with it. That makes updateTableComments testable, so two tests now drive it: comments applied to columns and partition keys with the captured UpdateTableRequest asserted, and the no-op case where nothing changed. The end-to-end test earns its keep on the half the unit tests could not reach. Rebuilding the column list but sending the original StorageDescriptor - the mistake the issue's own suggested fix would have made - fails only this new test, and nothing else in the suite.
hudi-agent
left a comment
There was a problem hiding this comment.
Thanks for working on this! The PR fixes AWSGlueCatalogSyncClient so column and partition-column comments are actually applied when syncing to Glue by rebuilding the immutable SDK v2 Column list and StorageDescriptor instead of discarding the rebuilt column, and correcting the always-false no-op comparison. No issues flagged from this automated pass, a Hudi committer or PMC member can take it from here for a final review.
cc @yihua
Describe the issue this Pull Request addresses
Closes #19316.
AWSGlueCatalogSyncClient.updateTableCommentshas applied no column or partition column comments since theAWS SDK v2 upgrade (#9347). Its helper built a
Columncarrying the comment and threw the result away:Before the upgrade this called
column.setComment(...)on the mutable v1 model, which worked. SDK v2 modelclasses are immutable, so nothing was applied:
updateTableCommentsnever detected a change, alwaysreturned
false, and withhoodie.datasource.hive_sync.sync_comment=trueno comment ever reached Glue.Found while reviewing #19289, which fixed the equivalent Hive metastore paths.
Summary and Changelog
setCommentsbecomeswithComments, which returns a rebuilt list instead of mutating in place.The storage descriptor is rebuilt too. Rebuilding only the column list is not enough and is the part
worth reviewing:
StorageDescriptoris immutable as well, and theUpdateTableRequestwas sending theoriginal descriptor. Editing a copy of
storageDescriptor.columns()— which is what the issue textoriginally suggested — would still have shipped columns with no comments. The request now sends the
descriptor rebuilt from the updated columns.
A column the storage schema says nothing about is left untouched rather than cleared. The pre-SDK-v2
code cleared it, but since that code has been a no-op for three years nothing depends on it, and clearing
is the riskier reading:
getStorageFieldSchemaskeeps the Avro schema's case while a catalog may holdcolumn names lowercased, so a name that failed to match would silently wipe a user's comment. Columns the
schema does know are still authoritative — a known column with no doc has its comment cleared. This
matches
HMSDDLExecutor.applyFieldComments, added for the Hive side in fix(hive-sync): sync column and partition column comments to HMS #19289, so the two catalogs nowagree.
Change detection now uses the table already fetched. It compared a freshly fetched table against local
objects it had not modified — trivially equal, and two extra Glue
GetTablecalls per sync. It nowcompares the fetched table against the rebuilt values, so one
GetTablecall does the job.Verification
withCommentsis@VisibleForTestingand covered by four new tests inTestAWSGlueSyncClient:testWithCommentsAppliesTheStorageCommenttestWithCommentsClearsTheCommentOfAKnownColumnWithoutADoctestWithCommentsLeavesColumnsTheStorageSchemaDoesNotKnowAlonetestRebuildingColumnsRequiresRebuildingTheStorageDescriptorstorageDescriptor.columns()is unmodifiable, and a descriptor rebuilt with new columns is a different object — the trap the original bug fell intoRestoring the build-and-drop behaviour inside
withCommentsturns three of them red, so they are notpassing vacuously:
Whole
hudi-awsmodule:Tests run: 99, Failures: 0, Errors: 0, Skipped: 16(skips pre-existing).checkstyle:checkandapache-rat:checkclean.Coverage gap now closed.
codecovreported 58.33% patch coverage with 5 uncovered lines, all insideupdateTableComments— the method this PR is about. The tests drovewithCommentsdirectly becauseupdateTableCommentswas unreachable from this module: it callsgetTableDoc(), which resolves the tableschema, and the fixture had none.
The cause was that
GlueTestUtilwrote its commit as JSON into.hoodie, while this is a table-version-8+table whose active timeline lives under
.hoodie/timelineand is read throughCommitMetadataSerDe. So theinstant was not on the timeline at all (
getActiveTimeline()returned[]), and putting it in the right placeby hand still failed, because
CommitMetadataSerDeexposes onlydeserialize.The fixture now writes the commit through
HoodieTestTable, as the rest of the repo does, which needs twotest-jar dependencies:
hudi-hadoop-commonforHoodieTestTableandhudi-commonfor theFileCreateUtilsit delegates to. Both are declared exactly as the sibling
hudi-gcpandhudi-azuremodules declare them —27 modules already depend on the
hudi-hadoop-commontest-jar — and there is no dependency cycle.GlueTestUtil's hand-rolledcreateMetaFileis dead as a result and is removed.Two tests now drive
updateTableCommentsend to end:testUpdateTableCommentsAppliesThemToColumnsAndPartitionKeysUpdateTableRequestcarries the comments on both the storage descriptor's columns and the partition keys, and the method reports a changetestUpdateTableCommentsIsANoOpWhenNothingChangesupdateTablecall at allThe end-to-end test earns its keep on the half the unit tests could not reach. Rebuilding the column list
but sending the original
StorageDescriptor— the mistake the issue's own suggested fix would have made —fails only this new test and nothing else in the suite:
Whole
hudi-awsmodule:Tests run: 101, Failures: 0, Errors: 0, Skipped: 16(skips pre-existing).checkstyle:checkandapache-rat:checkclean.Impact
With
hoodie.datasource.hive_sync.sync_comment=true, Glue column and partition column comments start beingapplied on the update path, which is the documented behaviour and what worked before the SDK v2 upgrade.
Users who already have comments in Glue keep them: only columns the storage schema knows are touched.
Two extra
GetTablecalls per comment sync are removed. No API, config or table format change.Risk Level
low — one helper rewritten and its result actually used, in a path that currently does nothing at all.
The semantics of the "unknown column" case are deliberately narrower than the pre-SDK-v2 code; that is
argued above rather than hidden.
Documentation Update
none — no new config, and this restores documented behaviour rather than changing it.
Contributor's checklist