# Class: CTENormalizer
Defined in: packages/core/src/transformers/CTENormalizer.ts:20
CTENormalizer is responsible for normalizing Common Table Expressions (CTEs) within SQL queries. It collects all CTEs from various parts of the query and consolidates them into a single WITH clause at the root level of the query.
This implementation uses:
- CommonTableCollector - to gather all CTEs from the query structure
- WithClauseDisabler - to remove all original WITH clauses from the query
- CTENameConflictResolver - to resolve name conflicts among CTEs and sort them properly
Methods
normalize()
static
normalize(query
):SelectQuery
Defined in: packages/core/src/transformers/CTENormalizer.ts:34
Normalizes a SQL query by consolidating all CTEs into a single WITH clause at the root level of the query.
Parameters
query
The query to normalize
Returns
A new normalized query with all CTEs at the root level