Repository navigation
Ignore unsupported Parquet logical/physical type combinations - #25338
Draft
mhaseeb123 wants to merge 2 commits into
Draft
mhaseeb123 wants to merge 2 commits into
mhaseeb123 wants to merge 2 commits into
Conversation
…ir statistics Signed-off-by: Muhammad Haseeb <14217455+mhaseeb123@users.noreply.github.com>
Signed-off-by: Muhammad Haseeb <14217455+mhaseeb123@users.noreply.github.com>
mhaseeb123
commented
Nov 17, 2026
Comment on lines
+267
to
+292
| pq::FileMetaData fmd; | ||
| read_footer(cudf::io::datasource::create(filepath), &fmd); | ||
|
|
||
| // Make the statistics claim every value is 0, so a reader that trusts them prunes `a > 50` | ||
| std::vector<uint8_t> zero(sizeof(int64_t), 0); | ||
| auto& stats = fmd.row_groups[0].columns[0].meta_data.statistics; | ||
| stats.min = stats.max = stats.min_value = stats.max_value = zero; | ||
| if (logical_type.has_value()) { fmd.schema[1].logical_type = *logical_type; } | ||
|
|
||
| std::vector<uint8_t> footer; | ||
| pq::detail::CompactProtocolWriter{&footer}.write(fmd); | ||
|
|
||
| std::ifstream in(filepath, std::ios::binary); | ||
| std::vector<char> bytes((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>()); | ||
| uint32_t old_len; | ||
| std::memcpy(&old_len, bytes.data() + bytes.size() - 8, sizeof(old_len)); | ||
| bytes.resize(bytes.size() - 8 - old_len); | ||
| bytes.insert(bytes.end(), footer.begin(), footer.end()); | ||
| auto const new_len = static_cast<uint32_t>(footer.size()); | ||
| bytes.insert(bytes.end(), | ||
| reinterpret_cast<char const*>(&new_len), | ||
| reinterpret_cast<char const*>(&new_len) + sizeof(new_len)); | ||
| bytes.insert(bytes.end(), {'P', 'A', 'R', '1'}); | ||
|
|
||
| auto const patched = temp_env->get_temp_filepath(name + ".parquet"); | ||
| std::ofstream(patched, std::ios::binary).write(bytes.data(), bytes.size()); |
Contributor
Author
There was a problem hiding this comment.
Once #25339 merges, this can use the shared edit_footer helper from parquet_common.hpp:
Suggested change
| pq::FileMetaData fmd; | |
| read_footer(cudf::io::datasource::create(filepath), &fmd); | |
| // Make the statistics claim every value is 0, so a reader that trusts them prunes `a > 50` | |
| std::vector<uint8_t> zero(sizeof(int64_t), 0); | |
| auto& stats = fmd.row_groups[0].columns[0].meta_data.statistics; | |
| stats.min = stats.max = stats.min_value = stats.max_value = zero; | |
| if (logical_type.has_value()) { fmd.schema[1].logical_type = *logical_type; } | |
| std::vector<uint8_t> footer; | |
| pq::detail::CompactProtocolWriter{&footer}.write(fmd); | |
| std::ifstream in(filepath, std::ios::binary); | |
| std::vector<char> bytes((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>()); | |
| uint32_t old_len; | |
| std::memcpy(&old_len, bytes.data() + bytes.size() - 8, sizeof(old_len)); | |
| bytes.resize(bytes.size() - 8 - old_len); | |
| bytes.insert(bytes.end(), footer.begin(), footer.end()); | |
| auto const new_len = static_cast<uint32_t>(footer.size()); | |
| bytes.insert(bytes.end(), | |
| reinterpret_cast<char const*>(&new_len), | |
| reinterpret_cast<char const*>(&new_len) + sizeof(new_len)); | |
| bytes.insert(bytes.end(), {'P', 'A', 'R', '1'}); | |
| auto const patched = temp_env->get_temp_filepath(name + ".parquet"); | |
| std::ofstream(patched, std::ios::binary).write(bytes.data(), bytes.size()); | |
| std::ifstream in(filepath, std::ios::binary); | |
| std::vector<char> bytes((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>()); | |
| edit_footer(bytes, [&](pq::FileMetaData& fmd) { | |
| // Make the statistics claim every value is 0, so a reader that trusts them prunes `a > 50` | |
| std::vector<uint8_t> zero(sizeof(int64_t), 0); | |
| auto& stats = fmd.row_groups[0].columns[0].meta_data.statistics; | |
| stats.min = stats.max = stats.min_value = stats.max_value = zero; | |
| if (logical_type.has_value()) { fmd.schema[1].logical_type = *logical_type; } | |
| }); | |
| auto const patched = temp_env->get_temp_filepath(name + ".parquet"); | |
| std::ofstream(patched, std::ios::binary).write(bytes.data(), bytes.size()); |
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Implements the fallback for unrecognized logical/physical type combinations from parquet-format#606.
This PR drops the logical annotation on a leaf column whose logical type is unrecognized or invalid for its physical type (e.g.
INTEGER(32)onINT64,DECIMALonBOOLEAN), and reads it as plain physical data. Min/max statistics of such columns are ignored in row-group and page-index filtering so they cannot prune using an ordering we don't understand. The check lives inmetadata::sanitize_schema()so both the regular and hybrid scan readers get it.Checklist