Expand description
AST transform helpers and convenience getters.
This module provides functions for common AST mutations (adding WHERE clauses, setting LIMIT/OFFSET, renaming columns/tables) and read-only extraction helpers (getting column names, table names, functions, etc.).
Mutation functions take an owned Expression and return a new Expression.
Read-only getters take &Expression.
Functionsยง
- add_
select_ columns - Append columns to the SELECT list of a query.
- add_
where - Add a condition to the WHERE clause.
- get_
aggregate_ functions - Collect all aggregate function nodes in the expression tree.
- get_
column_ names - Collect all column names (as
String) referenced in the expression tree. - get_
functions - Collect all function call nodes in the expression tree.
- get_
identifiers - Collect all identifier references in the expression tree.
- get_
literals - Collect all literal value nodes in the expression tree.
- get_
subqueries - Collect all subquery nodes in the expression tree.
- get_
table_ names - Collect all table names (as
String) referenced in the expression tree. - get_
window_ functions - Collect all window function nodes in the expression tree.
- node_
count - Count the total number of AST nodes in the expression tree.
- qualify_
columns - Qualify all unqualified column references with the given
table_name. - remove_
limit_ offset - Remove both LIMIT and OFFSET from a SELECT.
- remove_
nodes - Remove (replace with a
Null) all nodes matchingpredicate. - remove_
select_ columns - Remove columns from the SELECT list where
predicatereturnstrue. - remove_
where - Remove the WHERE clause from a SELECT.
- rename_
columns - Rename columns throughout the expression tree using the provided mapping.
- rename_
tables - Rename tables throughout the expression tree using the provided mapping.
- replace_
by_ type - Replace nodes matching
predicateby applyingreplacerto the matched node. - replace_
nodes - Replace nodes matching
predicatewithreplacement(cloned for each match). - set_
distinct - Set or remove the DISTINCT flag on a SELECT.
- set_
limit - Set the LIMIT on a SELECT.
- set_
offset - Set the OFFSET on a SELECT.