GH-45806: [C++][Statistics] Add array statistics schema support#50071
Open
cjc0013 wants to merge 2 commits into
Open
GH-45806: [C++][Statistics] Add array statistics schema support#50071cjc0013 wants to merge 2 commits into
cjc0013 wants to merge 2 commits into
Conversation
|
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends Arrow C++ statistics-schema support by adding an Array::MakeStatisticsArray() API and updating RecordBatch::MakeStatisticsArray() to enumerate statistics for nested child arrays using the IPC RecordBatch depth-first column index order, while preserving existing record-batch row-count behavior.
Changes:
- Added public C++ API
Array::MakeStatisticsArray()and shared the statistics-array construction path betweenArrayandRecordBatch. - Updated statistics enumeration to traverse
ArrayData::child_datafor nested statistics (depth-first column indexing). - Added unit tests covering
Array::MakeStatisticsArray()and nested field enumeration inRecordBatch::MakeStatisticsArray().
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| cpp/src/arrow/record_batch.cc | Refactors statistics enumeration into reusable helpers; adds nested traversal; implements Array::MakeStatisticsArray() and shared builder path. |
| cpp/src/arrow/record_batch_test.cc | Adds tests for the new Array API and nested-field statistics inclusion/order for record batches. |
| cpp/src/arrow/array/array_base.h | Declares the new public Array::MakeStatisticsArray() API with documentation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+595
to
+599
| Status EnumerateArrayStatistics(const std::shared_ptr<ArrayData>& data, | ||
| int32_t* nth_column, int* nth_statistics, | ||
| OnStatistics on_statistics, | ||
| bool include_exact_row_count = false) { | ||
| const auto current_column = (*nth_column)++; |
Comment on lines
+648
to
+650
| template <typename EnumerateStatisticsFunction> | ||
| Result<std::shared_ptr<Array>> MakeStatisticsArrayFromEnumerator( | ||
| EnumerateStatisticsFunction enumerate_statistics, MemoryPool* memory_pool) { |
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.
Rationale for this change
The statistics schema documentation describes statistics arrays for Arrow arrays and nested field column indexes, but C++ only exposed
RecordBatch::MakeStatisticsArray()and only enumerated top-level record batch columns.This leaves two related gaps:
Arrayto produce its statistics schema representation directly;RecordBatch::MakeStatisticsArray()drops statistics attached to nested child arrays.What changes are included in this PR?
Array::MakeStatisticsArray().ArrayandRecordBatch.ArrayData::child_datawhen enumerating record batch column statistics, using the same depth-first column index order described by the IPC record batch message rules.Are these changes tested?
Yes. Locally:
ninja arrow-table-test -j2./debug/arrow-table-test --gtest_filter="*MakeStatisticsArray*": 24 tests passed./debug/arrow-table-test: 181 tests passedAre there any user-facing changes?
Yes. This adds the public C++
Array::MakeStatisticsArray()API and letsRecordBatch::MakeStatisticsArray()include nested child-array statistics when present. This is not a breaking API change.Closes #45804.
Addresses part of #45474.
Refs #45806.