You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2020/07/18 21:40:46 UTC

[GitHub] [incubator-pinot] fx19880617 opened a new pull request #5715: Support alias name to be same as selection

fx19880617 opened a new pull request #5715:
URL: https://github.com/apache/incubator-pinot/pull/5715


   ## Description
   A fix to support query like:
   ```
   SELECT c1 AS c1 FROM myTable
   ```


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



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] fx19880617 commented on a change in pull request #5715: Support alias name to be same as selection

Posted by GitBox <gi...@apache.org>.
fx19880617 commented on a change in pull request #5715:
URL: https://github.com/apache/incubator-pinot/pull/5715#discussion_r457831931



##########
File path: pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java
##########
@@ -113,32 +113,11 @@ private static void validateSelectionClause(Map<Identifier, Expression> aliasMap
     // Sanity check on selection expression shouldn't use alias reference.

Review comment:
       done.




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



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #5715: Support alias name to be same as selection

Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on a change in pull request #5715:
URL: https://github.com/apache/incubator-pinot/pull/5715#discussion_r457759329



##########
File path: pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java
##########
@@ -113,32 +113,11 @@ private static void validateSelectionClause(Map<Identifier, Expression> aliasMap
     // Sanity check on selection expression shouldn't use alias reference.

Review comment:
       I think the correct fix should be just not adding it to the aliasMap?
   You can rewrite the query before handling the alias by replacing `a AS a` to `a`




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



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #5715: Support alias name to be same as selection

Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on a change in pull request #5715:
URL: https://github.com/apache/incubator-pinot/pull/5715#discussion_r457848395



##########
File path: pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java
##########
@@ -113,7 +113,11 @@ private static void validateSelectionClause(Map<Identifier, Expression> aliasMap
     // Sanity check on selection expression shouldn't use alias reference.
     Set<String> aliasKeys = new HashSet<>();
     for (Identifier identifier : aliasMap.keySet()) {
-      aliasKeys.add(identifier.getName().toLowerCase());
+      String aliasName = identifier.getName().toLowerCase();
+      if (aliasKeys.contains(aliasName)) {
+        throw new SqlCompilationException("Duplicated alias name found.");
+      }
+      aliasKeys.add(aliasName);

Review comment:
       (nit)
   ```suggestion
         if (!aliasKeys.add(aliasName)) {
           throw new SqlCompilationException("Duplicated alias name found.");
         }
   ```




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



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #5715: Support alias name to be same as selection

Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on a change in pull request #5715:
URL: https://github.com/apache/incubator-pinot/pull/5715#discussion_r457626980



##########
File path: pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java
##########
@@ -113,32 +113,11 @@ private static void validateSelectionClause(Map<Identifier, Expression> aliasMap
     // Sanity check on selection expression shouldn't use alias reference.

Review comment:
       We should not remove the sanity check on usage of alias reference
   E.g. we should reject the following query:
   ```
   SELECT colA AS a, foo(a, colB) FROM table
   ```
   
   Another way is to replace the alias reference in selection as well




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



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] fx19880617 merged pull request #5715: Support alias name to be same as selection

Posted by GitBox <gi...@apache.org>.
fx19880617 merged pull request #5715:
URL: https://github.com/apache/incubator-pinot/pull/5715


   


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



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] fx19880617 commented on a change in pull request #5715: Support alias name to be same as selection

Posted by GitBox <gi...@apache.org>.
fx19880617 commented on a change in pull request #5715:
URL: https://github.com/apache/incubator-pinot/pull/5715#discussion_r457756336



##########
File path: pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java
##########
@@ -113,32 +113,11 @@ private static void validateSelectionClause(Map<Identifier, Expression> aliasMap
     // Sanity check on selection expression shouldn't use alias reference.

Review comment:
       Added it back, basically remove colA in aliasMap for case like `SELECT colA AS colA`.




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



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org