pub fn no_limit_order_by_union(expr: Expression) -> Result<Expression>Expand description
Wrap UNION with ORDER BY/LIMIT in a subquery.
Some dialects (ClickHouse, TSQL) don’t support ORDER BY/LIMIT directly on UNION. This transform converts: SELECT … UNION SELECT … ORDER BY x LIMIT n to: SELECT * FROM (SELECT … UNION SELECT …) AS _l_0 ORDER BY x LIMIT n
NOTE: Our parser may place ORDER BY/LIMIT on the right-hand SELECT rather than the Union (unlike Python sqlglot). This function handles both cases by checking the right-hand SELECT for trailing ORDER BY/LIMIT and moving them to the Union.