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

GH-45257: [C++][Parquet] Fix Statistics<ByteArray> Cleanup handling #45258

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
14 changes: 12 additions & 2 deletions cpp/src/parquet/statistics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,18 @@ optional<std::pair<FLBA, FLBA>> CleanStatistic(std::pair<FLBA, FLBA> min_max,

optional<std::pair<ByteArray, ByteArray>> CleanStatistic(
std::pair<ByteArray, ByteArray> min_max, LogicalType::Type::type) {
if (min_max.first.ptr == nullptr || min_max.second.ptr == nullptr) {
return ::std::nullopt;
static ByteArray empty("");
if (min_max.first.ptr == nullptr) {
if (min_max.first.len != 0) {
return ::std::nullopt;
}
min_max.first = empty;
Copy link
Member

Choose a reason for hiding this comment

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

When will we see this kind of data?

Copy link
Member

Choose a reason for hiding this comment

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

I guess the root cause is here:

if (!encoded_min.empty()) {
PlainDecode(encoded_min, &min_);
}
if (!encoded_max.empty()) {
PlainDecode(encoded_max, &max_);
}
has_min_max_ = has_min_max;

When both min_value and max_value exist but at least one of them is an empty string, min_ or max_ is not initialized.

Should we fix here instead of CleanStatistics above?

Copy link
Member

Choose a reason for hiding this comment

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

}
if (min_max.second.ptr == nullptr) {
if (min_max.second.len != 0) {
return ::std::nullopt;
}
min_max.second = empty;
}
return min_max;
}
Expand Down
Loading