Skip to content

fix(rest): skip serializing unset optional fields in CreateTableRequest#2610

Open
rahulsmahadev wants to merge 1 commit into
apache:mainfrom
rahulsmahadev:fix-create-table-request-null-serialization
Open

fix(rest): skip serializing unset optional fields in CreateTableRequest#2610
rahulsmahadev wants to merge 1 commit into
apache:mainfrom
rahulsmahadev:fix-create-table-request-null-serialization

Conversation

@rahulsmahadev

Copy link
Copy Markdown

Summary

RestCatalog::create_table serializes CreateTableRequest with explicit null values for unset optional fields (e.g. "partition-spec": null, "write-order": null). Strict REST catalog implementations such as Apache Polaris reject these requests with HTTP 400 Bad Request. This change adds #[serde(skip_serializing_if = "Option::is_none")] to the optional fields on the create-table wire path so unset fields are omitted from the JSON body.

Fixes #2135

Changes

  • crates/catalog/rest/src/types.rsCreateTableRequest: skip serializing location, partition_spec, write_order, stage_create when None (properties was already skipped when empty).
  • crates/iceberg/src/spec/partition.rsUnboundPartitionSpec: skip serializing spec_id when None; UnboundPartitionField: skip serializing field_id when None. These types are embedded in the create-table request body.

Deserialization is unchanged: skip_serializing_if only affects serialization, and serde still accepts both missing fields and explicit null for these Option fields (covered by new tests).

Test plan

  • test_create_table_request_minimal_serialization — a request with only required fields set serializes without the optional keys.
  • test_create_table_request_full_serialization — a fully-populated request still serializes all optional keys.
  • test_create_table_request_deserialize_explicit_nulls — payloads with explicit nulls still deserialize (backward compatibility).
  • test_unbound_partition_spec_serialization_skips_none_fields — unset spec-id/field-id are omitted, set values serialized, explicit nulls still deserialize.

Note: I was unable to compile or run tests locally in my environment (no crates.io access); relying on CI to verify.

Unset optional fields of CreateTableRequest (location, partition-spec,
write-order, stage-create) and of the embedded UnboundPartitionSpec and
UnboundPartitionField (spec-id, field-id) were serialized as explicit
JSON nulls. Strict REST catalog servers such as Apache Polaris reject
those create-table requests with 400 Bad Request. Skip serializing
these fields when they are unset. Deserialization of explicit nulls is
unchanged.

Fixes apache#2135

Signed-off-by: rahulsmahadev <rahul.mahadev@databricks.com>
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 catalog CreateTableRequest sends explicit null values, causing 400 errors with Polaris

1 participant