pub fn move_ctes_to_top_level(expr: Expression) -> Result<Expression>Expand description
Move CTEs to the top level of the query.
Some dialects (e.g., Hive, T-SQL, Spark prior to version 3) only allow CTEs to be defined at the top-level, so for example queries like:
SELECT * FROM (WITH t(c) AS (SELECT 1) SELECT * FROM t) AS subqare invalid in those dialects. This transformation moves all CTEs to the top level.
Reference: transforms.py:664-700