libenchao commented on code in PR #3159:
URL: https://github.com/apache/calcite/pull/3159#discussion_r1169860676
##########
core/src/main/java/org/apache/calcite/rel/rules/SubQueryRemoveRule.java:
##########
@@ -241,21 +247,21 @@ private static RexNode rewriteSome(RexSubQuery e,
Set<CorrelationId> variablesSe
builder.aggregateCall(minMax, builder.field(0)).as("m"),
builder.count(false, "c"),
builder.count(false, "d", builder.field(0)))
- .as("q")
+ .as(qAlias)
.join(JoinRelType.INNER);
caseRexNode =
builder.call(SqlStdOperatorTable.CASE,
- builder.equals(builder.field("q", "c"), builder.literal(0)),
+ builder.equals(builder.field(qAlias, "c"), builder.literal(0)),
literalFalse,
builder.call(SqlStdOperatorTable.IS_TRUE,
builder.call(RexUtil.op(op.comparisonKind),
- e.operands.get(0), builder.field("q", "m"))),
+ e.operands.get(0), builder.field(qAlias, "m"))),
literalTrue,
- builder.greaterThan(builder.field("q", "c"),
- builder.field("q", "d")),
+ builder.greaterThan(builder.field(qAlias, "c"),
+ builder.field(qAlias, "d")),
Review Comment:
Currently `RelBuilder#field` would return the first one when there is
multiple results, I think we'd better to throw in this case. It would be a
breaking change, what do you think about this @rubenada ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]