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

gabriellee 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 0dce725120 [fix](nereids)fix decimalv3 type error of mod operator 
(#20039)
0dce725120 is described below

commit 0dce72512020fe2e9991d7988644d6acd956e265
Author: starocean999 <40539150+starocean...@users.noreply.github.com>
AuthorDate: Thu May 25 17:25:11 2023 +0800

    [fix](nereids)fix decimalv3 type error of mod operator (#20039)
---
 .../main/java/org/apache/doris/nereids/util/TypeCoercionUtils.java | 7 ++++---
 regression-test/data/nereids_syntax_p0/cast.out                    | 3 +++
 regression-test/suites/nereids_syntax_p0/cast.groovy               | 2 ++
 3 files changed, 9 insertions(+), 3 deletions(-)

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 e78286bc29..4f0594d829 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
@@ -580,12 +580,13 @@ public class TypeCoercionUtils {
                 return castChildren(binaryArithmetic, left, right, 
DoubleType.INSTANCE);
             }
 
-            // add, subtract should cast children to exactly same type as 
return type
+            // add, subtract and mod should cast children to exactly same type 
as return type
             if (binaryArithmetic instanceof Add
-                    || binaryArithmetic instanceof Subtract) {
+                    || binaryArithmetic instanceof Subtract
+                    || binaryArithmetic instanceof Mod) {
                 return castChildren(binaryArithmetic, left, right, retType);
             }
-            // multiply and mode do not need to cast children to same type
+            // multiply do not need to cast children to same type
             return binaryArithmetic.withChildren(castIfNotSameType(left, dt1), 
castIfNotSameType(right, dt2));
         }
 
diff --git a/regression-test/data/nereids_syntax_p0/cast.out 
b/regression-test/data/nereids_syntax_p0/cast.out
index b52dc5ac96..68689ed370 100644
--- a/regression-test/data/nereids_syntax_p0/cast.out
+++ b/regression-test/data/nereids_syntax_p0/cast.out
@@ -266,3 +266,6 @@ true        0.1
 -- !group31 --
 1
 
+-- !sql_test_DecimalV3_mode --
+1.0
+
diff --git a/regression-test/suites/nereids_syntax_p0/cast.groovy 
b/regression-test/suites/nereids_syntax_p0/cast.groovy
index 1f035256f4..8618ef7b10 100644
--- a/regression-test/suites/nereids_syntax_p0/cast.groovy
+++ b/regression-test/suites/nereids_syntax_p0/cast.groovy
@@ -193,4 +193,6 @@ suite("cast") {
         sql "select true + 1 + 'x'"
         exception "string literal 'x' cannot be cast to double"
     }
+
+    qt_sql_test_DecimalV3_mode """select cast(1 as DECIMALV3(1, 0)) % 2.1;""";
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to