Skip to content

yggdrasil.execution.expr.backends.pyarrow_backend

pyarrow_backend

pyarrow.compute.Expression emitter + best-effort lifter.

:func:to_pyarrow translates the AST to a :class:pyarrow.compute.Expression. Output is suitable as the filter= argument on :class:pyarrow.dataset.Dataset.scanner / :meth:pyarrow.Table.filter, the typical "push the predicate down to Arrow" surface.

:func:from_pyarrow walks a pyarrow expression back into our AST on a best-effort basis. pyarrow's expression introspection is limited to a few well-known function names (equal, less_equal, is_in, and_kleene, or_kleene, invert, is_null); anything outside that set raises :class:NotImplementedError.

to_pyarrow

to_pyarrow(expr: Expression)

Emit expr as a :class:pyarrow.compute.Expression.

from_pyarrow

from_pyarrow(arrow_expr) -> Expression

Walk a :class:pyarrow.compute.Expression back into our AST.

Limited by what the public pyarrow API exposes — the expression-tree structure isn't stable across versions, so this lifter handles the common shapes (column refs, literals, boolean combinators, comparisons, is_null, isin) and raises :class:NotImplementedError for anything else. Callers that need a richer round-trip should keep the original :class:Expression and emit fresh.