Skip to content

Commit

Permalink
remove make_array from map_from_array
Browse files Browse the repository at this point in the history
  • Loading branch information
goldmedal committed Jul 20, 2024
1 parent 81c8244 commit f43bd10
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
18 changes: 9 additions & 9 deletions datafusion/core/tests/dataframe/dataframe_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
6 changes: 3 additions & 3 deletions datafusion/functions-array/src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ pub fn map(keys: Vec<Expr>, values: Vec<Expr>) -> Expr {
}

pub fn map_from_array(keys: Vec<Expr>, values: Vec<Expr>) -> 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,
))
}
1 change: 0 additions & 1 deletion datafusion/functions/src/core/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ fn make_map_batch_one_args(args: &[ColumnarValue]) -> Result<ColumnarValue> {
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);
Expand Down

0 comments on commit f43bd10

Please sign in to comment.