Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for some of the window frame range queries #5275

Closed
mustafasrepo opened this issue Feb 14, 2023 · 0 comments · Fixed by #5286
Closed

Support for some of the window frame range queries #5275

mustafasrepo opened this issue Feb 14, 2023 · 0 comments · Fixed by #5286
Labels
enhancement New feature or request

Comments

@mustafasrepo
Copy link
Contributor

Is your feature request related to a problem or challenge? Please describe what you are trying to do.
When I run the query below in postgre

SELECT
  c9,
  COUNT(*) OVER(ORDER BY c9, c1 RANGE BETWEEN CURRENT ROW AND CURRENT ROW) AS cnt1,
  COUNT(*) OVER(ORDER BY c9, c1 RANGE UNBOUNDED PRECEDING) AS cnt2,
  COUNT(*) OVER(ORDER BY c9, c1 RANGE CURRENT ROW) AS cnt3,
  COUNT(*) OVER(RANGE BETWEEN CURRENT ROW AND CURRENT ROW) AS cnt4,
  COUNT(*) OVER(RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS cnt5,
  COUNT(*) OVER(RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) AS cnt6
  FROM aggregate_test_100
  ORDER BY c9
  LIMIT 5

It produces valid result. Behaviour is as follows (RANGE BETWEEN CURRENT ROW AND CURRENT ROW), OVER(RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW), OVER(RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING) are treated as OVER(ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING). OVER(ORDER BY c9, c1 RANGE UNBOUNDED PRECEDING) is treated as OVER(ORDER BY c9, c1 RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
When we run this query in datafusion it gives the error With window frame of type RANGE, the order by expression must be of length 1, got 2.
Describe the solution you'd like
A clear and concise description of what you want to happen.
I would like to see same behaviour as postgre

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant