Skip to content

Glue catalog: use comment for table and namespace descriptions, like the Hive catalog - #4629

Open
prateek11rai wants to merge 2 commits into
apache:mainfrom
prateek11rai:glue-table-comment
Open

prateek11rai wants to merge 2 commits into
apache:mainfrom
prateek11rai:glue-table-comment

Conversation

@prateek11rai

Copy link
Copy Markdown
Contributor

Note

🤖 claude-opus-5-5 on behalf of Prateek

Closes #4628

Rationale for this change

The Glue catalog ignored a description set with comment, unlike the Hive catalog, Java and iceberg-go (aa27f3f). The existing tests didn't catch it, and the docs didn't say which key to use. Details are in #4628. This PR fixes all three.

Alignment. In the Glue catalog, comment now sets the Glue description of tables and namespaces, and Description keeps working as a legacy key. When both are set, comment wins, as in iceberg-go.

  • Tables: every write path builds its TableInput in _construct_table_input, so the change is made once there. Rename is unchanged.
  • Namespaces: neither key is stored as a Glue parameter when it is used as the description. Setting either key updates the description, and removing either clears it. Databases written by older versions, which stored comment as a parameter, still load it, and the next update moves it into the description.
  • Load: load_namespace_properties returns the description under both comment and Description, so existing readers of Description don't break. iceberg-go returns comment only; we're happy to switch if you prefer.
  • Helper: _description_from_properties holds the comment-first rule because it is needed in three places, like iceberg-go's descriptionProperty.

Deprecating Description is left for the team to decide.

Are these changes tested?

Yes, with moto in tests/catalog/test_glue.py.

  • Existing tests: test_create_namespace_with_comment_and_location and test_update_namespace_properties only checked that comment round-trips through load. They now also assert the Glue description, and those assertions fail on main. Two load tests now expect the extra Description key.
  • New tests: comment alone, Description alone, and both set, for tables and namespaces; updating and removing each key; and databases written by older versions.
  • Integration tests: integration_test_glue.py is updated to match. We didn't run it, because it needs a real AWS account and no CI workflow runs it.

make lint, make test and mkdocs build --strict pass.

Are there any user-facing changes?

Yes.

  • A comment on a Glue table or namespace now sets its Glue description. Anything that only uses Description behaves as before.
  • load_namespace_properties on Glue also returns comment.
  • Docs:
    • The Glue section of the configuration docs gets a note with an example.
    • The "Create a table" example in api.md now sets comment, with a sentence saying it is the table and namespace description.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@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 @prateek11rai, nice one! Verified the parity with Java's GlueCatalog/IcebergToGlueConverter (GLUE_DESCRIPTION_KEY = "comment", description takes precedence over a comment parameter on load) and the behavior lines up, and the moto tests cover the legacy migration well. A few observations, none blocking:

  • pyiceberg/catalog/glue.py:1000: load_namespace_properties now returns the description under both comment and Description. A read-modify-write caller that edits only Description gets silently overridden by the stale comment alias, since comment wins in update_namespace_properties. Was that trade-off deliberate, or would returning only comment (like Java) be safer? You already raised it in the PR body; for what it's worth I'd lean towards the Java behavior.
  • pyiceberg/catalog/glue.py:1027: with removals={"comment"} and updates={"Description": ...} combined, the update wins while the PropertiesUpdateSummary still reports comment as removed. Similarly, removing one alias clears both, but the summary only lists the key from removals. Probably fine, just worth being aware of.
  • Test coverage: no test that clears a table description again (removing comment on a table commit), and test_update_namespace_description has no case where updates sets both keys.

Nit: could you use @pytest.mark.parametrize instead of the loops in test_create_namespace_description_from_properties, test_update_namespace_description and test_create_table_description_from_properties?

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@prateek11rai

Copy link
Copy Markdown
Contributor Author

Note

🤖 claude-opus-5-5 on behalf of Prateek

Thanks @Fokko for the review! I've pushed 8d18b0a, which addresses all four points:

  • Load returning both keys: we kept both on purpose. On main, Description is the only key that reaches the Glue description, so existing scripts read and edit it, and returning only comment would break them. For the stale-alias override you found, an update that sends both keys now uses the one that changed, and raises a ValueError if both changed to different values. test_update_namespace_description_after_load covers your read-modify-write case. Happy to switch to comment only if you still prefer the Java behavior.
  • Summary: removals are now adjusted before the summary is built. Removing one key lists both as removed, and removals={"comment"} with updates={"Description": ...} reports only the update. Removing and updating the same key still raises the existing overlap error.
  • Tests: added a table commit that removes the description (for both keys), and update cases that set both keys.
  • Nit: the three tests now use @pytest.mark.parametrize.

This branch has not been deployed

No deployments
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 catalog: use comment for table and namespace descriptions, like the Hive catalog

2 participants