alamb commented on code in PR #14712:
URL: https://github.com/apache/datafusion/pull/14712#discussion_r1958147867


##########
datafusion/functions-nested/src/planner.rs:
##########
@@ -166,6 +169,17 @@ impl ExprPlanner for FieldAccessPlanner {
                             ),
                         )))
                     }
+                    // special case for map access with

Review Comment:
   the comment seems to be unfinished. Maybe the with is extraneous?
   
   ```suggestion
                       // special case for map access
   ```



##########
datafusion/sqllogictest/test_files/map.slt:
##########
@@ -592,6 +592,24 @@ select map_extract(column1, 1), map_extract(column1, 5), 
map_extract(column1, 7)
 [NULL] [NULL] [[1, NULL, 3]]
 [NULL] [NULL] [NULL]
 
+query ?

Review Comment:
   Could you also please add some error tests  for out of bounds access. For 
example,  `column[0]`, `column[-1]` and `column[1000]` to test the boundary 
condidtions?
   
   
   Also, it seems like the code in this PR supports queries like 
   
   ```sql
   select column1[column2]
   ```
   
   where column2 is an array of integer as well
   
   Can you also add a test for that syntax as well?
   
   



##########
datafusion/functions/src/core/getfield.rs:
##########
@@ -194,39 +185,54 @@ impl ScalarUDFImpl for GetFieldFunc {
             }
         };
 
+        fn process_map_array<K>(
+            array: Arc<dyn Array>,
+            key_scalar: Scalar<K>,
+        ) -> Result<ColumnarValue>
+        where
+            K: Array + 'static,
+        {
+            let map_array = as_map_array(array.as_ref())?;
+            let keys = arrow::compute::kernels::cmp::eq(&key_scalar, 
map_array.keys())?;
+
+            let original_data = map_array.entries().column(1).to_data();
+            let capacity = Capacities::Array(original_data.len());
+            let mut mutable =
+                MutableArrayData::with_capacities(vec![&original_data], true, 
capacity);
+
+            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 maybe_matched = keys
+                    .slice(start, end - start)
+                    .iter()
+                    .enumerate()
+                    .find(|(_, t)| t.unwrap());

Review Comment:
   I don't understand why this panic is never called, but then I see you just 
moved the code



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