Module expr

Module expr 

Source
Expand description

Expression DSL for metadata filtering

Otters exposes a small, ergonomic expression DSL for describing metadata predicates that can be pushed down into pruning and row-level filtering. Build expressions with col("name") and combine them with & (AND) and | (OR). Expressions are type-checked and compiled against your schema before being evaluated.

§Examples

use otters::expr::col;

// price <= 40 AND version >= 2
let e1 = col("price").lte(40.0) & col("version").gte(2);

// (age < 18 OR age > 65) AND name != "alice"
let e2 = (col("age").lt(18) | col("age").gt(65)) & col("name").neq("alice");

// string equality OR equality
let e3 = col("grade").eq("A") | col("grade").eq("B");

§Datatypes and operators

  • String: Eq / Neq only
  • Int32 / Int64: Eq / Neq / Lt / Lte / Gt / Gte with integer literals
  • Float32 / Float64: same operators with float or integer literals
  • DateTime: same operators with a parseable datetime string (RFC3339/ISO8601, YYYY-MM-DD, YYYY-MM-DD HH:MM:SS)

§Compiling

Call Expr::compile(&schema) to type-check the expression against your column types and obtain a CompiledFilter plan used internally by the engine for fast pruning.

Structs§

CompiledFilter
Compiled expression that is ready to be evaluated.

Enums§

CmpOp
Comparison operator used in expression leaves.
ColumnFilter
A compiled, typed column filter used at evaluation time.
Expr
ExprError
Errors returned while compiling expressions to a filter plan.
Literal
NumericLiteral

Functions§

col
Builder for a column reference (polars-like DSL).
lit
Builder for a literal value.

Type Aliases§

Plan
Filter plan representation used by the expression compiler.