diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/DeleteStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/DeleteStmt.java index 3ab422bdf3..6ad2c1285e 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/DeleteStmt.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/DeleteStmt.java @@ -245,8 +245,12 @@ public class DeleteStmt extends DdlStmt { binaryPredicate.setChild(1, binaryPredicate.getChild(1).castTo(binaryPredicate.getChild(0).getType())); binaryPredicate.analyze(analyzer); - ExprRewriter exprRewriter = new ExprRewriter(FoldConstantsRule.INSTANCE); - binaryPredicate.setChild(1, exprRewriter.rewrite(binaryPredicate.getChild(1), analyzer, null)); + Expr rightChild = binaryPredicate.getChild(1); + Expr rewrittenExpr = FoldConstantsRule.INSTANCE.apply(rightChild, analyzer, null); + if (rightChild != rewrittenExpr) { + binaryPredicate.setChild(1, rewrittenExpr); + } + Expr leftExpr = binaryPredicate.getChild(0); if (!(leftExpr instanceof SlotRef)) { throw new AnalysisException( diff --git a/regression-test/suites/delete_p0/test_delete.groovy b/regression-test/suites/delete_p0/test_delete.groovy index 635762a327..fd78c30d2e 100644 --- a/regression-test/suites/delete_p0/test_delete.groovy +++ b/regression-test/suites/delete_p0/test_delete.groovy @@ -407,4 +407,21 @@ suite("test_delete") { qt_check_data7 """ select * from every_type_table order by col_1; """ sql "drop table every_type_table" + + sql "drop table if exists test2" + sql """ + CREATE TABLE `test2` + ( + col_1 int, + col_2 decimalv2(10,3) + )ENGINE=OLAP + duplicate KEY(`col_1`) + COMMENT 'OLAP' + DISTRIBUTED BY HASH(`col_1`) BUCKETS 1 + PROPERTIES ( + "replication_allocation" = "tag.location.default: 1" + ); + """ + sql "set enable_fold_constant_by_be = true;" + sql "DELETE FROM test2 WHERE col_2 = cast(123.45 as decimalv2(10,3));" }