From 7ad72bbcb8f9e9533cfe7c6d84e7f4f5d9fc98bc Mon Sep 17 00:00:00 2001 From: EmmyMiao87 <522274284@qq.com> Date: Tue, 5 Nov 2019 20:31:23 +0800 Subject: [PATCH] Enable decimalV2 cast to different precision (#2131) The precision of cast function is useless. For example, Query: select cast(10 as decimal(1,0)); Result: 10 Although numeric field is overflow, the numeric could be return. So, the cast function from decimal(a,b) to decimal(c,d) could not be executed. --- fe/src/main/java/org/apache/doris/analysis/CastExpr.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fe/src/main/java/org/apache/doris/analysis/CastExpr.java b/fe/src/main/java/org/apache/doris/analysis/CastExpr.java index ba1c81977e..2f78e15a9b 100644 --- a/fe/src/main/java/org/apache/doris/analysis/CastExpr.java +++ b/fe/src/main/java/org/apache/doris/analysis/CastExpr.java @@ -176,7 +176,7 @@ public class CastExpr extends Expr { Type childType = getChild(0).getType(); // this cast may result in loss of precision, but the user requested it - if (childType.equals(type)) { + if (childType.matchesType(type)) { noOp = true; return; }