[opt](Nereids) remove Nondeterministic trait from date related functions (#26444)
This commit is contained in:
@ -52,13 +52,8 @@ public enum ExpressionFunctions {
|
||||
private static final Logger LOG = LogManager.getLogger(ExpressionFunctions.class);
|
||||
private ImmutableMultimap<String, FEFunctionInvoker> functions;
|
||||
public static final Set<String> unfixedFn = ImmutableSet.of(
|
||||
"now",
|
||||
"current_time",
|
||||
"current_date",
|
||||
"utc_timestamp",
|
||||
"uuid",
|
||||
"random",
|
||||
"unix_timestamp"
|
||||
"random"
|
||||
);
|
||||
|
||||
private ExpressionFunctions() {
|
||||
|
||||
@ -17,8 +17,6 @@
|
||||
|
||||
package org.apache.doris.nereids.trees.expressions.functions;
|
||||
|
||||
import org.apache.doris.qe.ConnectContext;
|
||||
|
||||
/**
|
||||
* Nondeterministic functions.
|
||||
*
|
||||
@ -26,10 +24,4 @@ import org.apache.doris.qe.ConnectContext;
|
||||
*
|
||||
*/
|
||||
public interface Nondeterministic extends ExpressionTrait {
|
||||
@Override
|
||||
default boolean foldable() {
|
||||
return ConnectContext.get() == null
|
||||
|| ConnectContext.get().getSessionVariable() == null
|
||||
|| ConnectContext.get().getSessionVariable().isEnableFoldNondeterministicFn();
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,18 +86,19 @@ public class DateTimeAcquire {
|
||||
return DateLiteral.fromJavaDateType(LocalDateTime.now(DateUtils.getTimeZone()));
|
||||
}
|
||||
|
||||
/**
|
||||
* date acquire function: current_time
|
||||
*/
|
||||
@ExecFunction(name = "curtime", argTypes = {}, returnType = "DATETIME")
|
||||
public static Expression curTime() {
|
||||
return DateTimeLiteral.fromJavaDateType(LocalDateTime.now(DateUtils.getTimeZone()));
|
||||
}
|
||||
// comment these function temporally until we support TimeLiteral
|
||||
// /**
|
||||
// * date acquire function: current_time
|
||||
// */
|
||||
// @ExecFunction(name = "curtime", argTypes = {}, returnType = "TIME")
|
||||
// public static Expression curTime() {
|
||||
// return DateTimeLiteral.fromJavaDateType(LocalDateTime.now(DateUtils.getTimeZone()));
|
||||
// }
|
||||
|
||||
@ExecFunction(name = "current_time", argTypes = {}, returnType = "DATETIME")
|
||||
public static Expression currentTime() {
|
||||
return DateTimeLiteral.fromJavaDateType(LocalDateTime.now(DateUtils.getTimeZone()));
|
||||
}
|
||||
// @ExecFunction(name = "current_time", argTypes = {}, returnType = "TIME")
|
||||
// public static Expression currentTime() {
|
||||
// return DateTimeLiteral.fromJavaDateType(LocalDateTime.now(DateUtils.getTimeZone()));
|
||||
// }
|
||||
|
||||
/**
|
||||
* date transformation function: unix_timestamp
|
||||
|
||||
@ -70,6 +70,11 @@ public class Random extends ScalarFunction
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean foldable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* withChildren.
|
||||
*/
|
||||
|
||||
@ -40,7 +40,7 @@ import java.util.List;
|
||||
* ScalarFunction 'unix_timestamp'. This class is generated by GenerateFunction.
|
||||
*/
|
||||
public class UnixTimestamp extends ScalarFunction
|
||||
implements Nondeterministic, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args {
|
||||
implements ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args, Nondeterministic {
|
||||
|
||||
private static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
|
||||
FunctionSignature.ret(IntegerType.INSTANCE).args(),
|
||||
@ -101,14 +101,6 @@ public class UnixTimestamp extends ScalarFunction
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean foldable() {
|
||||
if (children.size() != 0) {
|
||||
return true;
|
||||
}
|
||||
return Nondeterministic.super.foldable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FunctionSignature> getSignatures() {
|
||||
return SIGNATURES;
|
||||
|
||||
@ -46,6 +46,11 @@ public class Uuid extends ScalarFunction
|
||||
super("uuid");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean foldable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
|
||||
return visitor.visitUuid(this, context);
|
||||
|
||||
@ -46,6 +46,11 @@ public class UuidNumeric extends ScalarFunction
|
||||
super("uuid_numeric");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean foldable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
|
||||
return visitor.visitUuidNumeric(this, context);
|
||||
|
||||
Reference in New Issue
Block a user