Skip to content

Commit f69b231

Browse files
authored
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.
1 parent 4355912 commit f69b231

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pyiceberg/catalog/rest.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
UnauthorizedError,
5959
)
6060
from pyiceberg.partitioning import UNPARTITIONED_PARTITION_SPEC, PartitionSpec
61-
from pyiceberg.schema import Schema
61+
from pyiceberg.schema import Schema, assign_fresh_schema_ids
6262
from pyiceberg.table import (
6363
CommitTableRequest,
6464
CommitTableResponse,
@@ -447,13 +447,14 @@ def create_table(
447447
sort_order: SortOrder = UNSORTED_SORT_ORDER,
448448
properties: Properties = EMPTY_DICT,
449449
) -> Table:
450-
schema: Schema = self._convert_schema_if_needed(schema) # type: ignore
450+
iceberg_schema = self._convert_schema_if_needed(schema)
451+
iceberg_schema = assign_fresh_schema_ids(iceberg_schema)
451452

452453
namespace_and_table = self._split_identifier_for_path(identifier)
453454
request = CreateTableRequest(
454455
name=namespace_and_table["table"],
455456
location=location,
456-
table_schema=schema,
457+
table_schema=iceberg_schema,
457458
partition_spec=partition_spec,
458459
write_order=sort_order,
459460
properties=properties,

0 commit comments

Comments
 (0)