Skip to main content

eliminate_qualify

Function eliminate_qualify 

Source
pub fn eliminate_qualify(expr: Expression) -> Result<Expression>
Expand description

Eliminate QUALIFY clause by converting to a subquery with WHERE filter

QUALIFY is supported by Snowflake, BigQuery, and DuckDB but not by most other dialects.

Converts:

SELECT * FROM t QUALIFY ROW_NUMBER() OVER (...) = 1

To:

SELECT * FROM (SELECT *, ROW_NUMBER() OVER (...) AS _w FROM t) _t WHERE _w = 1

Reference: transforms.py:194-255