[Fix](function) remove datev2 signature of microsecond #35017

This commit is contained in:
zclllyybb
2024-05-19 14:20:57 +08:00
committed by yiguolei
parent 22f85be712
commit a6a398d7a4
4 changed files with 13 additions and 11 deletions

View File

@ -1815,7 +1815,7 @@ public class FunctionCallExpr extends Expr {
.toSql());
}
}
if (fn.getFunctionName().getFunction().equals("timediff")) {
if (fn.getFunctionName().getFunction().equalsIgnoreCase("timediff")) {
fn.getReturnType().getPrimitiveType().setTimeType();
ScalarType left = (ScalarType) argTypes[0];
ScalarType right = (ScalarType) argTypes[1];
@ -1826,17 +1826,17 @@ public class FunctionCallExpr extends Expr {
}
}
if (fn.getFunctionName().getFunction().equals("from_microsecond")) {
if (fn.getFunctionName().getFunction().equalsIgnoreCase("from_microsecond")) {
Type ret = ScalarType.createDatetimeV2Type(6);
fn.setReturnType(ret);
}
if (fn.getFunctionName().getFunction().equals("from_millisecond")) {
if (fn.getFunctionName().getFunction().equalsIgnoreCase("from_millisecond")) {
Type ret = ScalarType.createDatetimeV2Type(3);
fn.setReturnType(ret);
}
if (fn.getFunctionName().getFunction().equals("from_second")) {
if (fn.getFunctionName().getFunction().equalsIgnoreCase("from_second")) {
Type ret = ScalarType.createDatetimeV2Type(0);
fn.setReturnType(ret);
}
@ -1863,7 +1863,7 @@ public class FunctionCallExpr extends Expr {
}
}
if (fn.getFunctionName().getFunction().equals("struct_element")) {
if (fn.getFunctionName().getFunction().equalsIgnoreCase("struct_element")) {
if (children.size() < 2) {
throw new AnalysisException(fnName.getFunction() + " needs two parameters: " + this.toSql());
}
@ -1888,7 +1888,7 @@ public class FunctionCallExpr extends Expr {
}
}
if (fn.getFunctionName().getFunction().equals("sha2")) {
if (fn.getFunctionName().getFunction().equalsIgnoreCase("sha2")) {
if ((children.size() != 2) || (getChild(1).isConstant() == false)
|| !(getChild(1) instanceof IntLiteral)) {
throw new AnalysisException(
@ -2046,7 +2046,7 @@ public class FunctionCallExpr extends Expr {
* SELECT str_to_date("2020-09-01", "%Y-%m-%d %H:%i:%s");
* Return type is DATETIME
*/
if (fn.getFunctionName().getFunction().equals("str_to_date")) {
if (fn.getFunctionName().getFunction().equalsIgnoreCase("str_to_date")) {
Expr child1Result = getChild(1).getResultValue(false);
if (child1Result instanceof StringLiteral) {
if (DateLiteral.hasTimePart(child1Result.getStringValue())) {
@ -2085,7 +2085,7 @@ public class FunctionCallExpr extends Expr {
// cast(xx as char(N)/varchar(N)) will be handled as substr(cast(xx as char, varchar), 1, N),
// but type is varchar(*), we change it to varchar(N);
if (fn.getFunctionName().getFunction().equals("substr")
if (fn.getFunctionName().getFunction().equalsIgnoreCase("substr")
&& children.size() == 3
&& children.get(1) instanceof IntLiteral
&& children.get(2) instanceof IntLiteral) {

View File

@ -24,7 +24,6 @@ import org.apache.doris.nereids.trees.expressions.functions.PropagateNullableOnD
import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.DateTimeV2Type;
import org.apache.doris.nereids.types.DateV2Type;
import org.apache.doris.nereids.types.IntegerType;
import com.google.common.base.Preconditions;
@ -39,8 +38,7 @@ public class Microsecond extends ScalarFunction
implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullableOnDateLikeV2Args {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT),
FunctionSignature.ret(IntegerType.INSTANCE).args(DateV2Type.INSTANCE)
FunctionSignature.ret(IntegerType.INSTANCE).args(DateTimeV2Type.SYSTEM_DEFAULT)
);
/**