fix(rest): skip serializing unset optional fields in CreateTableRequest#2610
Open
rahulsmahadev wants to merge 1 commit into
Open
fix(rest): skip serializing unset optional fields in CreateTableRequest#2610rahulsmahadev wants to merge 1 commit into
rahulsmahadev wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RestCatalog::create_tableserializesCreateTableRequestwith explicitnullvalues 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.rs—CreateTableRequest: skip serializinglocation,partition_spec,write_order,stage_createwhenNone(propertieswas already skipped when empty).crates/iceberg/src/spec/partition.rs—UnboundPartitionSpec: skip serializingspec_idwhenNone;UnboundPartitionField: skip serializingfield_idwhenNone. These types are embedded in the create-table request body.Deserialization is unchanged:
skip_serializing_ifonly affects serialization, and serde still accepts both missing fields and explicitnullfor theseOptionfields (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 explicitnulls still deserialize (backward compatibility).test_unbound_partition_spec_serialization_skips_none_fields— unsetspec-id/field-idare omitted, set values serialized, explicitnulls still deserialize.Note: I was unable to compile or run tests locally in my environment (no crates.io access); relying on CI to verify.