Skip to content

Commit 77af9fe

Browse files
committed
Signed-off-by: Xinyu Hao <haoxinyu@amazon.com>
1 parent 300886a commit 77af9fe

1 file changed

Lines changed: 24 additions & 24 deletions

File tree

core/src/main/java/org/opensearch/sql/calcite/CalciteRelNodeVisitor.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1747,31 +1747,31 @@ public RelNode visitStreamWindow(StreamWindow node, CalcitePlanContext context)
17471747
.as(ROW_NUMBER_COLUMN_FOR_STREAMSTATS);
17481748
context.relBuilder.projectPlus(streamSeq);
17491749

1750-
if (!node.isBucketNullable()) {
1751-
// construct groupNotNull predicate
1752-
List<RexNode> groupByList =
1753-
groupList.stream().map(expr -> rexVisitor.analyze(expr, context)).collect(Collectors.toList());
1754-
List<RexNode> notNullList =
1755-
PlanUtils.getSelectColumns(groupByList).stream()
1756-
.map(context.relBuilder::field)
1757-
.map(context.relBuilder::isNotNull)
1758-
.collect(Collectors.toList());
1759-
RexNode groupNotNull = context.relBuilder.and(notNullList);
1750+
if (!node.isBucketNullable()) {
1751+
// construct groupNotNull predicate
1752+
List<RexNode> groupByList =
1753+
groupList.stream().map(expr -> rexVisitor.analyze(expr, context)).collect(Collectors.toList());
1754+
List<RexNode> notNullList =
1755+
PlanUtils.getSelectColumns(groupByList).stream()
1756+
.map(context.relBuilder::field)
1757+
.map(context.relBuilder::isNotNull)
1758+
.collect(Collectors.toList());
1759+
RexNode groupNotNull = context.relBuilder.and(notNullList);
17601760

1761-
// wrap each expr: CASE WHEN groupNotNull THEN rawExpr ELSE CAST(NULL AS rawType) END
1762-
List<RexNode> wrappedOverExprs =
1763-
wrapWindowFunctionsWithGroupNotNull(overExpressions, groupNotNull, context);
1764-
context.relBuilder.projectPlus(wrappedOverExprs);
1765-
} else {
1766-
context.relBuilder.projectPlus(overExpressions);
1767-
}
1761+
// wrap each expr: CASE WHEN groupNotNull THEN rawExpr ELSE CAST(NULL AS rawType) END
1762+
List<RexNode> wrappedOverExprs =
1763+
wrapWindowFunctionsWithGroupNotNull(overExpressions, groupNotNull, context);
1764+
context.relBuilder.projectPlus(wrappedOverExprs);
1765+
} else {
1766+
context.relBuilder.projectPlus(overExpressions);
1767+
}
17681768

1769-
// resort when there is by condition
1770-
context.relBuilder.sort(context.relBuilder.field(ROW_NUMBER_COLUMN_FOR_STREAMSTATS));
1771-
context.relBuilder.projectExcept(context.relBuilder.field(ROW_NUMBER_COLUMN_FOR_STREAMSTATS));
1772-
} else {
1773-
context.relBuilder.projectPlus(overExpressions);
1774-
}
1769+
// resort when there is by condition
1770+
context.relBuilder.sort(context.relBuilder.field(ROW_NUMBER_COLUMN_FOR_STREAMSTATS));
1771+
context.relBuilder.projectExcept(context.relBuilder.field(ROW_NUMBER_COLUMN_FOR_STREAMSTATS));
1772+
} else {
1773+
context.relBuilder.projectPlus(overExpressions);
1774+
}
17751775

17761776
return context.relBuilder.peek();
17771777
}
@@ -1985,7 +1985,7 @@ private RexNode buildGroupFilter(
19851985
RexCorrelVariable correl) {
19861986
// build conjunctive equality filters: right.g_i = outer.g_i
19871987
if (groupList.isEmpty()) {
1988-
return null;
1988+
return null;
19891989
}
19901990
List<RexNode> equalsList =
19911991
groupList.stream()

0 commit comments

Comments
 (0)