-
Notifications
You must be signed in to change notification settings - Fork 976
Add an example to inspect parquet files and dump row group and page level metadata information #20117
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
rapids-bot
merged 10 commits into
rapidsai:branch-25.12
from
mhaseeb123:fea/parquet-inspect-example
Oct 2, 2025
Merged
Add an example to inspect parquet files and dump row group and page level metadata information #20117
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c27caea
Add parquet inspect example
mhaseeb123 b1de519
Style fix
mhaseeb123 0d7c198
Merge branch 'branch-25.12' into fea/parquet-inspect-example
mhaseeb123 c4f680c
Merge branch 'branch-25.12' into fea/parquet-inspect-example
mhaseeb123 be81fec
Apply suggestions from code review
mhaseeb123 9403508
Merge branch 'branch-25.12' into fea/parquet-inspect-example
mhaseeb123 dd77046
Add example to the CI
mhaseeb123 65bcdd5
Minor typo fix
mhaseeb123 0d12fb1
Merge branch 'branch-25.12' into fea/parquet-inspect-example
mhaseeb123 d16afc4
Merge branch 'branch-25.12' into fea/parquet-inspect-example
mhaseeb123 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,42 @@ | ||
# Copyright (c) 2024-2025, NVIDIA CORPORATION. | ||
|
||
cmake_minimum_required(VERSION 3.30.4 FATAL_ERROR) | ||
|
||
include(../set_cuda_architecture.cmake) | ||
|
||
# initialize cuda architecture | ||
rapids_cuda_init_architectures(parquet_inspect) | ||
|
||
project( | ||
parquet_inspect | ||
VERSION 0.0.1 | ||
LANGUAGES CXX CUDA | ||
) | ||
|
||
include(../fetch_dependencies.cmake) | ||
|
||
include(rapids-cmake) | ||
rapids_cmake_build_type("Release") | ||
|
||
# For now, disable CMake's automatic module scanning for C++ files. There is an sccache bug in the | ||
# version RAPIDS uses in CI that causes it to handle the resulting -M* flags incorrectly with | ||
# gcc>=14. We can remove this once we upgrade to a newer sccache version. | ||
set(CMAKE_CXX_SCAN_FOR_MODULES OFF) | ||
|
||
add_library(parquet_inspect_utils OBJECT parquet_inspect_utils.cpp) | ||
target_compile_features(parquet_inspect_utils PRIVATE cxx_std_20) | ||
target_link_libraries(parquet_inspect_utils PRIVATE cudf::cudf) | ||
|
||
# Build and install parquet_inspect | ||
add_executable(parquet_inspect parquet_inspect.cpp) | ||
target_link_libraries( | ||
parquet_inspect PRIVATE cudf::cudf $<BUILD_LOCAL_INTERFACE:nvtx3::nvtx3-cpp> | ||
$<TARGET_OBJECTS:parquet_inspect_utils> | ||
) | ||
target_compile_features(parquet_inspect PRIVATE cxx_std_20) | ||
install(TARGETS parquet_inspect DESTINATION bin/examples/libcudf/parquet_inspect) | ||
|
||
# Install the example.parquet file | ||
install(FILES ${CMAKE_CURRENT_LIST_DIR}/example.parquet | ||
DESTINATION bin/examples/libcudf/parquet_inspect | ||
) |
Binary file not shown.
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,106 @@ | ||
/* | ||
* Copyright (c) 2025, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "parquet_inspect_utils.hpp" | ||
|
||
#include <cudf/io/parquet_schema.hpp> | ||
#include <cudf/io/types.hpp> | ||
|
||
#include <rmm/cuda_stream_view.hpp> | ||
|
||
#include <filesystem> | ||
#include <iostream> | ||
#include <string> | ||
|
||
/** | ||
* @file parquet_inspect.cpp | ||
* @brief Inspects a parquet file and writes two parquet files containing row group and page | ||
* metadata respectively. | ||
*/ | ||
|
||
namespace { | ||
|
||
/** | ||
* @brief Function to print example usage and argument information. | ||
*/ | ||
void print_usage() | ||
{ | ||
std::cout << "\nUsage: parquet_inspect <input parquet file> <output path>\n\n"; | ||
} | ||
|
||
} // namespace | ||
|
||
/** | ||
* @brief Main for parquet_inspect examples | ||
* | ||
* Command line parameters: | ||
* 1. parquet input file name (default: "example.parquet") | ||
* 2. parquet output path (default: "$pwd") | ||
* | ||
* Example invocation from directory `cudf/cpp/examples/parquet_inspect`: | ||
* ./build/parquet_inspect example.parquet ./ | ||
*/ | ||
int main(int argc, char const** argv) | ||
{ | ||
std::string input_filepath = "example.parquet"; | ||
std::string output_path = std::filesystem::current_path().string(); | ||
std::optional<cudf::io::statistics_freq> page_stats = std::nullopt; | ||
|
||
switch (argc) { | ||
case 3: output_path = argv[2]; [[fallthrough]]; | ||
case 2: // Check if instead of input_paths, the first argument is `-h` or `--help` | ||
{ | ||
auto const arg = std::string{argv[1]}; | ||
if (arg == "-h" or arg == "--help") { | ||
print_usage(); | ||
return 0; | ||
} else if (arg != "-h" and arg != "--help") { | ||
input_filepath = std::filesystem::absolute(arg).string(); | ||
break; | ||
} | ||
[[fallthrough]]; | ||
} | ||
default: print_usage(); throw std::runtime_error("Invalid arguments"); | ||
} | ||
|
||
CUDF_EXPECTS( | ||
std::filesystem::exists(input_filepath) and std::filesystem::is_regular_file(input_filepath), | ||
"Input file '" + input_filepath + "' does not exist or is not a regular file.", | ||
std::invalid_argument); | ||
|
||
auto const filename = std::filesystem::path(input_filepath).stem().string(); | ||
|
||
auto const stream = cudf::get_default_stream(); | ||
auto const mr = create_memory_resource(true); | ||
cudf::set_current_device_resource(mr.get()); | ||
|
||
// Read parquet footer metadata | ||
auto [metadata, has_page_index] = read_parquet_file_metadata(input_filepath); | ||
|
||
// Write row group metadata | ||
auto output_filepath = output_path + "/" + filename + ".rowgroups.parquet"; | ||
write_rowgroup_metadata(metadata, output_filepath, stream); | ||
|
||
// Write page metadata | ||
if (has_page_index) { | ||
auto output_filepath = output_path + "/" + filename + ".pages.parquet"; | ||
write_page_metadata(metadata, output_filepath, stream); | ||
} | ||
|
||
stream.synchronize(); | ||
|
||
return 0; | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified from the CMakeLists.txt in
parquet_io
example