goldmedal commented on code in PR #11361:
URL: https://github.com/apache/datafusion/pull/11361#discussion_r1674992933


##########
datafusion/functions/src/core/map.rs:
##########
@@ -235,6 +203,25 @@ impl ScalarUDFImpl for MakeMap {
             }
         }
 
+        let mut result = Vec::new();
+        for _ in 0..arg_types.len() / 2 {
+            result.push(key_type.clone());
+            result.push(value_type.clone());

Review Comment:
   No, I think it works well because the following case is passed.
   ```
   query ?
   SELECT MAP(['POST', 'HEAD', 'PATCH'], [41, 33, null]);
   ----
   {POST: 41, HEAD: 33, PATCH: }
   ```
   
   Because the type of all values or all keys should be the same, after the 
type checking, I build a new vec based on the final key type and final value 
type. In this case, the original types are
   ```
   [DataType::Utf8, DataType::Int32, DataType::Utf8,, DataType::Int32, 
DataType::Utf8,, DataType::Null]
   ```
   It would be transformed to 
   ```
   [DataType::Utf8, DataType::Int32, DataType::Utf8,, DataType::Int32, 
DataType::Utf8,, DataType::Int32]
   ```
   
   So, I think we can get `Int32(Null)` when invoking, and then create a 
type-correct null array for it.
   



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