Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenAPI: add initial/write defaults to schema #12094

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

danielcweeks
Copy link
Contributor

Adds inital-default and write-default to the REST API spec.

Includes updates to a couple small round-trip request/response serde tests.

Copy link
Contributor

@kevinjqliu kevinjqliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Aligns with V3 default values from the spec
https://iceberg.apache.org/spec/#default-values

Comment on lines +2055 to +2058
initial-default:
type: string
write-default:
type: string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


"""
By default, OpenAPI treats all request parameters as optional.
"""
from
https://swagger.io/docs/specification/v3_0/describing-parameters/#required-and-optional-parameters

Copy link
Member

@jbonofre jbonofre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -2052,6 +2052,10 @@ components:
type: boolean
doc:
type: string
initial-default:
type: string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the type should be string. The table spec serializes these using the JSON single-value serialization, so it would be $ref: "#/components/schemas/PrimitiveTypeValue".

@@ -59,7 +60,7 @@ public class TestCreateTableRequest extends RequestResponseTestBase<CreateTableR
public void testRoundTripSerDe() throws JsonProcessingException {
String fullJsonRaw =
"{\"name\":\"test_tbl\",\"location\":\"file://tmp/location/\",\"schema\":{\"type\":\"struct\","
+ "\"schema-id\":0,\"fields\":[{\"id\":1,\"name\":\"id\",\"required\":true,\"type\":\"int\"},"
+ "\"schema-id\":0,\"fields\":[{\"id\":1,\"name\":\"id\",\"required\":true,\"type\":\"int\",\"write-default\":1},"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This demonstrates my comment below. The default here is not serialized as a string, it is a JSON value.

Here's where it is produced: https://github.com/apache/iceberg/blob/main/core/src/main/java/org/apache/iceberg/SchemaParser.java#L96

TableMetadata v3Metadata =
TableMetadataParser.fromJson(TEST_METADATA_LOCATION, tableMetadataJson);
// Convert the TableMetadata JSON from the file to an object and then back to JSON so that
// missing fields
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this line could be merged with the one below

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants