Skip to content

[SQL] Support RANK, ROW_NUMBER, DENSE_RANK even if not in a TopK pattern #3934

@ryzhyk

Description

@ryzhyk

I think these operators can be compiled into rolling aggregates, e.g.,

SELECT  rank() OVER (ORDER BY col),

can be

count(*) over (ORDER BY col RANGE BETWEEN UNBOUNDED PRECEDING and CURRENT ROW)

dense_rank corresponds to count(distinct).

row_number however is more tricky with non-unit weights, so that one may still need a custom implementation.

Metadata

Metadata

Assignees

Labels

DBSP coreRelated to the core DBSP librarySQL compilerRelated to the SQL compiler

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions