This is an automated email from the ASF dual-hosted git repository.

morrysnow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 0f15d86c43 [fix](nereids) decimalv2 and float like type's common type 
should be consistant with old planner in arithmetic expr (#22654)
0f15d86c43 is described below

commit 0f15d86c43aa31fa6f6ee45ac17981a398324a4c
Author: starocean999 <[email protected]>
AuthorDate: Tue Aug 8 15:22:04 2023 +0800

    [fix](nereids) decimalv2 and float like type's common type should be 
consistant with old planner in arithmetic expr (#22654)
    
    when both decimalv2 and float like type in the arithmetic expr, the common 
type is depend on roundPreciseDecimalV2Value session variable. If it's true, 
the common type is DecimalV2Type.SYSTEM_DEFAULT, otherwise its double type.
---
 .../org/apache/doris/nereids/util/TypeCoercionUtils.java     | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/util/TypeCoercionUtils.java 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/util/TypeCoercionUtils.java
index afdc19b2fe..bc44e03f19 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/util/TypeCoercionUtils.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/util/TypeCoercionUtils.java
@@ -91,6 +91,7 @@ import org.apache.doris.nereids.types.coercion.FractionalType;
 import org.apache.doris.nereids.types.coercion.IntegralType;
 import org.apache.doris.nereids.types.coercion.NumericType;
 import org.apache.doris.nereids.types.coercion.PrimitiveType;
+import org.apache.doris.qe.ConnectContext;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.ImmutableList;
@@ -557,10 +558,19 @@ public class TypeCoercionUtils {
                 break;
             }
         }
-        if (commonType.isFloatType() && (t1.isDecimalV3Type() || 
t2.isDecimalV3Type())) {
+        if (commonType.isFloatLikeType() && (t1.isDecimalV3Type() || 
t2.isDecimalV3Type())) {
             commonType = DoubleType.INSTANCE;
         }
 
+        if (t1.isDecimalV2Type() || t2.isDecimalV2Type()) {
+            // to be consitent with old planner
+            // see findCommonType() method in ArithmeticExpr.java
+            commonType = t1.isDecimalV2Type() && t2.isDecimalV2Type()
+                    || (ConnectContext.get() != null
+                    && 
ConnectContext.get().getSessionVariable().roundPreciseDecimalV2Value)
+                    ? DecimalV2Type.SYSTEM_DEFAULT : DoubleType.INSTANCE;
+        }
+
         boolean isBitArithmetic = binaryArithmetic instanceof BitAnd
                 || binaryArithmetic instanceof BitOr
                 || binaryArithmetic instanceof BitXor;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to