polars_plan/dsl/functions/coerce.rs
1use super::*;
2
3/// Take several expressions and collect them into a [`StructChunked`].
4/// # Panics
5/// panics if `exprs` is empty.
6pub fn as_struct(exprs: Vec<Expr>) -> Expr {
7 assert!(
8 !exprs.is_empty(),
9 "expected at least 1 field in 'as_struct'"
10 );
11 Expr::Function {
12 input: exprs,
13 function: FunctionExpr::AsStruct,
14 options: FunctionOptions {
15 collect_groups: ApplyOptions::ElementWise,
16 flags: FunctionFlags::default()
17 | FunctionFlags::PASS_NAME_TO_APPLY
18 | FunctionFlags::INPUT_WILDCARD_EXPANSION,
19 ..Default::default()
20 },
21 }
22}