Skip to main content

Module expr_util

Module expr_util 

Source
Expand description

Shared expression utilities for optimizer passes.

Provides:

  • SQL fragment parsing helpers (parse_predicate, parse_expr)
  • Expression rendering (render)
  • Conjunct splitting and joining (split_conjuncts, join_conjuncts)
  • Equi-join key extraction (equi_key)
  • Column-reference collection (collect_colrefs)
  • Canonical structural hashing (canonical_hash)
  • Common-subexpression detection (find_common_subexprs)

Structs§

ColRef
A qualified column reference extracted from an expression.

Functions§

canonical_hash
Compute a canonical (order-normalised) structural hash of an Expr.
collect_colrefs
Collect all column references reachable from e.
equi_key
If e is an equi-join predicate a.x = b.y (or x = y), return the two ColRefs. Returns None for any other expression shape.
find_common_subexprs
Find common (repeated) subexpressions in e by canonical hash.
join_conjuncts
Join a list of expressions with AND.
parse_expr
Parse a standalone SQL expression (not a WHERE predicate), returning None on failure.
parse_predicate
Parse a SQL predicate string into an Expr, returning None on failure.
render
Render an Expr back to a SQL string via its Display implementation.
split_conjuncts
Split a top-level AND expression into its conjuncts (leaves of the AND tree).