Skip to main content

Module normalize_expr

Module normalize_expr 

Source
Expand description

Build NormalizedExpr values from pg_query AST nodes.

Phase-2 scope (per docs/superpowers/plans/phase-2-parser.md):

  • Strip redundant casts to a column’s own type. 42::integer for an integer column collapses to 42; 'foo'::text for a text column collapses to 'foo'.
  • Lowercase reserved keywords on the canonical text emitted by pg_query’s deparser.
  • Compute the BLAKE3 hash of the canonical text.

Deferred to follow-up phase-2 issues (only affect equivalence sensitivity, not correctness — equivalent inputs that exercise these may diff for now):

  • Paren folding (collapsing trivial nested A_Expr parens).
  • Sorting commutative operands of +, *, AND, OR.

Functions§

from_pg_node
Build a NormalizedExpr from a pg_query expression node.