xuzifu666 commented on code in PR #4970:
URL: https://github.com/apache/calcite/pull/4970#discussion_r3315018605


##########
core/src/main/java/org/apache/calcite/rel/rules/FilterProjectTransposeRule.java:
##########
@@ -165,6 +165,13 @@ protected FilterProjectTransposeRule(
       // it can be pushed down. For now we don't support this.
       return;
     }
+    // Pushing the filter below the project would split a single
+    // non-deterministic evaluation (e.g. RAND()) into two: one consumed by
+    // the new filter condition, and the original still produced by the
+    // project above. Refuse to transpose in that case.
+    if (!project.getProjects().stream().allMatch(RexUtil::isDeterministic)) {

Review Comment:
   Blocks transpose (because RAND() exists in project)? eg:
   ```
   SELECT * FROM (
       SELECT RAND() as r, col1 as b FROM emp
     ) 
     WHERE col1 > 0
   ```



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