From 55cb78e0cbcf9dad3212a765edaf477c4a367845 Mon Sep 17 00:00:00 2001 From: felixwluo Date: Thu, 2 Apr 2026 19:15:27 +0800 Subject: [PATCH 1/2] [fix](delete) normalize DeleteSubPredicatePB operator on read path --- be/src/storage/delete/delete_handler.cpp | 7 ++- .../delete_p0/test_delete_nullsafe_eq.out | 3 ++ .../delete_p0/test_delete_nullsafe_eq.groovy | 45 +++++++++++++++++++ 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 regression-test/data/delete_p0/test_delete_nullsafe_eq.out create mode 100644 regression-test/suites/delete_p0/test_delete_nullsafe_eq.groovy diff --git a/be/src/storage/delete/delete_handler.cpp b/be/src/storage/delete/delete_handler.cpp index 8aab3c422966fd..c63ed89e1e70b8 100644 --- a/be/src/storage/delete/delete_handler.cpp +++ b/be/src/storage/delete/delete_handler.cpp @@ -225,7 +225,7 @@ std::string construct_sub_predicate(const TCondition& condition) { } // make operators from FE adaptive to BE -std::string trans_op(const std::string& opt) { +std::string trans_op(const std::string& opt, const std::string& condition_value = "") { std::string op = string(opt); if (op == "<") { op += "<"; @@ -237,6 +237,8 @@ std::string trans_op(const std::string& opt) { op = "="; } else if (op == "!*=") { op = "!="; + } else if (op == "<=>") { + op = iequal(condition_value, "NULL") ? "IS" : "="; } } return op; @@ -487,7 +489,8 @@ DeleteHandler::ConditionParseResult DeleteHandler::parse_condition( } res.column_name = sub_cond.column_name(); res.value_str.push_back(sub_cond.cond_value()); - res.condition_op = parse_condition_op(sub_cond.op(), res.value_str); + auto norm_op = trans_op(sub_cond.op(), sub_cond.cond_value()); + res.condition_op = parse_condition_op(norm_op, res.value_str); return res; } diff --git a/regression-test/data/delete_p0/test_delete_nullsafe_eq.out b/regression-test/data/delete_p0/test_delete_nullsafe_eq.out new file mode 100644 index 00000000000000..49c9d071663299 --- /dev/null +++ b/regression-test/data/delete_p0/test_delete_nullsafe_eq.out @@ -0,0 +1,3 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !after_delete -- +2 20 \ No newline at end of file diff --git a/regression-test/suites/delete_p0/test_delete_nullsafe_eq.groovy b/regression-test/suites/delete_p0/test_delete_nullsafe_eq.groovy new file mode 100644 index 00000000000000..ebfc6a91f78275 --- /dev/null +++ b/regression-test/suites/delete_p0/test_delete_nullsafe_eq.groovy @@ -0,0 +1,45 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +suite("test_delete_nullsafe_eq", "delete_p0") { + sql "DROP TABLE IF EXISTS test_delete_nullsafe_eq" + + sql """ + CREATE TABLE test_delete_nullsafe_eq ( + k1 INT, + v1 INT + ) + DUPLICATE KEY(k1) + DISTRIBUTED BY HASH(k1) BUCKETS 1 + PROPERTIES( + "replication_num" = "1", + "disable_auto_compaction" = "true" + ) + """ + + sql """INSERT INTO test_delete_nullsafe_eq VALUES (1, 10), (2, 20)""" + + try { + sql """SET delete_without_partition = true""" + sql """DELETE FROM test_delete_nullsafe_eq WHERE k1 <=> 1""" + sql """SYNC""" + + order_qt_after_delete """SELECT * FROM test_delete_nullsafe_eq ORDER BY k1""" + } finally { + sql """SET delete_without_partition = false""" + } +} \ No newline at end of file From 0d82ee95c41e6080c3dfef5d232e45fa4355369f Mon Sep 17 00:00:00 2001 From: felixwluo Date: Thu, 2 Apr 2026 19:19:09 +0800 Subject: [PATCH 2/2] format --- be/src/storage/delete/delete_handler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/be/src/storage/delete/delete_handler.cpp b/be/src/storage/delete/delete_handler.cpp index c63ed89e1e70b8..37a230b59e18ad 100644 --- a/be/src/storage/delete/delete_handler.cpp +++ b/be/src/storage/delete/delete_handler.cpp @@ -238,7 +238,7 @@ std::string trans_op(const std::string& opt, const std::string& condition_value } else if (op == "!*=") { op = "!="; } else if (op == "<=>") { - op = iequal(condition_value, "NULL") ? "IS" : "="; + op = iequal(condition_value, "NULL") ? "IS" : "="; } } return op;