-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Improve Parquet case-insensitive column selection semantics #22729
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e6abd9b
Add benchmark for Parquet filter name resolution and refactor column …
qbacpey e4b44c6
Adding peak memory usage logging and refactor column name mapping
qbacpey b62928a
Replacing references to reader_impl_helpers with column_path_helpers …
qbacpey 127f0b8
Replace code with `cudf::ast::tree`
qbacpey a5a6730
Update comments
qbacpey b2153c9
Address reviews
qbacpey c336e0a
Address reviews
qbacpey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #include "column_path_helpers.hpp" | ||
|
|
||
| #include <algorithm> | ||
| #include <cctype> | ||
| #include <cstddef> | ||
| #include <functional> | ||
| #include <string> | ||
| #include <string_view> | ||
|
|
||
| namespace cudf::io::parquet::detail { | ||
|
|
||
| std::string normalize_column_path(std::string_view col_path, bool case_sensitive_names) | ||
| { | ||
| if (case_sensitive_names) { return std::string{col_path}; } | ||
| auto normalized_path = std::string(col_path.size(), '\0'); | ||
| std::transform(col_path.begin(), col_path.end(), normalized_path.begin(), [](unsigned char c) { | ||
| return std::tolower(c); | ||
| }); | ||
| return normalized_path; | ||
| } | ||
|
|
||
| bool are_column_paths_equal(std::string_view lhs, std::string_view rhs, bool case_sensitive) | ||
| { | ||
| if (lhs.size() != rhs.size()) { return false; } | ||
| if (case_sensitive) { return lhs == rhs; } | ||
| // Optimize by normalizing and comparing char-by-char instead of whole strings | ||
| return std::equal( | ||
| lhs.begin(), lhs.end(), rhs.begin(), [](unsigned char lhs_char, unsigned char rhs_char) { | ||
| return std::equal_to<>{}(std::tolower(lhs_char), std::tolower(rhs_char)); | ||
| }); | ||
| } | ||
|
|
||
| std::size_t column_path_hash::operator()(std::string_view path) const | ||
| { | ||
| return std::hash<std::string>{}(normalize_column_path(path, case_sensitive_names)); | ||
| } | ||
|
|
||
| bool column_path_equal::operator()(std::string_view lhs, std::string_view rhs) const | ||
| { | ||
| return are_column_paths_equal(lhs, rhs, case_sensitive_names); | ||
| } | ||
|
|
||
| column_path_set make_column_path_set(bool case_sensitive_names, std::size_t bucket_hint) | ||
| { | ||
| return column_path_set( | ||
| bucket_hint, column_path_hash{case_sensitive_names}, column_path_equal{case_sensitive_names}); | ||
| } | ||
|
|
||
| } // namespace cudf::io::parquet::detail |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <cstddef> | ||
| #include <string> | ||
| #include <string_view> | ||
| #include <unordered_map> | ||
| #include <unordered_set> | ||
|
|
||
| namespace cudf::io::parquet::detail { | ||
|
|
||
| /** | ||
| * @brief Returns a normalized (lowercased) column name or path when case-insensitive matching is | ||
| * enabled | ||
| * | ||
| * @param col_path The column name or path to normalize | ||
| * @param case_sensitive_names Whether to normalize the column path case-insensitively | ||
| * | ||
| * @return The normalized column path | ||
| */ | ||
| [[nodiscard]] std::string normalize_column_path(std::string_view col_path, | ||
| bool case_sensitive_names); | ||
|
|
||
| /** | ||
| * @brief Compares two column paths with specified case sensitivity | ||
| * | ||
| * @param lhs The left-hand side column path | ||
| * @param rhs The right-hand side column path | ||
| * @param case_sensitive Whether to compare the column paths case-sensitively | ||
| * | ||
| * @return Boolean indicating if the column paths are equal | ||
| */ | ||
| [[nodiscard]] bool are_column_paths_equal(std::string_view lhs, | ||
| std::string_view rhs, | ||
| bool case_sensitive); | ||
|
|
||
| /** | ||
| * @brief Transparent hash for column paths that honors a case-sensitivity policy. | ||
| * | ||
| * Hashes the column path according to `case_sensitive_names`, so that two paths that compare equal | ||
| * under `are_column_paths_equal` also hash equally. | ||
| */ | ||
| struct column_path_hash { | ||
| using is_transparent = void; | ||
| bool case_sensitive_names{true}; | ||
|
|
||
| std::size_t operator()(std::string_view path) const; | ||
| }; | ||
|
|
||
| /** | ||
| * @brief Transparent equality for column paths that honors a case-sensitivity policy. | ||
| * | ||
| * Delegates to `are_column_paths_equal`, keeping the comparison consistent with `column_path_hash`. | ||
| */ | ||
| struct column_path_equal { | ||
| using is_transparent = void; | ||
| bool case_sensitive_names{true}; | ||
|
qbacpey marked this conversation as resolved.
|
||
|
|
||
| bool operator()(std::string_view lhs, std::string_view rhs) const; | ||
| }; | ||
|
|
||
| /** | ||
| * @brief A set of column paths matched with a configurable case-sensitivity policy. | ||
| */ | ||
| using column_path_set = std::unordered_set<std::string, column_path_hash, column_path_equal>; | ||
|
|
||
| /** | ||
| * @brief Constructs an empty `column_path_set` whose hash/equality use the given policy. | ||
| * | ||
| * @param case_sensitive_names Whether column-path matching is case-sensitive | ||
| * @param bucket_hint Optional initial bucket count | ||
| * @return An empty `column_path_set` using the requested policy | ||
| */ | ||
| [[nodiscard]] column_path_set make_column_path_set(bool case_sensitive_names, | ||
| std::size_t bucket_hint = 0); | ||
|
|
||
| /** | ||
| * @brief A map keyed by column path matched with a configurable case-sensitivity policy. | ||
| */ | ||
| template <typename Value> | ||
| using column_path_map = std::unordered_map<std::string, Value, column_path_hash, column_path_equal>; | ||
|
|
||
| /** | ||
| * @brief Constructs an empty `column_path_map` whose hash/equality use the given policy. | ||
| * | ||
| * @tparam Value Mapped value type | ||
| * @param case_sensitive_names Whether column-path matching is case-sensitive | ||
| * @param bucket_hint Optional initial bucket count | ||
| * @return An empty `column_path_map` using the requested policy | ||
| */ | ||
| template <typename Value> | ||
| [[nodiscard]] column_path_map<Value> make_column_path_map(bool case_sensitive_names, | ||
| std::size_t bucket_hint = 0) | ||
| { | ||
| return column_path_map<Value>( | ||
| bucket_hint, column_path_hash{case_sensitive_names}, column_path_equal{case_sensitive_names}); | ||
| } | ||
|
|
||
| } // namespace cudf::io::parquet::detail | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.