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

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

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


##########
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(node -> node != null)

Review Comment:
   `node -> node != null` -> `Objects::nonNull` seems better, WDYT?



##########
core/src/test/java/org/apache/calcite/test/SqlValidatorTest.java:
##########
@@ -5709,6 +5709,19 @@ public boolean isBangEqualAllowed() {
         .withConformance(lenient).ok();
   }
 
+  /** Test case for
+   * <a href="https://issues.apache.org/jira/browse/CALCITE-5486">[CALCITE-5486]
+   * SubQuery not support HAVING alias in where condition</a>. */
+  @Test void testHavingAliasInCondition() {

Review Comment:
   Should we also add a test in `SqlToRelConverterTest` to ensure we get the right plan?



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