[#11534] fix(spark-connector): GravitinoGlueCatalog does not invalidate Iceberg SparkCatalog cache after table mutations#11559
Merged
Conversation
…table mutations in GravitinoGlueCatalog GravitinoGlueCatalog maintains two separate catalog backends: sparkCatalog (HiveTableCatalog) for non-Iceberg tables, and icebergGlueCatalog (Iceberg SparkCatalog) for Iceberg tables. BaseCatalog.alterTable/dropTable/purgeTable/ renameTable all called sparkCatalog.invalidateTable directly, bypassing virtual dispatch and never invalidating icebergGlueCatalog's internal CachingCatalog. After ALTER TABLE ADD COLUMNS, the stale CachingCatalog returned the pre-ALTER SparkTable, causing SparkIcebergTable.newScanBuilder() to use the old schema while schema() reported the new one, resulting in: IllegalStateException: Couldn't find <newCol> in [<oldCols>] Fix: change BaseCatalog to call invalidateTable(ident) (virtual dispatch) instead of sparkCatalog.invalidateTable(ident) directly, then override invalidateTable in GravitinoGlueCatalog to also invalidate icebergGlueCatalog when initialized.
Code Coverage Report
Files
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Override
invalidateTableinGravitinoGlueCatalogto also clearicebergGlueCatalog's cache. ChangeBaseCatalogmutation methods to callinvalidateTable(ident)via virtual dispatch so the override takes effect.Why are the changes needed?
icebergGlueCatalog's internalCachingCatalogwas never invalidated after table mutations, causing stale schema reads andIllegalStateException: Couldn't find <col> in [...]afterALTER TABLE ADD COLUMNS.Fix #11534
Does this PR introduce any user-facing change?
Yes. Stale schema error on Iceberg Glue tables after ALTER/DROP/PURGE/RENAME is fixed.
How was this patch tested?
TestGravitinoGlueCatalogtestIcebergAlterTableAddColumnCacheInvalidationinSparkGlueCatalogIT, verified against real AWS Glue + S3 (Spark 3.5)