[Fix](Planner) fix cast from decimal to boolean (#19585)

This commit is contained in:
LiBinfeng
2023-05-15 15:13:16 +08:00
committed by GitHub
parent 2a02561863
commit 052c7cff89
3 changed files with 36 additions and 0 deletions

View File

@ -27,6 +27,7 @@ import org.apache.doris.analysis.Expr;
import org.apache.doris.analysis.IntLiteral;
import org.apache.doris.analysis.LiteralExpr;
import org.apache.doris.analysis.SlotRef;
import org.apache.doris.catalog.PrimitiveType;
import org.apache.doris.catalog.Type;
import org.apache.doris.common.AnalysisException;
@ -123,6 +124,7 @@ public class RewriteBinaryPredicatesRule implements ExprRewriteRule {
if (expr0 instanceof CastExpr && (expr0.getType() == Type.DECIMALV2 || expr0.getType().isDecimalV3())
&& expr0.getChild(0) instanceof SlotRef
&& expr0.getChild(0).getType().getResultType() == Type.BIGINT
&& expr0.getChild(0).getType().getPrimitiveType() != PrimitiveType.BOOLEAN
&& expr1 instanceof DecimalLiteral) {
return rewriteBigintSlotRefCompareDecimalLiteral(expr0,
expr0.getChild(0).getType(), (DecimalLiteral) expr1, op);