From f69b2317bd28ae32e79d4487c7213f1b3b6ad469 Mon Sep 17 00:00:00 2001 From: Fokko Driesprong Date: Tue, 30 Jan 2024 20:21:21 +0100 Subject: [PATCH] REST: Set fresh IDs on create-table (#327) For the other implementation we do this when writing the metadata, but for the REST catalog we just post the schema itself. The REST spec does not mention anything about setting fresh IDs, so it is best to do it ourselves. --- pyiceberg/catalog/rest.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pyiceberg/catalog/rest.py b/pyiceberg/catalog/rest.py index 34d75b5936..765f04b128 100644 --- a/pyiceberg/catalog/rest.py +++ b/pyiceberg/catalog/rest.py @@ -58,7 +58,7 @@ UnauthorizedError, ) from pyiceberg.partitioning import UNPARTITIONED_PARTITION_SPEC, PartitionSpec -from pyiceberg.schema import Schema +from pyiceberg.schema import Schema, assign_fresh_schema_ids from pyiceberg.table import ( CommitTableRequest, CommitTableResponse, @@ -447,13 +447,14 @@ def create_table( sort_order: SortOrder = UNSORTED_SORT_ORDER, properties: Properties = EMPTY_DICT, ) -> Table: - schema: Schema = self._convert_schema_if_needed(schema) # type: ignore + iceberg_schema = self._convert_schema_if_needed(schema) + iceberg_schema = assign_fresh_schema_ids(iceberg_schema) namespace_and_table = self._split_identifier_for_path(identifier) request = CreateTableRequest( name=namespace_and_table["table"], location=location, - table_schema=schema, + table_schema=iceberg_schema, partition_spec=partition_spec, write_order=sort_order, properties=properties,