Skip to content

feat(hive): accept the Java owner properties - #4597

Open
Anurag-S1ngh wants to merge 1 commit into
apache:mainfrom
Anurag-S1ngh:feat/4140-hive-owner
Open

Anurag-S1ngh wants to merge 1 commit into
apache:mainfrom
Anurag-S1ngh:feat/4140-hive-owner

Conversation

@Anurag-S1ngh

Copy link
Copy Markdown
Contributor

Part of #4140

Rationale for this change

Java clients store the table owner in the hive.metastore.table.owner table property, while PyIceberg reads owner. Tables now fall back to the Java property, with owner taking precedence. For databases, hive.metastore.database.owner and hive.metastore.database.owner-type are mapped to the Thrift owner fields and removed from the database parameters, matching Java's HiveCatalog. Setting an owner type without an owner raises.

Are these changes tested?

Added tests for the Java table owner, native-key precedence, the database owner and owner type, and the owner-type-without-owner error. tests/catalog/test_hive.py passes apart from four kerberos tests that also fail on clean main because the kerberos extra is not installed locally.

Are there any user-facing changes?

Yes. The Java owner properties are accepted.

Java tables store the owner in the hive.metastore.table.owner table
property, and databases in hive.metastore.database.owner with an
optional owner-type. Read them alongside the native owner property
and map the database keys to the Thrift owner fields.

@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 @Anurag-S1ngh! The keys and owner-type mapping match Java. A few differences inline.

Comment thread pyiceberg/catalog/hive.py
dbName=database_name,
tableName=table_name,
owner=table.properties[OWNER] if table.properties and OWNER in table.properties else getpass.getuser(),
owner=get_first_property_value(table.properties or {}, OWNER, HIVE_METASTORE_TABLE_OWNER) or getpass.getuser(),

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.

Java strips hive.metastore.table.owner from the HMS table parameters on both create and commit (HMSTablePropertyHelper.java:94 and :146). Here it is still copied into the parameters via _construct_parameters. Could we filter it out and assert that in the test?

Comment thread pyiceberg/catalog/hive.py
for key, value in properties.items():
if key == COMMENT:
database.description = value
elif key == LOCATION:

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.

Java returns the owner from loadNamespaceMetadata (HiveCatalog.java:806-808) and supports removing both owner keys (HiveCatalog.java:652-655). Here load_namespace_properties doesn't return them, and removing hive.metastore.database.owner via update_namespace_properties reports it as missing. Could we handle both so the property round-trips?

Fokko

This comment was marked as outdated.

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.

2 participants