fix(rest): omit CreateTableRequest.location when None - #165
Open
forrestlinfeng wants to merge 1 commit into
Open
forrestlinfeng wants to merge 1 commit into
forrestlinfeng wants to merge 1 commit into
Conversation
Previously `location: Option<String>` was serialized as `"location": null` when unset, because the field had no `skip_serializing_if`. Some REST- compatible catalogs (notably AWS Glue REST) reject a present-but-null `location` even though the Iceberg REST spec marks the field as optional, expecting it to be omitted so they can fall back to a server-side default (e.g. the Glue database's `LocationUri`). Add `#[serde(default, skip_serializing_if = "Option::is_none")]` so the field is omitted when None, matching how `properties` is already handled and matching the spec semantics for optional fields. Also adds a unit test. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
forrestlinfeng
requested review from
Li0k,
chenzl25,
jonathanc-n,
mwylde,
nagraham and
vovacf201
as code owners
June 4, 2026 18:01
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.
Which issue does this PR close?
No issue filed — reporting and fixing directly. Happy to open one if preferred.
What changes are included in this PR?
CreateTableRequest.locationis declared asOption<String>but lacksskip_serializing_if, soserde_jsonemits"location": nullwhen the caller passesNone. Per the Iceberg REST spec the field is optional and should be omitted when unset.Several REST-compatible catalog servers (notably AWS Glue REST) reject a present-but-null
locationand never fall back to a server-side default (e.g. the Glue database'sLocationUri). The result isLocation information cannot be nullerrors that cannot be resolved from the server side — the database may already have aLocationUriset, but it's never consulted because the request actively provideslocation: null.This PR adds
#[serde(default, skip_serializing_if = "Option::is_none")]to thelocationfield, matching howpropertiesis already handled on the same struct and matching spec semantics for optional fields./// Optional table location. If not provided, the server will choose a location. + #[serde(default, skip_serializing_if = "Option::is_none")] pub location: Option<String>,Scope
Intentionally minimal — only
locationis touched. The sameOption<T>pattern withoutskip_serializing_ifexists onpartition_spec,write_order, andstage_create, and is likely worth the same treatment in a follow-up, but those haven't been observed to trigger server-side rejections in practice.Compatibility
This is a backwards-compatible serialization change:
{"name": "t", "location": null, "schema": {...}, ...}{"name": "t", "schema": {...}, ...}Spec-compliant REST servers MUST treat a missing optional field the same as an explicit null, so well-behaved servers (Polaris, Tabular, Lakekeeper, etc.) are unaffected. Strict servers like Glue REST start working.
Are these changes tested?
Yes — added a unit test
types::tests::test_create_table_request_omits_null_locationthat constructs aCreateTableRequest { location: None, .. }and asserts the serialized JSON has no"location"key. Existingcatalog::tests::test_create_tableandtest_create_table_409still pass.