pub fn eliminate_distinct_on(expr: Expression) -> Result<Expression>Expand description
Eliminate DISTINCT ON clause by converting to a subquery with ROW_NUMBER
DISTINCT ON is PostgreSQL-specific. For dialects that don’t support it, this converts it to a subquery with a ROW_NUMBER() window function.
Converts:
SELECT DISTINCT ON (a) a, b FROM t ORDER BY a, bTo:
SELECT a, b FROM (
SELECT a, b, ROW_NUMBER() OVER (PARTITION BY a ORDER BY a, b) AS _row_number
FROM t
) _t WHERE _row_number = 1Reference: transforms.py:138-191