-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Implement tree
explain for BoundedWindowAggExec
and WindowAggExec
#15084
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
Conversation
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.
Thank you so much for the efforts, I think the only thing missing is adding test for BoundedWindowAggExec
DuckDB also uses the whole window expression in their pretty explain, this is good enough:
┌─────────────┴─────────────┐
│ WINDOW │
│ ──────────────────── │
│ Projections: │
│ sum(v1) OVER (ORDER BY v1 │
│ ASC NULLS LAST ROWS │
│ BETWEEN UNBOUNDED │
│ PRECEDING AND CURRENT ROW)│
└─────────────┬─────────────┘
But I think if we can split window-expr, partition-by, order-by, window-frame to separate rows, it will look even better:
window expression: SUM(v1) OVER (...)
window frame: ROWS BETWEEN 1 PRECEDING AND CURRENT ROW
partition by: v1 % 10
order by: v1 ASC NULLS LAST
I think this should be left to a separate follow-up ticket, I saw BoundedWindowExec
can have multiple window expressions, they should all have the same partition and order? This should be checked first and then figure out how to better format it.
01)┌───────────────────────────┐ | ||
02)│ ProjectionExec │ | ||
03)└─────────────┬─────────────┘ | ||
04)┌─────────────┴─────────────┐ |
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.
To also test BoundedWindowAggExec
, we can set a bounded window frame (e.g. 'rows between 1 preceding and current row`)
explain SELECT
v1,
SUM(v1) OVER (ORDER BY v1 ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS rolling_sum
FROM generate_series(1, 1000) AS t1(v1);
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.
Can you
- update this test to use two expressions that share the same window definition? For exmaple
select
count(*) over(),
row_number() over ()
from table1
- Add a query that has two different window definitions? For example
select
rank() over(ORDER BY int_col DESC),
row_number() over (ORDER BY int_col ASC)
from table1
Thanks for you excellent advice!❤️ |
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.
Thank you @irenjj -- other than a few more tests this one is looking good to me!
01)┌───────────────────────────┐ | ||
02)│ ProjectionExec │ | ||
03)└─────────────┬─────────────┘ | ||
04)┌─────────────┴─────────────┐ |
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.
Can you
- update this test to use two expressions that share the same window definition? For exmaple
select
count(*) over(),
row_number() over ()
from table1
- Add a query that has two different window definitions? For example
select
rank() over(ORDER BY int_col DESC),
row_number() over (ORDER BY int_col ASC)
from table1
DisplayFormatType::TreeRender => { | ||
// TODO: collect info | ||
write!(f, "")?; | ||
let g: Vec<String> = self |
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.
I think it might look better if we added one list of window expressions and then printed the window
expr=count()
window = OVER ORDER BY ...
Not sure if this is possible. We can also explore it in a follow on PR (no need to change here)
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 @irenjj -- this looks like a good improvement to me
Thanks @2010YOUY01 for the reviews
tree explain for
BoundedWindowAggExec and
WindowAggExec`tree
explain for BoundedWindowAggExec
and WindowAggExec
🎉 |
I am pretty excited about this |
Which issue does this PR close?
tree
explain forBoundedWindowAggExec
andWindowAggExec
#15083Rationale for this change
What changes are included in this PR?
Are these changes tested?
Are there any user-facing changes?