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
Internal #751: Shared Window Partition #9839
Conversation
hawkfish
commented
Nov 29, 2023
- Extend the partitioning and window internals to handle multiple partial sorts.
- Add CSE and and fix BoundWindowExpression::Equals in the process.
- Add partition fusion.
Extend the partitioning and window internals to handle multiple partial sorts.
Add CSE and and fix BoundWindowExpression::Equals in the process.
Add partition fusion.
fixes: duckdblabs/duckdb-internal#751 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Could we add some tests with shared partitions/orderings? I'm not sure if this is tested enough by the base set of tests. I've tried this myself and found what I believe to be at least one incorrect result:
CALL dbgen(sf=0.01);
select l_extendedprice, l_partkey, l_orderkey, sum(l_extendedprice) over(order by l_partkey), sum(l_extendedprice) over (order by l_partkey, l_orderkey) from lineitem order by l_partkey, l_orderkey;
This PR
┌─────────────────┬───────────┬────────────┬───────────────┬────────────────┐
│ l_extendedprice │ l_partkey │ l_orderkey │ sum_part │ sum_part_order │
│ decimal(15,2) │ int32 │ int32 │ decimal(38,2) │ decimal(38,2) │
├─────────────────┼───────────┼────────────┼───────────────┼────────────────┤
│ 29733.00 │ 1 │ 2883 │ 29733.00 │ 29733.00 │
│ 1802.00 │ 1 │ 5121 │ 31535.00 │ 31535.00 │
│ 4505.00 │ 1 │ 6179 │ 36040.00 │ 36040.00 │
│ · │ · │ · │ · │ · │
│ · │ · │ · │ · │ · │
│ · │ · │ · │ · │ · │
│ 20746.00 │ 2000 │ 58916 │ 2152182544.47 │ 2152182544.47 │
│ 7216.00 │ 2000 │ 59269 │ 2152189760.47 │ 2152189760.47 │
├─────────────────┴───────────┴────────────┴───────────────┴────────────────┤
│ 60175 rows (5 shown) 5 columns │
└───────────────────────────────────────────────────────────────────────────┘
0.9.2
┌─────────────────┬───────────┬────────────┬───────────────┬────────────────┐
│ l_extendedprice │ l_partkey │ l_orderkey │ sum_part │ sum_part_order │
│ decimal(15,2) │ int32 │ int32 │ decimal(38,2) │ decimal(38,2) │
├─────────────────┼───────────┼────────────┼───────────────┼────────────────┤
│ 29733.00 │ 1 │ 2883 │ 607274.00 │ 29733.00 │
│ 1802.00 │ 1 │ 5121 │ 607274.00 │ 31535.00 │
│ 4505.00 │ 1 │ 6179 │ 607274.00 │ 36040.00 │
│ · │ · │ · │ · │ · │
│ · │ · │ · │ · │ · │
│ · │ · │ · │ · │ · │
│ 20746.00 │ 2000 │ 58916 │ 2152189760.47 │ 2152182544.47 │
│ 7216.00 │ 2000 │ 59269 │ 2152189760.47 │ 2152189760.47 │
├─────────────────┴───────────┴────────────┴───────────────┴────────────────┤
│ 60175 rows (5 shown) 5 columns │
└───────────────────────────────────────────────────────────────────────────┘
Even worse, this still gives the right answer: select
l_extendedprice,
l_partkey,
l_orderkey,
sum(l_extendedprice) over (order by l_partkey),
from lineitem
order by l_partkey, l_orderkey |
Fix incorrect fixed width in SBIterator::Compare. Add test to verify.
Sorry about that! Dumb problem in an unexpected place. Restricting to |
More thorough testing.
Add test for window function CSE
Thanks! LGTM |
Merge pull request duckdb/duckdb#9839 from hawkfish/window-suborder Merge pull request duckdb/duckdb#9906 from taniabogatsch/disable-32-bit-test