From 3a981de64309edf608c833433827bd52ddae91b1 Mon Sep 17 00:00:00 2001 From: sundy-li <543950155@qq.com> Date: Tue, 9 Nov 2021 10:57:37 +0800 Subject: [PATCH] ISSUES-30801: Remove not like function into RPNElement --- src/Storages/MergeTree/KeyCondition.cpp | 21 ------------------- .../01891_not_like_partition_prune.reference | 6 ++++++ .../01891_not_like_partition_prune.sql | 9 ++++++++ 3 files changed, 15 insertions(+), 21 deletions(-) create mode 100644 tests/queries/0_stateless/01891_not_like_partition_prune.reference create mode 100644 tests/queries/0_stateless/01891_not_like_partition_prune.sql diff --git a/src/Storages/MergeTree/KeyCondition.cpp b/src/Storages/MergeTree/KeyCondition.cpp index dda7f235d97..f8f6bfff0ae 100644 --- a/src/Storages/MergeTree/KeyCondition.cpp +++ b/src/Storages/MergeTree/KeyCondition.cpp @@ -276,27 +276,6 @@ const KeyCondition::AtomMap KeyCondition::atom_map return true; } }, - { - "notLike", - [] (RPNElement & out, const Field & value) - { - if (value.getType() != Field::Types::String) - return false; - - String prefix = extractFixedPrefixFromLikePattern(value.get()); - if (prefix.empty()) - return false; - - String right_bound = firstStringThatIsGreaterThanAllStringsWithPrefix(prefix); - - out.function = RPNElement::FUNCTION_NOT_IN_RANGE; - out.range = !right_bound.empty() - ? Range(prefix, true, right_bound, false) - : Range::createLeftBounded(prefix, true); - - return true; - } - }, { "startsWith", [] (RPNElement & out, const Field & value) diff --git a/tests/queries/0_stateless/01891_not_like_partition_prune.reference b/tests/queries/0_stateless/01891_not_like_partition_prune.reference new file mode 100644 index 00000000000..9dcd05ad5b7 --- /dev/null +++ b/tests/queries/0_stateless/01891_not_like_partition_prune.reference @@ -0,0 +1,6 @@ +1.1 +1 +1.2 +1.12 +1 +1.1 diff --git a/tests/queries/0_stateless/01891_not_like_partition_prune.sql b/tests/queries/0_stateless/01891_not_like_partition_prune.sql new file mode 100644 index 00000000000..6a1842e4a03 --- /dev/null +++ b/tests/queries/0_stateless/01891_not_like_partition_prune.sql @@ -0,0 +1,9 @@ +drop table if exists test; + +create table test (a String) Engine MergeTree order by a partition by a; +insert into test values('1'), ('1.1'), ('1.2'), ('1.12'); + +select * from test where a like '1%1'; +select * from test where a not like '1%1'; +select * from test where a not like '1%2'; +drop table test;