antonkw commented on code in PR #4177:
URL: https://github.com/apache/calcite/pull/4177#discussion_r1949392602


##########
core/src/main/java/org/apache/calcite/rel/rel2sql/RelToSqlConverter.java:
##########
@@ -456,7 +458,10 @@ public Result visit(Filter e) {
               builder.context.toSql(null, e.getCondition())));
       return builder.result();
     } else {
-      final Result x = visitInput(e, 0, Clause.WHERE);
+      Result x = visitInput(e, 0, Clause.WHERE);
+      if (e.getCondition().getKind() == NOT || e.getCondition().getKind() == 
EXISTS) {

Review Comment:
   @mihaibudiu 
   > why are these the only conditions that require a reset alias?
   
   My take here is that typically predicates can't access the input via 
aliases. At least, for many SQL engines user ought to move the input into CTE 
to refer to it in filtering conditions. And JOINs with `EXISTS`/`NOT EXISTS` 
syntax are exceptions in that regard.
   
   I thought about explicit function with name like `canAccessInputViaAlias` 
that processes condition. But it seems too nit-pick'y given the fact that I am 
sure only about two greenlighting keywords



-- 
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: [email protected]

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

Reply via email to