Skip to content

[feature request] named window expressions? #624

Closed
@yitao-li

Description

@yitao-li

Is there a way in dbplyr to generate SQL of the form

SELECT
  SUM(`col1`) OVER `wnd` AS `s1`,
  SUM(`col2`) OVER `wnd` AS `s2`,
  SUM(`col3`) OVER `wnd` AS `s3`
FROM `my_table`
  WINDOW `wnd` AS (PARTITION BY `col4` ORDER BY `col5`)

?

(i.e., avoid spelling out the same window-spec repeatedly within the same query, and refer to it by a name instead) ?

The benefit of having this is the generated query would be shorter and easier to debug (as it's immediately clear that the same window spec is applied to multiple aggregations).

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