You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "rubenada (via GitHub)" <gi...@apache.org> on 2023/04/19 08:25:21 UTC

[GitHub] [calcite] rubenada commented on a diff in pull request #3159: [CALCITE-5655] Intermediate table alias should be different to avoid wrong field reference lookup in subquery remove phase

rubenada commented on code in PR #3159:
URL: https://github.com/apache/calcite/pull/3159#discussion_r1170995157


##########
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:
   Uhm... I think that might be a sensitive, breaking change. I'm not sure about it.
   In any case, I think that should be discussed in a separated thread/ticket, and is out of the scope of the current PR.



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org