GH-47252: [C++][Compute] Fix sort_indices for temporal types in arrow::Table.#50270
Open
nfrmtk wants to merge 2 commits into
Open
GH-47252: [C++][Compute] Fix sort_indices for temporal types in arrow::Table.#50270nfrmtk wants to merge 2 commits into
nfrmtk wants to merge 2 commits into
Conversation
|
|
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a crash in compute::SortIndices / Table::sort_by when sorting arrow::Table columns with temporal logical types (e.g., timestamp), by ensuring per-batch sort-key arrays are converted to their physical representation before comparator-based merges.
Changes:
- Convert flattened per-record-batch sort-key arrays to the physical type (
GetPhysicalType+GetPhysicalArray) when constructingResolvedTableSortKeychunks. - Add a regression test covering
Tablemulti-key sorting on timestamp columns across multiple JSON chunks (record batches).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| cpp/src/arrow/compute/kernels/vector_sort_internal.h | Ensure table sort-key chunks use physical array types to prevent comparator downcast crashes for temporal logical types. |
| cpp/src/arrow/compute/kernels/vector_sort_test.cc | Add regression coverage for Table sort indices on timestamp keys across multiple chunks and null placement variants. |
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
I was unable to use compute::SortIndices with timestamp type because of crash.
What changes are included in this PR?
Fix. The issue was that comparator for merging record batches was not converting timestamp type to its physical variant.
so it crashed on null pointer reference on checked_cast result
Are these changes tested?
yes
Are there any user-facing changes?
This PR contains a "Critical Fix". (If the changes fix either (a) a security vulnerability, (b) a bug that caused incorrect or invalid data to be produced, or (c) a bug that causes a crash (even when the API contract is upheld), please provide explanation. If not, you can remove this.)
i've already provided, i suppose