diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Ceil.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Ceil.java index 0e388c5db3..4be7f7a454 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Ceil.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Ceil.java @@ -25,7 +25,6 @@ import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable; import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression; import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; import org.apache.doris.nereids.types.DecimalV3Type; -import org.apache.doris.nereids.types.DoubleType; import org.apache.doris.nereids.types.IntegerType; import com.google.common.base.Preconditions; @@ -40,7 +39,6 @@ public class Ceil extends ScalarFunction implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable, ComputePrecisionForRound { public static final List SIGNATURES = ImmutableList.of( - FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE), FunctionSignature.ret(DecimalV3Type.WILDCARD).args(DecimalV3Type.WILDCARD), FunctionSignature.ret(DecimalV3Type.WILDCARD).args(DecimalV3Type.WILDCARD, IntegerType.INSTANCE) ); diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dceil.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dceil.java index bb0f6f0216..7102cb948d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dceil.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dceil.java @@ -25,7 +25,6 @@ import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable; import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression; import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; import org.apache.doris.nereids.types.DecimalV3Type; -import org.apache.doris.nereids.types.DoubleType; import org.apache.doris.nereids.types.IntegerType; import com.google.common.base.Preconditions; @@ -40,7 +39,6 @@ public class Dceil extends ScalarFunction implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable, ComputePrecisionForRound { public static final List SIGNATURES = ImmutableList.of( - FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE), FunctionSignature.ret(DecimalV3Type.WILDCARD).args(DecimalV3Type.WILDCARD), FunctionSignature.ret(DecimalV3Type.WILDCARD).args(DecimalV3Type.WILDCARD, IntegerType.INSTANCE) ); diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dfloor.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dfloor.java index ec2039e121..df9f7bbb93 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dfloor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dfloor.java @@ -25,7 +25,6 @@ import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable; import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression; import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; import org.apache.doris.nereids.types.DecimalV3Type; -import org.apache.doris.nereids.types.DoubleType; import org.apache.doris.nereids.types.IntegerType; import com.google.common.base.Preconditions; @@ -40,7 +39,6 @@ public class Dfloor extends ScalarFunction implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable, ComputePrecisionForRound { public static final List SIGNATURES = ImmutableList.of( - FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE), FunctionSignature.ret(DecimalV3Type.WILDCARD).args(DecimalV3Type.WILDCARD), FunctionSignature.ret(DecimalV3Type.WILDCARD).args(DecimalV3Type.WILDCARD, IntegerType.INSTANCE) ); diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dround.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dround.java index bb2502e8c9..29fe1516fb 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dround.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Dround.java @@ -24,7 +24,6 @@ import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSi import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable; import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; import org.apache.doris.nereids.types.DecimalV3Type; -import org.apache.doris.nereids.types.DoubleType; import org.apache.doris.nereids.types.IntegerType; import com.google.common.base.Preconditions; @@ -39,8 +38,6 @@ public class Dround extends ScalarFunction implements ExplicitlyCastableSignature, PropagateNullable, ComputePrecisionForRound { public static final List SIGNATURES = ImmutableList.of( - FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE), - FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, IntegerType.INSTANCE), FunctionSignature.ret(DecimalV3Type.WILDCARD).args(DecimalV3Type.WILDCARD), FunctionSignature.ret(DecimalV3Type.WILDCARD).args(DecimalV3Type.WILDCARD, IntegerType.INSTANCE) ); diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Floor.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Floor.java index 9e9f2c7d7b..e6b60cb791 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Floor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Floor.java @@ -25,7 +25,6 @@ import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable; import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression; import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; import org.apache.doris.nereids.types.DecimalV3Type; -import org.apache.doris.nereids.types.DoubleType; import org.apache.doris.nereids.types.IntegerType; import com.google.common.base.Preconditions; @@ -40,7 +39,6 @@ public class Floor extends ScalarFunction implements UnaryExpression, ExplicitlyCastableSignature, PropagateNullable, ComputePrecisionForRound { public static final List SIGNATURES = ImmutableList.of( - FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE), FunctionSignature.ret(DecimalV3Type.WILDCARD).args(DecimalV3Type.WILDCARD), FunctionSignature.ret(DecimalV3Type.WILDCARD).args(DecimalV3Type.WILDCARD, IntegerType.INSTANCE) ); diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Round.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Round.java index 7f0e266acc..ac7afc7774 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Round.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Round.java @@ -24,7 +24,6 @@ import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSi import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable; import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; import org.apache.doris.nereids.types.DecimalV3Type; -import org.apache.doris.nereids.types.DoubleType; import org.apache.doris.nereids.types.IntegerType; import com.google.common.base.Preconditions; @@ -39,8 +38,6 @@ public class Round extends ScalarFunction implements ExplicitlyCastableSignature, PropagateNullable, ComputePrecisionForRound { public static final List SIGNATURES = ImmutableList.of( - FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE), - FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, IntegerType.INSTANCE), FunctionSignature.ret(DecimalV3Type.WILDCARD).args(DecimalV3Type.WILDCARD), FunctionSignature.ret(DecimalV3Type.WILDCARD).args(DecimalV3Type.WILDCARD, IntegerType.INSTANCE) ); diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/RoundBankers.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/RoundBankers.java index 5697ae277e..a7b0f50e8b 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/RoundBankers.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/RoundBankers.java @@ -24,7 +24,6 @@ import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSi import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable; import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; import org.apache.doris.nereids.types.DecimalV3Type; -import org.apache.doris.nereids.types.DoubleType; import org.apache.doris.nereids.types.IntegerType; import com.google.common.base.Preconditions; @@ -39,8 +38,6 @@ public class RoundBankers extends ScalarFunction implements ExplicitlyCastableSignature, PropagateNullable, ComputePrecisionForRound { public static final List SIGNATURES = ImmutableList.of( - FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE), - FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, IntegerType.INSTANCE), FunctionSignature.ret(DecimalV3Type.WILDCARD).args(DecimalV3Type.WILDCARD), FunctionSignature.ret(DecimalV3Type.WILDCARD).args(DecimalV3Type.WILDCARD, IntegerType.INSTANCE) ); diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Truncate.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Truncate.java index 83af5293cd..fbf3a59b29 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Truncate.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/Truncate.java @@ -25,7 +25,6 @@ import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable; import org.apache.doris.nereids.trees.expressions.shape.BinaryExpression; import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; import org.apache.doris.nereids.types.DecimalV3Type; -import org.apache.doris.nereids.types.DoubleType; import org.apache.doris.nereids.types.IntegerType; import com.google.common.base.Preconditions; @@ -40,7 +39,6 @@ public class Truncate extends ScalarFunction implements BinaryExpression, ExplicitlyCastableSignature, PropagateNullable, ComputePrecisionForRound { public static final List SIGNATURES = ImmutableList.of( - FunctionSignature.ret(DoubleType.INSTANCE).args(DoubleType.INSTANCE, IntegerType.INSTANCE), FunctionSignature.ret(DecimalV3Type.WILDCARD).args(DecimalV3Type.WILDCARD, IntegerType.INSTANCE) ); diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/UdfTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/UdfTest.java index 35cb8ba14d..d068bb6c17 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/UdfTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/expressions/UdfTest.java @@ -34,6 +34,7 @@ import org.apache.doris.nereids.trees.expressions.literal.TinyIntLiteral; import org.apache.doris.nereids.trees.expressions.literal.VarcharLiteral; import org.apache.doris.nereids.types.DateTimeV2Type; import org.apache.doris.nereids.types.DateV2Type; +import org.apache.doris.nereids.types.DecimalV3Type; import org.apache.doris.nereids.types.DoubleType; import org.apache.doris.nereids.types.IntegerType; import org.apache.doris.nereids.util.PlanChecker; @@ -145,7 +146,7 @@ public class UdfTest extends TestWithFeService implements PlanPatternMatchSuppor new VarcharLiteral("day")), new Cast(new Add( new Multiply( - new Floor(new Divide( + new Floor(new Cast(new Divide( new Cast( new Hour(new Cast(new VarcharLiteral("2023-05-20 12:23:45"), DateTimeV2Type.SYSTEM_DEFAULT)), DoubleType.INSTANCE @@ -153,11 +154,11 @@ public class UdfTest extends TestWithFeService implements PlanPatternMatchSuppor new Divide( new Cast(new TinyIntLiteral(((byte) 24)), DoubleType.INSTANCE), new Cast(new IntegerLiteral(((byte) 3)), DoubleType.INSTANCE) - )) + )), DecimalV3Type.createDecimalV3Type(30, 15)) ), - new Cast(new TinyIntLiteral(((byte) 1)), DoubleType.INSTANCE) + new Cast(new TinyIntLiteral(((byte) 1)), DecimalV3Type.createDecimalV3Type(3, 0)) ), - new Cast(new TinyIntLiteral(((byte) 1)), DoubleType.INSTANCE) + new Cast(new TinyIntLiteral(((byte) 1)), DecimalV3Type.createDecimalV3Type(33, 0)) ), IntegerType.INSTANCE) ), new VarcharLiteral("%Y%m%d:%H") diff --git a/regression-test/data/nereids_function_p0/scalar_function/D.out b/regression-test/data/nereids_function_p0/scalar_function/D.out index 48a586d5b7..cbf4d8f532 100644 --- a/regression-test/data/nereids_function_p0/scalar_function/D.out +++ b/regression-test/data/nereids_function_p0/scalar_function/D.out @@ -2234,32 +2234,32 @@ Monday -- !sql_dceil_Double -- \N -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -2.0 -2.0 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +2 +2 -- !sql_dceil_Double_notnull -- -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -2.0 -2.0 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +2 +2 -- !sql_dceil_DecimalV3S1 -- \N @@ -2495,32 +2495,32 @@ Monday -- !sql_dfloor_Double -- \N -0.0 -0.0 -0.0 -0.0 -0.0 -0.0 -0.0 -0.0 -0.0 -1.0 -1.0 -1.0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +1 +1 -- !sql_dfloor_Double_notnull -- -0.0 -0.0 -0.0 -0.0 -0.0 -0.0 -0.0 -0.0 -0.0 -1.0 -1.0 -1.0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +1 +1 -- !sql_dfloor_DecimalV3S1 -- \N @@ -2761,12 +2761,12 @@ Monday -0.5228787452803376 -0.3979400086720376 -0.3010299956639812 --0.22184874961635637 +-0.2218487496163564 -0.1549019599857432 -0.09691001300805639 -0.045757490560675115 0.0 -0.04139268515822507 +0.04139268515822508 0.07918124604762482 -- !sql_dlog10_Double_notnull -- @@ -2775,12 +2775,12 @@ Monday -0.5228787452803376 -0.3979400086720376 -0.3010299956639812 --0.22184874961635637 +-0.2218487496163564 -0.1549019599857432 -0.09691001300805639 -0.045757490560675115 0.0 -0.04139268515822507 +0.04139268515822508 0.07918124604762482 -- !sql_domain_String -- @@ -2872,61 +2872,61 @@ Monday -- !sql_dround_Double -- \N -0.0 -0.0 -0.0 -0.0 -0.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 +0 +0 +0 +0 +1 +1 +1 +1 +1 +1 +1 +1 -- !sql_dround_Double_notnull -- -0.0 -0.0 -0.0 -0.0 -0.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 +0 +0 +0 +0 +1 +1 +1 +1 +1 +1 +1 +1 -- !sql_dround_Double_Integer -- \N -0.1 -0.2 -0.3 -0.4 -0.5 -0.6 -0.7 -0.8 -0.9 -1.0 -1.1 -1.2 +0.10 +0.20 +0.30 +0.40 +0.50 +0.60 +0.70 +0.80 +0.90 +1.00 +1.10 +1.20 -- !sql_dround_Double_Integer_notnull -- -0.1 -0.2 -0.3 -0.4 -0.5 -0.6 -0.7 -0.8 -0.9 -1.0 -1.1 -1.2 +0.10 +0.20 +0.30 +0.40 +0.50 +0.60 +0.70 +0.80 +0.90 +1.00 +1.10 +1.20 -- !sql_dround_DecimalV3S1 -- \N diff --git a/regression-test/data/nereids_function_p0/scalar_function/R.out b/regression-test/data/nereids_function_p0/scalar_function/R.out index 3145c2c6dc..9c7be851d5 100644 --- a/regression-test/data/nereids_function_p0/scalar_function/R.out +++ b/regression-test/data/nereids_function_p0/scalar_function/R.out @@ -436,61 +436,61 @@ string3 -- !sql_round_Double -- \N -0.0 -0.0 -0.0 -0.0 -0.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 +0 +0 +0 +0 +1 +1 +1 +1 +1 +1 +1 +1 -- !sql_round_Double_notnull -- -0.0 -0.0 -0.0 -0.0 -0.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 +0 +0 +0 +0 +1 +1 +1 +1 +1 +1 +1 +1 -- !sql_round_Double_Integer -- \N -0.1 -0.2 -0.3 -0.4 -0.5 -0.6 -0.7 -0.8 -0.9 -1.0 -1.1 -1.2 +0.10 +0.20 +0.30 +0.40 +0.50 +0.60 +0.70 +0.80 +0.90 +1.00 +1.10 +1.20 -- !sql_round_Double_Integer_notnull -- -0.1 -0.2 -0.3 -0.4 -0.5 -0.6 -0.7 -0.8 -0.9 -1.0 -1.1 -1.2 +0.10 +0.20 +0.30 +0.40 +0.50 +0.60 +0.70 +0.80 +0.90 +1.00 +1.10 +1.20 -- !sql_round_DecimalV3S1 -- \N @@ -668,61 +668,61 @@ string3 -- !sql_round_bankers_Double -- \N -0.0 -0.0 -0.0 -0.0 -0.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 +0 +0 +0 +0 +0 +1 +1 +1 +1 +1 +1 +1 -- !sql_round_bankers_Double_notnull -- -0.0 -0.0 -0.0 -0.0 -0.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 -1.0 +0 +0 +0 +0 +0 +1 +1 +1 +1 +1 +1 +1 -- !sql_round_bankers_Double_Integer -- \N -0.1 -0.2 -0.3 -0.4 -0.5 -0.6 -0.7 -0.8 -0.9 -1.0 -1.1 -1.2 +0.10 +0.20 +0.30 +0.40 +0.50 +0.60 +0.70 +0.80 +0.90 +1.00 +1.10 +1.20 -- !sql_round_bankers_Double_Integer_notnull -- -0.1 -0.2 -0.3 -0.4 -0.5 -0.6 -0.7 -0.8 -0.9 -1.0 -1.1 -1.2 +0.10 +0.20 +0.30 +0.40 +0.50 +0.60 +0.70 +0.80 +0.90 +1.00 +1.10 +1.20 -- !sql_round_bankers_DecimalV3S1 -- \N diff --git a/regression-test/data/query_p0/sql_functions/math_functions/test_round.out b/regression-test/data/query_p0/sql_functions/math_functions/test_round.out index 155e438c9e..c126a6dd55 100644 --- a/regression-test/data/query_p0/sql_functions/math_functions/test_round.out +++ b/regression-test/data/query_p0/sql_functions/math_functions/test_round.out @@ -12,9 +12,9 @@ 10.12 -- !truncate -- -1.0 1989.0 1001.0 123.1 0.1 6.3 -2.0 1986.0 1001.0 1243.5 20.2 789.2 -3.0 1989.0 1002.0 24453.3 78945.0 3654.0 +1 1989 1001 123.1 0.1 6.3 +2 1986 1001 1243.5 20.2 789.2 +3 1989 1002 24453.3 78945.0 3653.9 -- !select -- 16 16 16 @@ -99,10 +99,10 @@ 247.14 469.36 691.58 -- !query -- -200 500 700 +200.0 500.0 700.0 -- !query -- -0 0 0 +0.0 0.0 0.0 -- !query -- 247.136 469.358 691.579 @@ -114,4 +114,5 @@ 200.000 500.000 700.000 -- !query -- -0.000 0.000 0.000 \ No newline at end of file +0.000 0.000 0.000 +