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


##########
cpp/src/arrow/compute/exec.cc:
##########
@@ -783,7 +783,14 @@ class ScalarExecutor : public 
KernelExecutorImpl<ScalarKernel> {
   Status Execute(const ExecBatch& batch, ExecListener* listener) override {
     RETURN_NOT_OK(span_iterator_.Init(batch, 
exec_context()->exec_chunksize()));
 
-    if (batch.length == 0) {
+    // A dictionary-to-dictionary cast must run to preserve unreferenced 
dictionary
+    // values even when there are no indices to process.
+    const bool changes_dictionary_type =
+        batch.num_values() == 1 && batch.values[0].type() != nullptr &&
+        is_dictionary(batch.values[0].type()->id()) &&
+        is_dictionary(output_type_.type->id()) &&
+        !batch.values[0].type()->Equals(*output_type_.type);

Review Comment:
   This looks... weird. Why the type unequality condition?
   
   Also, this will trigger on every scalar compute function, not just the cast 
function.



-- 
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