This is an automated email from the ASF dual-hosted git repository.
yiguolei 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 dcdc81844f [fix](nereids)use same decimalv3 type for params and return
types (#20101)
dcdc81844f is described below
commit dcdc81844f5016cb31011beccff7ccc644e3b3bc
Author: starocean999 <[email protected]>
AuthorDate: Fri May 26 20:15:51 2023 +0800
[fix](nereids)use same decimalv3 type for params and return types (#20101)
---
.../main/java/org/apache/doris/analysis/ArithmeticExpr.java | 12 ++++++++++--
.../java/org/apache/doris/nereids/trees/expressions/Mod.java | 4 +++-
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/analysis/ArithmeticExpr.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/ArithmeticExpr.java
index c863f06194..4bf92c6c4b 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ArithmeticExpr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ArithmeticExpr.java
@@ -512,8 +512,16 @@ public class ArithmeticExpr extends Expr {
}
castChild(ScalarType.createDecimalV3Type(precision,
targetScale), 0);
} else if (op == Operator.MOD) {
- castChild(type, 0);
- castChild(type, 1);
+ // TODO use max int part + max scale of two operands as
result type
+ // because BE require the result and operands types are
the exact the same decimalv3 type
+ precision = Math.max(widthOfIntPart1, widthOfIntPart2) +
scale;
+ if (precision > ScalarType.MAX_DECIMAL128_PRECISION) {
+ type = castBinaryOp(Type.DOUBLE);
+ } else {
+ type = ScalarType.createDecimalV3Type(precision,
scale);
+ castChild(type, 0);
+ castChild(type, 1);
+ }
}
break;
case INT_DIVIDE:
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Mod.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Mod.java
index f7e1443f39..8154d4afbc 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Mod.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Mod.java
@@ -44,8 +44,10 @@ public class Mod extends BinaryArithmetic implements
AlwaysNullable {
@Override
public DecimalV3Type getDataTypeForDecimalV3(DecimalV3Type t1,
DecimalV3Type t2) {
+ // TODO use max int part + max scale of two operands as result type
+ // because BE require the result and operands types are the exact the
same decimalv3 type
int scale = Math.max(t1.getScale(), t2.getScale());
- int precision = t2.getRange() + scale;
+ int precision = Math.max(t1.getRange(), t2.getRange()) + scale;
return DecimalV3Type.createDecimalV3Type(precision, scale);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]