hannerwang commented on a change in pull request #2408:
URL: https://github.com/apache/calcite/pull/2408#discussion_r621759639



##########
File path: 
core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
##########
@@ -6669,9 +6729,95 @@ private SqlNode nthSelectItem(int ordinal, final 
SqlParserPos pos) {
           break;
         }
       }
-
       return super.visit(literal);
     }
+
+    @Override
+    protected SqlNode visitScoped(SqlCall call) {
+      checkExpandedAsAlias(call);
+      return super.visitScoped(call);
+    }
+
+    void recordExpandingTopNodes(SqlNode root) {
+      List<SqlNode> operands = ((SqlCall) root).getOperandList();
+      for (int i = 0; i < operands.size(); i++) {
+        SqlNode operand = operands.get(i);
+        if (operand.getKind() == SqlKind.ROW) {
+          recordExpandingTopNodes(operand);
+        }
+        if (operand instanceof SqlCall) {
+          expandingTopNodes.put(operand, Boolean.FALSE);
+        } else {
+          expandingTopNodes.put(operand, Boolean.TRUE);
+        }
+      }
+    }
+
+    /*
+     * check if top level node should be expanded as alias.
+     */
+    void checkExpandedAsAlias(SqlNode sqlNode) {

Review comment:
       do you mean the 'check' in comment?




-- 
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to