Skip to content

fix(rest): send spec-id 0 in create_table when the partition spec has none - #3530

Open
ninglinLiu wants to merge 2 commits into
apache:mainfrom
ninglinLiu:fix/rest-create-table-spec-id
Open

ninglinLiu wants to merge 2 commits into
apache:mainfrom
ninglinLiu:fix/rest-create-table-spec-id

Conversation

@ninglinLiu

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

What changes are included in this PR?

RestCatalog::create_table now sends spec-id: 0 when the UnboundPartitionSpec in the TableCreation has no spec id, and keeps the id unchanged when one is set.

Since #2610, an unset spec id is omitted from the request. Servers that parse the request with Iceberg Java's PartitionSpecParser (for example Polaris 1.3.0) require spec-id and reject the request with a bare HTTP 400. The first spec of a new table always has id 0, which is also what the Java client sends.

The default is applied where the REST request is built, so the serde behaviour of UnboundPartitionSpec (which is also used for TableUpdate::AddSpec and elsewhere) is unchanged.

Are these changes tested?

Yes.

  • test_create_table now matches the request body and requires "partition-spec": {"spec-id": 0} for a spec built without an id. It fails on main and passes with this change.
  • New test_create_table_keeps_explicit_partition_spec_id checks that an explicitly set spec id (3) is sent unchanged.

cargo test -p iceberg-catalog-rest --lib (97 tests), cargo clippy -p iceberg-catalog-rest --all-targets -- -D warnings and cargo fmt --all -- --check pass.

This PR was prepared with AI assistance and reviewed/tested by the author.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

REST create_table omits partition spec-id; Java-based servers (Polaris) reject it

1 participant