You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "libenchao (via GitHub)" <gi...@apache.org> on 2023/02/18 12:27:03 UTC

[GitHub] [calcite] libenchao commented on a diff in pull request #3053: [CALCITE-5486] SubQuery not support HAVING alias in where condition

libenchao commented on code in PR #3053:
URL: https://github.com/apache/calcite/pull/3053#discussion_r1111002622


##########
core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java:
##########
@@ -4474,6 +4474,21 @@ protected void validateWhereOrOn(
       SqlNode condition,
       String clause) {
     validateNoAggs(aggOrOverOrGroupFinder, condition, clause);
+    //  SqlSelect need to expand alias
+    condition.accept(new SqlShuttle() {
+      @Override public @Nullable SqlNode visit(SqlCall call) {
+        call.getOperandList()
+            .stream()
+            .filter(Objects::nonNull)
+            .forEach(node -> node.accept(this));
+        if (call.getKind() == SqlKind.SELECT) {
+          SqlSelect select = (SqlSelect) call;
+          validateHavingClause(select);

Review Comment:
   `validateWhereOrOn` is used not only to validate `where` clause, is your change also applies to `on` clause, is there any test covers this?



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