You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2019/12/17 08:33:16 UTC

[GitHub] [calcite] jinxing64 commented on a change in pull request #1655: [CALCITE-3387] Query with GROUP BY and JOIN ... USING wrongly fails with "Column DEPTNO is ambiguous" error

jinxing64 commented on a change in pull request #1655: [CALCITE-3387] Query with GROUP BY and JOIN ... USING wrongly fails with "Column DEPTNO is ambiguous" error
URL: https://github.com/apache/calcite/pull/1655#discussion_r358649332
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
 ##########
 @@ -484,6 +484,52 @@ private boolean expandSelectItem(
     return false;
   }
 
+  private static SqlNode expandCommonColumn(SqlSelect sqlSelect,
+      SqlNode selectItem, SelectScope scope) {
+    if (!(selectItem instanceof SqlIdentifier)) {
+      return selectItem;
+    }
+
+    final SqlIdentifier identifier = (SqlIdentifier) selectItem;
+    if (!identifier.isSimple()) {
+      return selectItem;
+    }
+
+    final SqlNode from = sqlSelect.getFrom();
+    if (from == null || !(from instanceof SqlJoin)) {
+      return selectItem;
+    }
+
+    final SqlJoin join = (SqlJoin) from;
+    if (join.getConditionType() != JoinConditionType.USING) {
 
 Review comment:
   If our target is `USING` clause, I'm not sure if it deserve to add a test for below sql
   ```
   SELECT deptno, name FROM emp JOIN dept on emp.deptno = dept.deptno
   ```
   and assert that it will throw exception `Column 'DEPTNO' is ambiguous`

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services