Skip to content

Glue: Prune removed table properties from Glue Parameters - #4133

Merged
kevinjqliu merged 3 commits into
apache:mainfrom
Ankitraj-builds:fix/glue-prune-removed-properties
Oct 24, 2026
Merged

kevinjqliu merged 3 commits into
apache:mainfrom
Ankitraj-builds:fix/glue-prune-removed-properties

Conversation

@Ankitraj-builds

@Ankitraj-builds Ankitraj-builds commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Closes #3977

Rationale for this change

_construct_parameters in pyiceberg/catalog/glue.py starts from the existing Glue Parameters and only adds or overwrites keys. When a property is removed from the table, it stays in Glue forever, so Glue and the table properties drift apart.

This change passes the table's previous properties into _construct_parameters during commit_table. Any key that was in the previous properties but is not in the new ones is removed from Parameters. Glue keys that never came from Iceberg table properties are kept, which matches the Java Glue catalog behavior that @David-Banquet pointed out in the issue.

The new argument is optional with a default of None, so create_table, register_table and other callers are unchanged.

Additionally, table properties named table_type, metadata_location or previous_metadata_location can no longer overwrite the catalog-managed Glue parameters of the same name, which could break load_table. Covered by test_commit_table_properties_do_not_overwrite_reserved_parameters.

Are these changes tested?

Yes. Added test_commit_table_prunes_removed_properties in tests/catalog/test_glue.py. It creates a table with two properties, removes one, commits, and checks that the removed key is gone from Glue Parameters while the other one stays. The test fails on main and passes with this change. All 53 tests in tests/catalog/test_glue.py pass locally.

Are there any user-facing changes?

Yes. After this change, properties removed from a Glue-backed table are also removed from the Glue table Parameters on the next commit. Glue keys not managed by Iceberg are not touched.

@rambleraptor rambleraptor left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quick nit. thanks for the PR!

Comment thread pyiceberg/catalog/glue.py Outdated
"TableType": EXTERNAL_TABLE,
"Parameters": _construct_parameters(metadata_location, glue_table, prev_metadata_location, properties),
"Parameters": _construct_parameters(
metadata_location, glue_table, prev_metadata_location, properties, prev_metadata_properties

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use named parameters for this? We've got a lot of properties with very similar names and ever so different orderings of parameters.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, switched to keyword arguments in the latest commit. Thanks for the review!

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

Thanks for fixing this @Ankitraj-builds

@Fokko
Fokko enabled auto-merge October 22, 2026 21:14

@rambleraptor rambleraptor left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for that (very quick!) change

@Fokko
Fokko added this pull request to the merge queue Oct 22, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Oct 23, 2026
@Ankitraj-builds

Copy link
Copy Markdown
Contributor Author

Thanks @Fokko and @rambleraptor It looks like the merge queue removed this PR. The branch still merges cleanly with main and the Glue tests pass locally. Could you re-add it to the queue when you get a chance?

A table property named table_type, metadata_location, or
previous_metadata_location overwrote the catalog-managed Glue parameter
of the same name, which could point Glue at a bogus metadata file and
break load_table. Skip reserved keys when copying table properties,
matching the Hive catalog.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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

LGTM

I added a fix to guard against setting reserved keys (table_type, metadata_location, previous_metadata_location) in 3194838 (this PR)

@kevinjqliu
kevinjqliu enabled auto-merge October 24, 2026 07:10
@kevinjqliu
kevinjqliu added this pull request to the merge queue Oct 24, 2026
Merged via the queue into apache:main with commit 2ecd87b Oct 24, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Glue table Parameters are never pruned: removed table properties persist indefinitely

4 participants