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

[multistage] Initial (phase 1) Query runtime for window functions with ORDER BY within the OVER() clause #10449

Merged

Conversation

somandal
Copy link
Contributor

@somandal somandal commented Mar 21, 2023

This PR introduces the multi-stage runtime changes to support Phase 1 of Window Functions, specifically targeting queries of the type OVER(ORDER BY) and OVER(PARTITION BY key1 ORDER BY key2). Runtime support has been added for the following classes of window queries:

  • OVER(ORDER BY) - single and multiple OVER(ORDER BY) in the same query
  • OVER(PARTITION BY key1 ORDER BY key2) - single and multiple OVER(PARTITION BY key1 ORDER BY key2) using the same PARTITION BY key1 and ORDER BY key2 across all OVER()s in the same query

The window functions supported as part of Phase 1 are: SUM, AVG, MIN, MAX, COUNT, BOOL_OR, and BOOL_AND.

This PR does not include support for:

  • Custom frames
  • Other window functions related to rank and values
  • Multiple window groups (basically multiple OVER clauses with different PARTITION BY, ORDER BY and/or FRAME specifications, if these specifications are the same they get grouped into a single window group)

The above will be part of future changes for window function support

Note: One issue was found while working on this PR related to Apache Calcite parsing. Details can be found in this section of the design document. Look for heading "Calcite Parser Exception on ORDER BY with > 1 column using default frame"

cc @siddharthteotia @walterddr @vvivekiyer @ankitsultana

@somandal somandal changed the title Initial (phase 1) Query runtime for window functions with ORDER BY within the OVER() clause [multistage] Initial (phase 1) Query runtime for window functions with ORDER BY within the OVER() clause Mar 21, 2023
@codecov-commenter
Copy link

codecov-commenter commented Mar 21, 2023

Codecov Report

Merging #10449 (f6273ac) into master (3687b2b) will decrease coverage by 39.08%.
The diff coverage is 0.00%.

@@              Coverage Diff              @@
##             master   #10449       +/-   ##
=============================================
- Coverage     63.23%   24.16%   -39.08%     
+ Complexity     5905       58     -5847     
=============================================
  Files          2036     2065       +29     
  Lines        110973   111457      +484     
  Branches      16892    16990       +98     
=============================================
- Hits          70177    26930    -43247     
- Misses        35606    81757    +46151     
+ Partials       5190     2770     -2420     
Flag Coverage Δ
integration1 ?
integration2 24.16% <0.00%> (-0.21%) ⬇️
unittests1 ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...uery/runtime/operator/WindowAggregateOperator.java 0.00% <0.00%> (-91.67%) ⬇️
...query/runtime/operator/utils/AggregationUtils.java 0.00% <0.00%> (-96.50%) ⬇️

... and 1347 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Contributor

@walterddr walterddr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good mostly.
this PR assumes the mailbox receive will generate ordered block appropriately, correct? if so could we please state so in the javadoc of window aggregate operator?

@somandal
Copy link
Contributor Author

this PR assumes the mailbox receive will generate ordered block appropriately, correct? if so could we please state so in the javadoc of window aggregate operator?

Thanks for the review! Yes, this PR assumes that mailbox receive will generate ordered blocks. Added a note in the javadocs about this. I've also addressed all other comments. PTAL when you get a chance.

@somandal somandal requested a review from walterddr March 24, 2023 16:34
Copy link
Contributor

@walterddr walterddr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

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

Successfully merging this pull request may close these issues.

3 participants