Skip to content

Commit

Permalink
REST: Set fresh IDs on create-table (#327)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Fokko authored Jan 30, 2024
1 parent 4355912 commit f69b231
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pyiceberg/catalog/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit f69b231

Please sign in to comment.