kasakrisz commented on code in PR #5749:
URL: https://github.com/apache/hive/pull/5749#discussion_r2038905755


##########
ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java:
##########
@@ -3800,19 +3800,25 @@ private RelNode genGBLogicalPlan(QB qb, RelNode srcRel) 
throws SemanticException
         groupByOutputRowResolver.setIsExprResolver(true);
 
         if (hasGrpByAstExprs) {
-          // 4. Construct GB Keys (ExprNode)
-          for (int i = 0; i < groupByNodes.size(); ++i) {
-            ASTNode groupByNode = groupByNodes.get(i);
-            Map<ASTNode, RexNode> astToRexNodeMap = genAllRexNode(
-                groupByNode, groupByInputRowResolver, cluster.getRexBuilder());
-            RexNode groupByExpression = astToRexNodeMap.get(groupByNode);
-            if (groupByExpression == null) {
-              throw new CalciteSemanticException("Invalid Column Reference: " 
+ groupByNode.dump(),
-                  UnsupportedFeature.Invalid_column_reference);
-            }
+          try {
+            groupByInputRowResolver.setCheckForAmbiguity(true);
+            // 4. Construct GB Keys (ExprNode)
+            for (int i = 0; i < groupByNodes.size(); ++i) {
+              ASTNode groupByNode = groupByNodes.get(i);
+              Map<ASTNode, RexNode> astToRexNodeMap = genAllRexNode(
+                      groupByNode, groupByInputRowResolver, 
cluster.getRexBuilder());
+              RexNode groupByExpression = astToRexNodeMap.get(groupByNode);
+              if (groupByExpression == null) {
+                throw new CalciteSemanticException("Invalid Column Reference: 
" + groupByNode.dump(),
+                        UnsupportedFeature.Invalid_column_reference);
+              }
 
-            addToGBExpr(groupByOutputRowResolver, groupByInputRowResolver, 
groupByNode,
-                groupByExpression, groupByExpressions, outputColumnNames);
+              addToGBExpr(groupByOutputRowResolver, groupByInputRowResolver, 
groupByNode,
+                      groupByExpression, groupByExpressions, 
outputColumnNames);
+            }
+          }
+          finally {
+            groupByInputRowResolver.setCheckForAmbiguity(false);
           }

Review Comment:
   Your are right, an exception is causing a CBO failure anyway.
   I removed the try-finally



-- 
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: gitbox-unsubscr...@hive.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org
For additional commands, e-mail: gitbox-h...@hive.apache.org

Reply via email to