[fix](function)timediff with now function causes a error signature (… (#39349)
…#39322) https://github.com/apache/doris/pull/39322 ## Proposed changes ``` mysql [(none)]>select round(timediff(now(),'2024-08-15')/60/60,2); ERROR 1105 (HY000): errCode = 2, detailMessage = argument 1 requires datetimev2 type, however 'now()' is of datetime type ``` The reason is that the function parameter types were modified in expectedInputTypes, which led to no match being found. The code here is from a long time ago. Because the precision of datetimev2 could not be deduced in the past, a separate implementation was made here. This code can be safely deleted. <!--Describe your changes.--> ## Proposed changes Issue Number: close #xxx <!--Describe your changes.-->
This commit is contained in:
@ -21,10 +21,8 @@ import org.apache.doris.catalog.FunctionSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.Expression;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullableOnDateLikeV2Args;
|
||||
import org.apache.doris.nereids.trees.expressions.literal.StringLikeLiteral;
|
||||
import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression;
|
||||
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
|
||||
import org.apache.doris.nereids.types.DataType;
|
||||
import org.apache.doris.nereids.types.DateTimeType;
|
||||
import org.apache.doris.nereids.types.DateTimeV2Type;
|
||||
import org.apache.doris.nereids.types.DateV2Type;
|
||||
@ -96,20 +94,4 @@ public class TimeDiff extends ScalarFunction
|
||||
}
|
||||
return signature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DataType> expectedInputTypes() {
|
||||
FunctionSignature signature = getSignature();
|
||||
if (getArgument(0) instanceof StringLikeLiteral) {
|
||||
StringLikeLiteral str = (StringLikeLiteral) getArgument(0);
|
||||
DateTimeV2Type left = DateTimeV2Type.forTypeFromString(str.getStringValue());
|
||||
signature = signature.withArgumentType(0, left);
|
||||
}
|
||||
if (getArgument(1) instanceof StringLikeLiteral) {
|
||||
StringLikeLiteral str = (StringLikeLiteral) getArgument(1);
|
||||
DateTimeV2Type right = DateTimeV2Type.forTypeFromString(str.getStringValue());
|
||||
signature = signature.withArgumentType(1, right);
|
||||
}
|
||||
return signature.argumentsTypes;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user