polars_plan/dsl/functions/
coerce.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use super::*;

/// Take several expressions and collect them into a [`StructChunked`].
/// # Panics
/// panics if `exprs` is empty.
pub fn as_struct(exprs: Vec<Expr>) -> Expr {
    assert!(
        !exprs.is_empty(),
        "expected at least 1 field in 'as_struct'"
    );
    Expr::Function {
        input: exprs,
        function: FunctionExpr::AsStruct,
        options: FunctionOptions {
            collect_groups: ApplyOptions::ElementWise,
            flags: FunctionFlags::default()
                | FunctionFlags::PASS_NAME_TO_APPLY
                | FunctionFlags::INPUT_WILDCARD_EXPANSION,
            ..Default::default()
        },
    }
}