[fix](Nereids) round function return type should be double (#15502)

This commit is contained in:
morrySnow
2022-12-30 23:36:15 +08:00
committed by GitHub
parent 96518db263
commit 781fa17993
4 changed files with 24 additions and 4 deletions

View File

@ -22,7 +22,6 @@ 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.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BigIntType;
import org.apache.doris.nereids.types.DoubleType;
import org.apache.doris.nereids.types.IntegerType;
@ -38,7 +37,7 @@ public class Round extends ScalarFunction
implements ExplicitlyCastableSignature, PropagateNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BigIntType.INSTANCE).args(DoubleType.INSTANCE),
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE),
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, IntegerType.INSTANCE)
);

View File

@ -22,7 +22,6 @@ 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.PropagateNullable;
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
import org.apache.doris.nereids.types.BigIntType;
import org.apache.doris.nereids.types.DoubleType;
import org.apache.doris.nereids.types.IntegerType;
@ -38,7 +37,7 @@ public class RoundBankers extends ScalarFunction
implements ExplicitlyCastableSignature, PropagateNullable {
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
FunctionSignature.ret(BigIntType.INSTANCE).args(DoubleType.INSTANCE),
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE),
FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, IntegerType.INSTANCE)
);

View File

@ -26,3 +26,15 @@
-- !select --
16.020 16.02000 16.02000
-- !nereids_round_arg1 --
10.0
-- !nereids_round_arg2 --
10.12
-- !nereids_round_bankers_arg1 --
10.0
-- !nereids_round_bankers_arg2 --
10.12

View File

@ -37,4 +37,14 @@ suite("test_round") {
qt_select """ SELECT truncate(col1, 2), truncate(col2, 2), truncate(col3, 2) FROM `${tableName}`; """
qt_select """ SELECT round_bankers(col1, 2), round_bankers(col2, 2), round_bankers(col3, 2) FROM `${tableName}`; """
sql """ DROP TABLE IF EXISTS `${tableName}` """
sql "SET enable_nereids_planner=true"
sql "SET enable_vectorized_engine=true"
sql "SET enable_fallback_to_original_planner=false"
qt_nereids_round_arg1 "SELECT round(10.12345)"
qt_nereids_round_arg2 "SELECT round(10.12345, 2)"
qt_nereids_round_bankers_arg1 "SELECT round_bankers(10.12345)"
qt_nereids_round_bankers_arg2 "SELECT round_bankers(10.12345, 2)"
}