Uh oh!
There was an error while loading. Please reload this page.
[feature](nereids)support window function - #14397
Conversation
2deb44f to
04696e9CompareTeamCity pipeline, clickbench performance test result: |
09c9cda to
f81180bCompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| /** | ||
| * translate WindowFrame to AnalyticWindow | ||
| */ | ||
| default AnalyticWindow translateWindowFrame(WindowFrame windowFrame, PlanTranslatorContext context) { | ||
| FrameUnitsType frameUnits = windowFrame.getFrameUnits(); | ||
| FrameBoundary leftBoundary = windowFrame.getLeftBoundary(); | ||
| FrameBoundary rightBoundary = windowFrame.getRightBoundary(); | ||
| AnalyticWindow.Type type = frameUnits == FrameUnitsType.ROWS | ||
| ? AnalyticWindow.Type.ROWS : AnalyticWindow.Type.RANGE; | ||
| AnalyticWindow.Boundary left = withFrameBoundary(leftBoundary, context); | ||
| AnalyticWindow.Boundary right = withFrameBoundary(rightBoundary, context); | ||
| return new AnalyticWindow(type, left, right); | ||
| } |
There was a problem hiding this comment.
i think it it better that put translate functions in translator
There was a problem hiding this comment.
due to that AnalyticWindow doesn't extend Expr, it is hard to use visitWindowFrame() in ExpressionTranslator. And in consider of that the code related of translate windowFrame is long, I put these functions in Window interface rather than PhysicalPlanTranslator.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| if (containsWindowExpressions(projects)) { | ||
| return new LogicalWindow<>(projects, input); | ||
| } | ||
| return new LogicalProject<>(projects, Collections.emptyList(), input, isDistinct); |
There was a problem hiding this comment.
maybe we should generate LogicalWindow after we do bind.
we chould just treat windowExpression as a scalar expression.
- if we use window function without agg. Then window function will in Projections.
we could generate LogicalProject(LogicalWindow(LogicalProject)) to handle all case. - if we use window function in agg. Then window function will in Agg's output expressions. After normalize agg it will present in the Project topping on Aggregate. and then we could do the same thing as first scene.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
780f3c9 to
3c3cd0fCompare| * which is an UnboundFunction at first and will be analyzed as relevant BoundFunction | ||
| * (can be a WindowFunction or AggregateFunction) after BindFunction. | ||
| */ | ||
| public class WindowExpression extends Expression implements PropagateNullable { |
There was a problem hiding this comment.
| publicclassWindowExpressionextendsExpressionimplementsPropagateNullable{ | |
| publicclassWindowExpressionextendsExpression { | |
| @Override | |
| publicbooleannullable() { | |
| returnfunction.nullable(); | |
| } |
| @Override | ||
| public DataType getDataType() { | ||
| return IntegerType.INSTANCE; | ||
| } |
| @Override | ||
| public DataType getDataType() { | ||
| return IntegerType.INSTANCE; | ||
| } |
| SELECT *, row_number() over(partition by c1) | ||
| FROM ( | ||
| SELECT *, row_number() over(partition by c2) | ||
| FROM window_test |
There was a problem hiding this comment.
need order by in over to get a stable result
| FunctionSignature.ret(LargeIntType.INSTANCE).args(LargeIntType.INSTANCE) | ||
| ); | ||
| private Expression buckets; |
PR approved by at least one committer and no changes requested. |
PR approved by anyone and no changes requested. |
fix distinct window compute wrong result, introduced by apache#14397 ```sql select distinct sum(value) over(partition by id) from ( select 100 value, 1 id union all select 100, 2 )a; +----------------------------------+ | sum(value) over(partition by id) | +----------------------------------+ | 100 | | 100 | +----------------------------------+ ```
fix distinct window compute wrong result, introduced by apache#14397 ```sql select distinct sum(value) over(partition by id) from ( select 100 value, 1 id union all select 100, 2 )a; +----------------------------------+ | sum(value) over(partition by id) | +----------------------------------+ | 100 | | 100 | +----------------------------------+ ```
### What problem does this PR solve? Related PR: #21727#14397 Problem Summary: 1. forgot to copy isChecked flag in LogicalWindow when do deep copy 2. implement LogicalWindow To PhyscialWindow should not check isChecked flag This PR: 1. check deep copy for all plan node 2. remove check isChecked in LogicalWindow To PhyscialWindow
### What problem does this PR solve? Related PR: #21727#14397 Problem Summary: 1. forgot to copy isChecked flag in LogicalWindow when do deep copy 2. implement LogicalWindow To PhyscialWindow should not check isChecked flag This PR: 1. check deep copy for all plan node 2. remove check isChecked in LogicalWindow To PhyscialWindow
### What problem does this PR solve? Related PR: #21727#14397 Problem Summary: 1. forgot to copy isChecked flag in LogicalWindow when do deep copy 2. implement LogicalWindow To PhyscialWindow should not check isChecked flag This PR: 1. check deep copy for all plan node 2. remove check isChecked in LogicalWindow To PhyscialWindow
fix distinct window compute wrong result, introduced by apache#14397 ```sql select distinct sum(value) over(partition by id) from ( select 100 value, 1 id union all select 100, 2 )a; +----------------------------------+ | sum(value) over(partition by id) | +----------------------------------+ | 100 | | 100 | +----------------------------------+ ```
fix distinct window compute wrong result, introduced by apache#14397 ```sql select distinct sum(value) over(partition by id) from ( select 100 value, 1 id union all select 100, 2 )a; +----------------------------------+ | sum(value) over(partition by id) | +----------------------------------+ | 100 | | 100 | +----------------------------------+ ```
fix distinct window compute wrong result, introduced by apache#14397 ```sql select distinct sum(value) over(partition by id) from ( select 100 value, 1 id union all select 100, 2 )a; +----------------------------------+ | sum(value) over(partition by id) | +----------------------------------+ | 100 | | 100 | +----------------------------------+ ```
### What problem does this PR solve? Related PR: apache#21727apache#14397 Problem Summary: 1. forgot to copy isChecked flag in LogicalWindow when do deep copy 2. implement LogicalWindow To PhyscialWindow should not check isChecked flag This PR: 1. check deep copy for all plan node 2. remove check isChecked in LogicalWindow To PhyscialWindow
Proposed changes
Issue Number: close #xxx
Problem summary
support WindowFunction in nereids;
Checklist(Required)
Further comments
If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...