You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ap...@apache.org on 2023/06/20 17:58:50 UTC
[arrow] branch main updated: GH-36176: [C++] Fix regression for single-key Table sorting (#36179)
This is an automated email from the ASF dual-hosted git repository.
apitrou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new 8a4c19bd65 GH-36176: [C++] Fix regression for single-key Table sorting (#36179)
8a4c19bd65 is described below
commit 8a4c19bd65039b5f182c3335e38cc266a262d29d
Author: Ben Harkins <60...@users.noreply.github.com>
AuthorDate: Tue Jun 20 13:58:44 2023 -0400
GH-36176: [C++] Fix regression for single-key Table sorting (#36179)
### Rationale for this change
Fixes a regression introduced in https://github.com/apache/arrow/pull/35727.
### What changes are included in this PR?
Re-implements a branch in the `Table` sorter that defers to the `ChunkedArray` sorter for single sort keys.
### Are these changes tested?
Covered by existing tests.
### Are there any user-facing changes?
No.
* Closes: #36176
Authored-by: benibus <bp...@gmx.com>
Signed-off-by: Antoine Pitrou <an...@python.org>
---
cpp/src/arrow/compute/kernels/vector_sort.cc | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/cpp/src/arrow/compute/kernels/vector_sort.cc b/cpp/src/arrow/compute/kernels/vector_sort.cc
index 5ee8cbaf6e..b58244ad6e 100644
--- a/cpp/src/arrow/compute/kernels/vector_sort.cc
+++ b/cpp/src/arrow/compute/kernels/vector_sort.cc
@@ -1012,6 +1012,17 @@ class SortIndicesMetaFunction : public MetaFunction {
if (n_sort_keys == 0) {
return Status::Invalid("Must specify one or more sort keys");
}
+ if (n_sort_keys == 1) {
+ // The single-key approach here differs from the record batch one as pre-resolving
+ // the table sort keys involves processing the table into batches, which we don't
+ // need to do here.
+ ARROW_ASSIGN_OR_RAISE(
+ auto chunked_array,
+ PrependInvalidColumn(options.sort_keys[0].target.GetOneFlattened(table)));
+ if (chunked_array->type()->id() != Type::STRUCT) {
+ return SortIndices(*chunked_array, options, ctx);
+ }
+ }
auto out_type = uint64();
auto length = table.num_rows();