Skip to main content

Module parser

Module parser 

Source
Expand description

SQL expression text โ†’ SqlExpr AST parser.

Parses the subset of SQL expressions used in GENERATED ALWAYS AS (expr) column definitions. Supports:

  • Column references: price, tax_rate
  • Numeric literals: 42, 3.14, -1
  • String literals: 'hello', ''escaped''
  • Binary operators: +, -, *, /, %
  • Comparison: =, !=, <>, <, >, <=, >=
  • Logical: AND, OR, NOT
  • Parenthesized sub-expressions: (a + b) * c
  • Function calls: ROUND(price * 1.08, 2), CONCAT(a, ' ', b)
  • COALESCE: COALESCE(a, b, '')
  • CASE WHEN: CASE WHEN x > 0 THEN 'positive' ELSE 'non-positive' END
  • NULL literal

Determinism validation: rejects NOW(), RANDOM(), NEXTVAL(), UUID().

Functionsยง

parse_generated_expr
Parse a SQL expression string into an SqlExpr AST.