Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,13 @@ private static void writePartitionSummaries(BlockBuilder arrayBlockBuilder, List

BlockBuilder rowBuilder = singleArrayWriter.beginBlockEntry();
BOOLEAN.writeBoolean(rowBuilder, summary.containsNull());
BOOLEAN.writeBoolean(rowBuilder, summary.containsNaN());
Boolean containsNan = summary.containsNaN();
if (containsNan == null) {
rowBuilder.appendNull();
}
else {
BOOLEAN.writeBoolean(rowBuilder, containsNan);
}
Comment on lines 140 to 146
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Optional may be handy here

            Optional.ofNullable(summary.containsNaN()).ifPresentOrElse(
                    containsNan -> BOOLEAN.writeBoolean(rowBuilder, containsNan),
                    rowBuilder::appendNull);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was thinking now also about something similar. A similar change would be beneficial for unboxing other types as well.

Alternatively this could be handled behind the scenes within BOOLEAN if we pass Boolean instead of boolean

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd love to avoid nullable reference types where possible. Quite easy to miss.

The writer being "smarter" means it's easy to introduce mistakes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi all

The field is nullable per the spec. It's generally only missing for older data files, so it's usually encountered (and why it's not super reproducible). But it is nullable per the spec. Older tables won't have this field populated and so that is a source of issue.

It is easy to encounter NPEs in my opinion so I typically prefer to handle things with optionals, but it is usually present (if that informs your thinking at all for performance etc) 👍

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

VARCHAR.writeString(rowBuilder, field.transform().toHumanString(
Conversions.fromByteBuffer(nestedType, summary.lowerBound())));
VARCHAR.writeString(rowBuilder, field.transform().toHumanString(
Expand Down