mihaibudiu commented on code in PR #4970:
URL: https://github.com/apache/calcite/pull/4970#discussion_r3312892470
##########
core/src/main/java/org/apache/calcite/plan/RelOptUtil.java:
##########
@@ -3346,6 +3346,21 @@ public static List<RexNode> pushPastProject(List<?
extends RexNode> nodes,
// function? Possibly. But it's invalid SQL, so don't go there.
return null;
}
+ // [CALCITE-7551] Refuse to merge if it would duplicate a
+ // non-deterministic expression (e.g. RAND()).
+ final List<RexNode> bottom = project.getProjects();
+ final int[] refs = new int[bottom.size()];
+ new RexVisitorImpl<Void>(true) {
+ @Override public Void visitInputRef(RexInputRef ref) {
+ refs[ref.getIndex()]++;
+ return null;
+ }
+ }.visitEach(nodes);
+ for (int i = 0; i < refs.length; i++) {
Review Comment:
As discussed in Jira, this is a bit too conservative, since it will not
distinguish CURRENT_TIMESTAMP from RAND. But fixing that may be in the scope of
a separate PR - we need really two separate notions of nondeterminism.
##########
core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java:
##########
@@ -6133,4 +6133,16 @@ void checkUserDefinedOrderByOver(NullCollation
nullCollation) {
+ "FROM emp JOIN dept using (deptno)";
sql(sql).withConformance(SqlConformanceEnum.PRESTO).ok();
}
+
+ /** Test case of
Review Comment:
why is SqlToRel connected to these rules?
--
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]