public class HiveParserProjectWindowTrimmer extends Object
create table src(a int, b int, c int); select a, count(b) over(order by a rows between 1 preceding and 1 following) from src;
will be converted into the RelNode like:
LogicalProject(a=[$0], _o_c2=[$4]) LogicalProject(a=[$0], b=[$1], c=[$2], _o_col3=[count($1) over(order by $0 desc nulls last rows between 1 preceding and 1 following)])
The project node with window will contain all the fields, some of which are not necessary. And
it will remove the redundant nodes in rule
ProjectWindowTransposeRule, and adjust the index referred in
RexInputRef for it remove some nodes. But it hasn't adjusted the index of lowerBound/upperBound,
which then cause problem when try to access the lowerBound/upperBound.
The class's behavior is quite same to
ProjectWindowTransposeRule, but also adjusts the index of
|Constructor and Description|
|Modifier and Type||Method and Description|
Remove the redundant nodes from the project node which contains over window node.
public static org.apache.calcite.rel.RelNode trimProjectWindow(org.apache.calcite.rel.core.Project selectProject, org.apache.calcite.rel.core.Project projectWithWindow, Map<org.apache.calcite.rel.RelNode,HiveParserRowResolver> relToRowResolver, Map<org.apache.calcite.rel.RelNode,Map<String,Integer>> relToHiveColNameCalcitePosMap)
selectProject- the project node contains selected fields in top of the project node with window
projectWithWindow- the project node which contains windows in the end of project expressions.
Copyright © 2014–2022 The Apache Software Foundation. All rights reserved.