Skip to content

Commit df294d1

Browse files
committed
fix: add metadata_properties to _construct_parameters when update hive table
1 parent da88b8d commit df294d1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pyiceberg/catalog/hive.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,18 @@ def _construct_hive_storage_descriptor(
211211
DEFAULT_PROPERTIES = {TableProperties.PARQUET_COMPRESSION: TableProperties.PARQUET_COMPRESSION_DEFAULT}
212212

213213

214-
def _construct_parameters(metadata_location: str, previous_metadata_location: Optional[str] = None) -> Dict[str, Any]:
214+
def _construct_parameters(
215+
metadata_location: str, previous_metadata_location: Optional[str] = None, metadata_properties: Optional[Properties] = None
216+
) -> Dict[str, Any]:
215217
properties = {PROP_EXTERNAL: "TRUE", PROP_TABLE_TYPE: "ICEBERG", PROP_METADATA_LOCATION: metadata_location}
216218
if previous_metadata_location:
217219
properties[PROP_PREVIOUS_METADATA_LOCATION] = previous_metadata_location
218220

221+
if metadata_properties:
222+
for key, value in metadata_properties.items():
223+
if key not in properties:
224+
properties[key] = str(value)
225+
219226
return properties
220227

221228

@@ -541,6 +548,7 @@ def commit_table(
541548
hive_table.parameters = _construct_parameters(
542549
metadata_location=updated_staged_table.metadata_location,
543550
previous_metadata_location=current_table.metadata_location,
551+
metadata_properties=updated_staged_table.properties,
544552
)
545553
open_client.alter_table_with_environment_context(
546554
dbname=database_name,

0 commit comments

Comments
 (0)