Skip to content

[FEA] Support aggregate rolling expressions inside over() in cuDF-Polars #23623

Description

@rjzamora

cuDF-Polars should support composable range-rolling aggregate expressions inside
grouped over(...), such as sum().rolling(...).over(...),
mean().rolling(...).over(...), min().rolling(...).over(...), and
max().rolling(...).over(...).

def test_expr_agg_rolling_over(engine: GPUEngine) -> None:
    lf = pl.LazyFrame(
        {
            "g": ["A", "A", "B", "B"],
            "ts": [1, 2, 1, 2],
            "x": [10, 20, 30, 40],
        }
    ).sort("g", "ts")

    q = lf.select(
        pl.col("x").sum().rolling("ts", period="2i").over("g"),
        pl.col("x").min().rolling("ts", period="2i").over("g"),
    )

    assert_gpu_result_equal(q, engine=engine)

First-pass support can use the existing grouped-over strategy: forward shuffle
by group, local evaluation, and backward remapping to input rows. Huge-group /
low-cardinality execution can be handled as follow-up distributed window work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cudf-polarsIssues specific to cudf-polarsfeature requestNew feature or request

    Type

    No type

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions