Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,8 @@ protected SqlAbstractTimeFunction(String name, SqlTypeName typeName) {
@Override public boolean isDynamicFunction() {
return true;
}

@Override public boolean isDeterministic() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,8 @@ protected SqlBaseContextVariable(String name,
@Override public boolean isDynamicFunction() {
return true;
}

@Override public boolean isDeterministic() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,8 @@ public SqlCurrentDateFunction() {
@Override public boolean isDynamicFunction() {
return true;
}

@Override public boolean isDeterministic() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,8 @@ public SqlRandFunction() {
@Override public boolean isDynamicFunction() {
return true;
}

@Override public boolean isDeterministic() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,8 @@ public SqlRandIntegerFunction() {
@Override public boolean isDynamicFunction() {
return true;
}

@Override public boolean isDeterministic() {
return false;
}
}
24 changes: 24 additions & 0 deletions core/src/test/java/org/apache/calcite/rex/RexExecutorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,30 @@ private void testContextLiteral(
});
}

@Test void testNonDeterministicFunc() throws Exception {
check((rexBuilder, executor) -> {
// SqlRandFunction
final RexNode rand = rexBuilder.makeCall(SqlStdOperatorTable.RAND);
assertThat(RexUtil.isDeterministic(rand), equalTo(false));

// SqlRandIntegerFunction
final RexNode randInteger = rexBuilder.makeCall(SqlStdOperatorTable.RAND_INTEGER);
assertThat(RexUtil.isDeterministic(randInteger), equalTo(false));

// SqlCurrentDateFunction
final RexNode currentDate = rexBuilder.makeCall(SqlStdOperatorTable.CURRENT_DATE);
assertThat(RexUtil.isDeterministic(currentDate), equalTo(false));

// SqlBaseContextVariable
final RexNode user = rexBuilder.makeCall(SqlStdOperatorTable.USER);
assertThat(RexUtil.isDeterministic(user), equalTo(false));

// SqlAbstractTimeFunction
final RexNode localtime = rexBuilder.makeCall(SqlStdOperatorTable.LOCALTIME);
assertThat(RexUtil.isDeterministic(localtime), equalTo(false));
});
}

private static final SqlBinaryOperator PLUS_RANDOM =
new SqlMonotonicBinaryOperator(
"+",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5619,7 +5619,7 @@ private void testSwapJoinShouldNotMatch(RelNode input) {
+ "group by sal, hiredate\n"
+ "having count(*) > 3";
sql(sql).withRule(CoreRules.AGGREGATE_ANY_PULL_UP_CONSTANTS)
.check();
.checkUnchanged();
}

@Test void testReduceExpressionsNot() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11630,17 +11630,6 @@ LogicalProject(HIREDATE=[$1])
LogicalProject(SAL=[$5], HIREDATE=[$4])
LogicalFilter(condition=[AND(IS NULL($5), =($4, CURRENT_TIMESTAMP))])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="planAfter">
<![CDATA[
LogicalProject(HIREDATE=[$1])
LogicalFilter(condition=[>($2, 3)])
LogicalProject(SAL=[$0], HIREDATE=[CURRENT_TIMESTAMP], $f2=[$1])
LogicalAggregate(group=[{0}], agg#0=[COUNT()])
LogicalProject(SAL=[$5])
LogicalFilter(condition=[AND(IS NULL($5), =($4, CURRENT_TIMESTAMP))])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
Expand Down