jayzhan211 commented on code in PR #12259:
URL: https://github.com/apache/datafusion/pull/12259#discussion_r1739942171


##########
datafusion/functions/src/core/getfield.rs:
##########
@@ -184,9 +184,25 @@ impl ScalarUDFImpl for GetFieldFunc {
         };
 
         match (array.data_type(), name) {
-            (DataType::Map(_, _), ScalarValue::Utf8(Some(k))) => {
+            (DataType::Map(_, _), name) => {
                 let map_array = as_map_array(array.as_ref())?;
-                let key_scalar: 
Scalar<arrow::array::GenericByteArray<arrow::datatypes::GenericStringType<i32>>>
 = Scalar::new(StringArray::from(vec![k.clone()]));
+                if !matches!(name, ScalarValue::Utf8(_) | 
ScalarValue::Int64(_) | ScalarValue::Float64(_)) {
+                    return exec_err!(
+                "get indexed field is only possible on map with utf8, int64 
and float64 indexes. \
+                             Tried with {name:?} index")
+                }
+
+                let mut key_array: ArrayRef = name.to_array()?;
+                if key_array.data_type() != map_array.key_type() {
+                    let pre_cast_dt = key_array.data_type().clone();
+                    if 
arrow::compute::kernels::cast::can_cast_types(key_array.data_type(), 
map_array.key_type()) {

Review Comment:
   Casting and type check should be handled in Signature not `invoke`.



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