MCPcopy Create free account
hub / github.com/apache/datafusion / plan_make_map

Method plan_make_map

datafusion/functions-nested/src/planner.rs:109–122  ·  view source on GitHub ↗
(&self, args: Vec<Expr>)

Source from the content-addressed store, hash-verified

107 }
108
109 fn plan_make_map(&self, args: Vec<Expr>) -> Result<PlannerResult<Vec<Expr>>> {
110 if !args.len().is_multiple_of(2) {
111 return plan_err!("make_map requires an even number of arguments");
112 }
113
114 let (keys, values): (Vec<_>, Vec<_>) =
115 args.into_iter().enumerate().partition(|(i, _)| i % 2 == 0);
116 let keys = make_array(keys.into_iter().map(|(_, e)| e).collect());
117 let values = make_array(values.into_iter().map(|(_, e)| e).collect());
118
119 Ok(PlannerResult::Planned(Expr::ScalarFunction(
120 ScalarFunction::new_udf(map_udf(), vec![keys, values]),
121 )))
122 }
123}
124
125#[derive(Debug)]

Callers 1

criterion_benchmarkFunction · 0.45

Calls 7

make_arrayFunction · 0.85
ScalarFunctionClass · 0.85
collectMethod · 0.80
lenMethod · 0.45
partitionMethod · 0.45
into_iterMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected