Skip to main content

Module ast_transforms

Module ast_transforms 

Source
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 matching predicate.
remove_select_columns
Remove columns from the SELECT list where predicate returns true.
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 predicate by applying replacer to the matched node.
replace_nodes
Replace nodes matching predicate with replacement (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.