jayzhan211 commented on code in PR #11452:
URL: https://github.com/apache/datafusion/pull/11452#discussion_r1676984126
##########
datafusion/functions-array/src/planner.rs:
##########
@@ -97,6 +98,27 @@ impl ExprPlanner for ArrayFunctionPlanner {
) -> Result<PlannerResult<Vec<Expr>>> {
Ok(PlannerResult::Planned(make_array(exprs)))
}
+
+ fn plan_make_map(&self, args: Vec<Expr>) ->
Result<PlannerResult<Vec<Expr>>> {
+ if args.len() % 2 != 0 {
+ return exec_err!("make_map requires an even number of arguments");
+ }
+
+ let (keys, values): (Vec<_>, Vec<_>) = args
Review Comment:
It is possible to avoid clone
```suggestion
let (keys, values): (Vec<_>, Vec<_>) =
args.into_iter().enumerate().partition(|(i, _)| i % 2 == 0);
let keys = make_array(keys.into_iter().map(|(_, expr)|
expr).collect());
let values = make_array(values.into_iter().map(|(_, expr)|
expr).collect());
```
--
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]