Skip to main content

Module ast_helpers

Module ast_helpers 

Source
Expand description

Shared AST manipulation helpers for DML planners.

Functions§

find_foreign_qualifier
Walk expr and return the first qualifier on a table.col compound identifier that does not match any of valid_qualifiers. Used by the single-table WHERE planner to reject a table qualifier that refers to neither the table’s name nor its alias (e.g. WHERE wrong.name = ...) with a typed error, instead of silently stripping it into a bare field lookup that would never match any row.
flatten_and_expr
Flatten a right-leaning AND expression tree into a list of conjuncts.
qualified_ident_pair
Return (table, column) for a table.col compound identifier, or None.
rebuild_and_expr
Reassemble conjuncts into a right-leaning AND tree. Panics if empty.
strip_and_convert_filters
Strip qualifier. from all compound identifiers in expr, then convert the result to Vec<Filter> via convert_where_to_filters.
strip_single_table_qualifiers
Normalize a SINGLE-TABLE SELECT by stripping the (always-redundant) table qualifier from column refs in the projection, WHERE, and GROUP BY, returning a rewritten copy. t.col / alias.col collapse to col before the qualified name can become a literal "t.col" field-lookup string that no stored document ever has (silent zero-row / empty-value bug). A qualifier that matches neither the table’s name nor its alias is a typed error, never a silent match-nothing. Subquery bodies are intentionally not descended into (their qualifiers belong to their own tables).
strip_table_qualifier
Walk an expression and replace every table.col compound identifier where table == qualifier with a bare col identifier. Lets target-side predicates like t.score > 15 be evaluated against documents that store fields without a table qualifier.