Skip to content

add RANGE and GROUP window framing for DuckDB #110

@drizk1

Description

@drizk1

DuckDB recently released RANGE and GROUP window framing

right now just row based is supported as below. Since dbplyr, duckplyr, and ibis dont yet have this incorporated to my knowledge for a syntax reference, I think we have some freedom.

we could make an optional arg in _frame for it, which i think would be the most clear, but I'm open to ideas for when 1.2 gets released to julia

@chain DB.db_table(db, "test_df") begin
    DB.@mutate(mean_7 = mean(percent),
        _by = groups,
        _order = value ,
        _frame = (-3, 3))
    DB.@arrange(groups, value)
    @aside DB.@show_query _
end
WITH cte_1 AS (
SELECT  id, groups, value, percent, AVG(percent) OVER (PARTITION BY groups 
        ORDER BY value ASC ROWS BETWEEN 3 PRECEDING AND 3 FOLLOWING) AS mean_7
        FROM test_df)  
SELECT *
        FROM cte_1  
        ORDER BY groups ASC, value ASC

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions