Skip to content

yggdrasil.execution.expr.backends.polars_backend

polars_backend

polars.Expr emitter + best-effort lifter.

:func:to_polars translates the AST to a :class:polars.Expr — suitable as the predicate of :meth:polars.DataFrame.filter / :meth:polars.LazyFrame.filter. Output uses native polars operators so optimization (predicate pushdown, projection pruning) kicks in.

:func:from_polars parses a polars expression's serialized form back into our AST. Polars exposes Expr.meta.serialize() / Expr.meta.tree_format() for introspection — the lifter walks the tree-format output. Anything beyond comparisons + boolean combinators raises :class:NotImplementedError.

to_polars

to_polars(expr: Expression)

Emit expr as a :class:polars.Expr.

from_polars

from_polars(pl_expr) -> Expression

Lift a :class:polars.Expr back into our AST.

Uses Expr.meta.serialize(format="json") (polars ≥ 0.20). Older polars versions raise :class:NotImplementedError — upgrade or carry the original :class:Expression through the pipeline.