OpenAPI: Mark StructField doc as nullable in REST catalog spec#16070
OpenAPI: Mark StructField doc as nullable in REST catalog spec#16070Amneet13 wants to merge 1 commit intoapache:mainfrom
Conversation
| doc: | ||
| type: string | ||
| nullable: true |
There was a problem hiding this comment.
isn't this optional ?
iceberg/core/src/main/java/org/apache/iceberg/SchemaParser.java
Lines 92 to 94 in 1f0579f
while sending to server this is omitted ? i know while reading i.e fromJson we are null tolerant but i think its fine
There was a problem hiding this comment.
@singhpk234 Thanks for the review! You're right that the Iceberg serializer omits doc when it's null. However, we ran into a real-world case where an Iceberg table is created on top of a Paimon table — in that scenario doc is explicitly sent as null (not omitted) in the response. This causes deserialization failures in clients auto-generated from the OpenAPI spec since the spec didn't allow null. Adding nullable: true makes the spec tolerant of both cases — absent and explicitly null — which is the safer contract for external clients.
Problem
The
docfield in theStructFieldschema inrest-catalog-open-api.yamlwas missingnullable: true. However, the Java implementation inTypes.NestedFieldhas always alloweddocto benull— it defaults tonull(see Types.java line 761) and thedoc()getter can returnnull.This mismatch means clients that auto-generate code from the OpenAPI spec would incorrectly treat
docas a required non-null string, potentially causing deserialization failures when the server returns aStructFieldwith nodocvalue.Change
Added
nullable: trueto thedocfield in theStructFieldschema to align the spec with the actual Java behavior.References
api/src/main/java/org/apache/iceberg/types/Types.java#L761open-api/rest-catalog-open-api.yaml#L2294