diff --git a/datafusion/core/tests/dataframe/dataframe_functions.rs b/datafusion/core/tests/dataframe/dataframe_functions.rs index 3a1f919bc51e..8d851f83152c 100644 --- a/datafusion/core/tests/dataframe/dataframe_functions.rs +++ b/datafusion/core/tests/dataframe/dataframe_functions.rs @@ -1112,15 +1112,15 @@ async fn test_fn_map() -> Result<()> { vec![lit(1), lit(2), lit(3)], ); let expected = [ - "+-------------------------------------------------------------------------------------------+", - "| map_one(make_array(Utf8(\"a\"),Utf8(\"b\"),Utf8(\"c\")),make_array(Int32(1),Int32(2),Int32(3))) |", - "+-------------------------------------------------------------------------------------------+", - "| {a: 1, b: 2, c: 3} |", - "| {a: 1, b: 2, c: 3} |", - "| {a: 1, b: 2, c: 3} |", - "| {a: 1, b: 2, c: 3} |", - "+-------------------------------------------------------------------------------------------+", - ]; + "+-------------------------------------------------------------------+", + "| map_one(Utf8(\"a\"),Utf8(\"b\"),Utf8(\"c\"),Int32(1),Int32(2),Int32(3)) |", + "+-------------------------------------------------------------------+", + "| {a: 1, b: 2, c: 3} |", + "| {a: 1, b: 2, c: 3} |", + "| {a: 1, b: 2, c: 3} |", + "| {a: 1, b: 2, c: 3} |", + "+-------------------------------------------------------------------+", + ]; assert_fn_batches!(expr, expected); Ok(()) } diff --git a/datafusion/functions-array/src/map.rs b/datafusion/functions-array/src/map.rs index 840dcb25e3f2..5d7ea235bac9 100644 --- a/datafusion/functions-array/src/map.rs +++ b/datafusion/functions-array/src/map.rs @@ -30,10 +30,10 @@ pub fn map(keys: Vec, values: Vec) -> Expr { } pub fn map_from_array(keys: Vec, values: Vec) -> Expr { - let keys = make_array(keys); - let values = make_array(values); + let mut args = keys; + args.extend(values); Expr::ScalarFunction(ScalarFunction::new_udf( map_one_udf(), - vec![keys, values], + args, )) } diff --git a/datafusion/functions/src/core/map.rs b/datafusion/functions/src/core/map.rs index 834061372c85..71008c71a0a3 100644 --- a/datafusion/functions/src/core/map.rs +++ b/datafusion/functions/src/core/map.rs @@ -64,7 +64,6 @@ fn make_map_batch_one_args(args: &[ColumnarValue]) -> Result { let val_iter = args[len..].iter().map(get_scalar_from_col); let value = ScalarValue::iter_to_array(val_iter)?; - let key = get_first_element(key); let value = get_first_element(value); let can_evaluate_to_const = can_evaluate_to_const(args);