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

feat(over window): support batch over window #10915

Merged
merged 13 commits into from
Jul 14, 2023
Merged

feat(over window): support batch over window #10915

merged 13 commits into from
Jul 14, 2023

Conversation

stdrc
Copy link
Contributor

@stdrc stdrc commented Jul 12, 2023

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

This PR adds support for over window in batch mode, which fixes #10016 and fixes #9931.

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • [ ] I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features Sqlsmith: Sql feature generation #7934).
  • [ ] My PR contains breaking changes. (If it deprecates some features, please create a tracking issue to remove them in the future).
  • All checks passed in ./risedev check (or alias, ./risedev c)
  • [ ] My PR changes performance-critical code. (Please run macro/micro-benchmarks and show the results.)

Documentation

  • My PR contains user-facing changes.
Click here for Documentation

Types of user-facing changes

Please keep the types that apply to your changes, and remove the others.

  • SQL commands, functions, and operators

Release note

  • Support over window functions like lead, lad in batch mode

Signed-off-by: Richard Chien <stdrc@outlook.com>
Signed-off-by: Richard Chien <stdrc@outlook.com>
Signed-off-by: Richard Chien <stdrc@outlook.com>
Signed-off-by: Richard Chien <stdrc@outlook.com>
Signed-off-by: Richard Chien <stdrc@outlook.com>
Signed-off-by: Richard Chien <stdrc@outlook.com>
Signed-off-by: Richard Chien <stdrc@outlook.com>
Signed-off-by: Richard Chien <stdrc@outlook.com>
Signed-off-by: Richard Chien <stdrc@outlook.com>
@stdrc stdrc marked this pull request as ready for review July 14, 2023 07:40
@github-actions github-actions bot added the user-facing-changes Contains changes that are visible to users label Jul 14, 2023
Signed-off-by: Richard Chien <stdrc@outlook.com>
@stdrc stdrc requested a review from yuhao-su July 14, 2023 08:11
@codecov
Copy link

codecov bot commented Jul 14, 2023

Codecov Report

Merging #10915 (1767ecf) into main (33071ff) will decrease coverage by 0.03%.
The diff coverage is 47.67%.

@@            Coverage Diff             @@
##             main   #10915      +/-   ##
==========================================
- Coverage   69.95%   69.92%   -0.03%     
==========================================
  Files        1307     1309       +2     
  Lines      223475   223714     +239     
==========================================
+ Hits       156327   156429     +102     
- Misses      67148    67285     +137     
Flag Coverage Δ
rust 69.92% <47.67%> (-0.03%) ⬇️

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

Impacted Files Coverage Δ
src/batch/src/executor/mod.rs 78.37% <ø> (ø)
src/batch/src/executor/sort_over_window.rs 0.00% <0.00%> (ø)
src/frontend/src/optimizer/plan_node/mod.rs 92.97% <ø> (ø)
src/meta/src/hummock/metrics_utils.rs 70.61% <0.00%> (-3.33%) ⬇️
src/meta/src/manager/catalog/fragment.rs 27.85% <0.00%> (-0.35%) ⬇️
src/meta/src/rpc/server.rs 0.00% <0.00%> (ø)
src/meta/src/hummock/manager/mod.rs 68.16% <29.62%> (-0.27%) ⬇️
...ntend/src/optimizer/plan_node/batch_over_window.rs 62.29% <62.29%> (ø)
src/meta/src/rpc/metrics.rs 78.54% <63.33%> (-0.71%) ⬇️
...end/src/optimizer/plan_node/logical_over_window.rs 92.70% <89.74%> (-0.25%) ⬇️
... and 7 more

... and 7 files with indirect coverage changes

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

Signed-off-by: Richard Chien <stdrc@outlook.com>
Copy link
Contributor

@st1page st1page left a comment

Choose a reason for hiding this comment

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

Generally LGTM

Comment on lines +624 to +626
└─BatchOverWindow { window_functions: [row_number() OVER(PARTITION BY t.y ORDER BY t.x ASC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)] }
└─BatchExchange { order: [t.y ASC, t.x ASC], dist: HashShard(t.y) }
└─BatchSort { order: [t.y ASC, t.x ASC] }
Copy link
Contributor

Choose a reason for hiding this comment

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

The Exchange can not make the OverWindow's computing can not be shuffled well because the partition key in a period could be the same.
a better plan might be

        └─BatchOverWindow { window_functions: [row_number() OVER(PARTITION BY t.y ORDER BY t.x ASC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)] }
            └─BatchSort { order: [t.y ASC, t.x ASC] }
                     └─BatchExchange { dist: HashShard(t.y) }

@stdrc stdrc enabled auto-merge July 14, 2023 09:47
@stdrc stdrc added this pull request to the merge queue Jul 14, 2023
Merged via the queue into main with commit 88ecdf8 Jul 14, 2023
36 checks passed
@stdrc stdrc deleted the rc/batch-over-window branch July 14, 2023 10:31
@CharlieSYH CharlieSYH added the 📖✓ Covered or will be covered in the user docs. label Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature user-facing-changes Contains changes that are visible to users 📖✓ Covered or will be covered in the user docs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

frontend: BatchOverWindow node (general version) Batch over window function, incl. lag and lead
3 participants