pitrou commented on code in PR #50423:
URL: https://github.com/apache/arrow/pull/50423#discussion_r3628711154


##########
cpp/src/arrow/compute/kernels/pivot_internal.cc:
##########
@@ -75,6 +79,19 @@ struct ConcretePivotWiderKeyMapper : public 
PivotWiderKeyMapper {
       }
       Unreachable("Grouper doesn't agree with std::unordered_set");
     }
+    // GH-48679: the fast grouper implementation may produce non-monotonic
+    // group ids, for example [0,1,2,4,3] rather than [0,1,2,3,4].
+    // Therefore, we need to produce a mapping a mapping of group ids to key 
indices.
+    auto key_indices_to_group_ids_data = key_indices_to_group_ids.array();
+    // InversePermutation doesn't allow unsigned integers, patch to signed.
+    DCHECK_EQ(key_indices_to_group_ids_data->type->id(), Type::UINT32);
+    key_indices_to_group_ids_data->type = int32();
+    ARROW_ASSIGN_OR_RAISE(group_ids_to_key_indices_,
+                          InversePermutation(key_indices_to_group_ids_data,
+                                             
InversePermutationOptions::Defaults(), ctx));
+    group_ids_to_key_indices_.array()->type = uint32();

Review Comment:
   Will do!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to