neilconway commented on code in PR #23966:
URL: https://github.com/apache/datafusion/pull/23966#discussion_r3675775369


##########
datafusion/physical-expr/src/expressions/binary/kernels.rs:
##########
@@ -280,12 +280,15 @@ pub(crate) fn regex_match_dyn_scalar(
                     "Data type {} not supported as a dictionary value type for 
operation 'regex_match_dyn_scalar' on string array",
                     other
                 ),
-            }.map(
+            }.and_then(
                 // downcast_dictionary_array duplicates code per possible key 
type, so we aim to do all prep work before
                 |evaluated_values| downcast_dictionary_array! {
                     left => {
-                        let unpacked_dict = 
evaluated_values.take_iter(left.keys().iter().map(|opt| opt.map(|v| v as 
_))).collect::<BooleanArray>();
-                        Arc::new(unpacked_dict) as ArrayRef
+                        Ok(arrow::compute::take(
+                            evaluated_values.as_ref(),

Review Comment:
   Might be worth adding a one-liner comment on why we use `take`?



##########
datafusion/physical-expr/src/expressions/binary/kernels.rs:
##########
@@ -280,12 +280,15 @@ pub(crate) fn regex_match_dyn_scalar(
                     "Data type {} not supported as a dictionary value type for 
operation 'regex_match_dyn_scalar' on string array",
                     other
                 ),
-            }.map(
+            }.and_then(
                 // downcast_dictionary_array duplicates code per possible key 
type, so we aim to do all prep work before
                 |evaluated_values| downcast_dictionary_array! {
                     left => {
-                        let unpacked_dict = 
evaluated_values.take_iter(left.keys().iter().map(|opt| opt.map(|v| v as 
_))).collect::<BooleanArray>();
-                        Arc::new(unpacked_dict) as ArrayRef
+                        Ok(arrow::compute::take(
+                            evaluated_values.as_ref(),
+                            left.keys(),
+                            None,
+                        )?)
                     },
                     _ => unreachable!(),

Review Comment:
   I don't think we need `downcast_dictionary_array!` anymore.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to