[fix](datatype) fixed decimal type implicit cast handling in BinaryPredicate (#30181)

This commit is contained in:
Nitin-Kashyap
2024-01-24 07:27:23 +05:30
committed by yiguolei
parent 79d178ca54
commit f85b04c2c6
3 changed files with 101 additions and 2 deletions

View File

@ -1674,10 +1674,19 @@ public abstract class Expr extends TreeNode<Expr> implements ParseNode, Cloneabl
Type t2 = getChild(1).getType();
// add operand casts
Preconditions.checkState(compatibleType.isValid());
if (t1.getPrimitiveType() != compatibleType.getPrimitiveType()) {
if (t1.isDecimalV3() || t1.isDecimalV2()) {
if (!t1.equals(compatibleType)) {
castChild(compatibleType, 0);
}
} else if (t1.getPrimitiveType() != compatibleType.getPrimitiveType()) {
castChild(compatibleType, 0);
}
if (t2.getPrimitiveType() != compatibleType.getPrimitiveType()) {
if (t2.isDecimalV3() || t2.isDecimalV2()) {
if (!t2.equals(compatibleType)) {
castChild(compatibleType, 1);
}
} else if (t2.getPrimitiveType() != compatibleType.getPrimitiveType()) {
castChild(compatibleType, 1);
}
return compatibleType;