andygrove commented on code in PR #23537:
URL: https://github.com/apache/datafusion/pull/23537#discussion_r3604285784


##########
datafusion/functions/src/core/getfield.rs:
##########
@@ -129,22 +129,24 @@ fn process_map_array(
     let mut mutable =
         MutableArrayData::with_capacities(vec![&original_data], true, 
capacity);
 
+    let offsets = map_array.value_offsets();
+    // Scan the comparison result in place: slicing it per entry would allocate
+    // a new array for every row of the map.
+    let matches = keys.values();
+    let match_nulls = keys.nulls();
+
     for entry in 0..map_array.len() {
-        let start = map_array.value_offsets()[entry] as usize;
-        let end = map_array.value_offsets()[entry + 1] as usize;
+        let start = offsets[entry] as usize;
+        let end = offsets[entry + 1] as usize;
 
-        let maybe_matched = keys
-            .slice(start, end - start)
-            .iter()
-            .enumerate()
-            .find(|(_, t)| t.unwrap());
+        let matched = (start..end).find(|&i| {
+            matches.value(i) && match_nulls.is_none_or(|nulls| 
nulls.is_valid(i))

Review Comment:
   Good call — map keys are non-null by definition, so the comparison result 
never carries nulls here. Dropped the check to match the previous behavior 
(which unwrapped unconditionally). Done in c4ed51d.



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