jackye1995 commented on code in PR #140: URL: https://github.com/apache/iceberg-python/pull/140#discussion_r1427178174
########## pyiceberg/catalog/glue.py: ########## @@ -59,21 +61,33 @@ from pyiceberg.partitioning import UNPARTITIONED_PARTITION_SPEC, PartitionSpec from pyiceberg.schema import Schema from pyiceberg.serializers import FromInputFile -from pyiceberg.table import CommitTableRequest, CommitTableResponse, Table +from pyiceberg.table import CommitTableRequest, CommitTableResponse, Table, update_table_metadata from pyiceberg.table.metadata import new_table_metadata from pyiceberg.table.sorting import UNSORTED_SORT_ORDER, SortOrder from pyiceberg.typedef import EMPTY_DICT -def _construct_parameters(metadata_location: str) -> Properties: - return {TABLE_TYPE: ICEBERG.upper(), METADATA_LOCATION: metadata_location} +def _construct_parameters( + metadata_location: str, glue_table: Optional[TableTypeDef] = None, prev_metadata_location: Optional[str] = None +) -> Properties: + new_parameters = glue_table.get("Parameters", {}) if glue_table else {} + new_parameters.update({TABLE_TYPE: ICEBERG.upper(), METADATA_LOCATION: metadata_location}) + if prev_metadata_location: + new_parameters[PREVIOUS_METADATA_LOCATION] = prev_metadata_location + return new_parameters -def _construct_create_table_input(table_name: str, metadata_location: str, properties: Properties) -> TableInputTypeDef: +def _construct_table_input( + table_name: str, + metadata_location: str, + properties: Properties, + glue_table: Optional[TableTypeDef] = None, + prev_metadata_location: Optional[str] = None, +) -> TableInputTypeDef: table_input: TableInputTypeDef = { "Name": table_name, "TableType": EXTERNAL_TABLE, - "Parameters": _construct_parameters(metadata_location), + "Parameters": _construct_parameters(metadata_location, glue_table, prev_metadata_location), Review Comment: I think we should ideally add the mapping we have in Java logic [here](https://github.com/apache/iceberg/blob/main/aws/src/main/java/org/apache/iceberg/aws/glue/IcebergToGlueConverter.java#L218), but we can do that as a follow up. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org