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

Parquet: Implement defaults for generic data #11785

Merged
merged 2 commits into from
Dec 16, 2024

Conversation

rdblue
Copy link
Contributor

@rdblue rdblue commented Dec 13, 2024

This adds default value support when reading Parquet files into Iceberg's generic data model.

Copy link
Contributor

@Fokko Fokko left a comment

Choose a reason for hiding this comment

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

Small nits, but it looks good. Great to see this being added 👍

public void testMissingRequiredWithoutDefault() {
Schema writeSchema =
new Schema(
required(1, "id", Types.LongType.get()),
Copy link
Contributor

Choose a reason for hiding this comment

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

For this test, I would drop fields {1,2} to ensure that it only focuses on being unable to read default fields without an initialDefault.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll drop the data field, but I think it's good to have an ID field so that we get unique records and can compare the lists easily when debugging.

@@ -276,15 +277,21 @@ public ParquetValueReader<?> struct(
} else if (id == MetadataColumns.IS_DELETED.fieldId()) {
reorderedFields.add(ParquetValueReaders.constant(false));
types.add(null);
} else if (reader != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I really miss Python's := operator here :)

NestedField.optional("missing_inner_float")
.withId(5)
.ofType(Types.FloatType.get())
.withInitialDefault(-0.0F)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add an example with another complex default type (map, list)?

Copy link
Contributor

@emkornfield emkornfield Dec 16, 2024

Choose a reason for hiding this comment

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

In addition to this, I'm not sure if this is the right place to test it but it would be good to make sure there test coverage that covers. The following spec requirements:

  • When a new field is added to a struct with a default value, updating the struct's default is optional
  • If a field value is missing from a struct's initial-default, the field's initial-default must be used for the field

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, good call out. I'll add those cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@emkornfield, right now we have only added support for primitive field defaults so those cases aren't being addressed yet.

@rdblue rdblue merged commit 57ea310 into apache:main Dec 16, 2024
49 checks passed
@rdblue
Copy link
Contributor Author

rdblue commented Dec 16, 2024

Merging this. Thanks for the review, @Fokko!

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.

3 participants