Skip to main content

guard_expr

Function guard_expr 

Source
pub fn guard_expr(expr: Expr, schema: Option<&Schema>) -> Expr
Expand description

expr with every operation that would panic on a date past the calendar replaced by one that does not: casts to text and concat_str go through text_expr, dt.to_string through format_expr, and the date parts read from calendar_expr. With schema, the one expr is evaluated against, only operations on a date or ms/us datetime are replaced and every other plan stays as Polars built it; without it, each is replaced, and the replacement casts any other type as Polars would. A date that meets text in a coalesce or a when/then/otherwise, which Polars casts to text itself, goes through text_expr too, but only with schema, which says the result is text. Date math that overflows near the ends of the nanosecond range reads from ns_edge_expr. A date cast to a datetime, or met with one in a coalesce, a when/then/otherwise, fill_null or a horizontal min or max (the last ones only with schema), goes through countable_expr.