add not like to atom map

This commit is contained in:
Duc Canh Le 2022-10-10 13:31:10 +08:00
parent 03be5ffab7
commit f823b9a177
3 changed files with 27 additions and 0 deletions

View File

@ -560,6 +560,27 @@ 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<const String &>());
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)

View File

@ -0,0 +1,5 @@
CREATE TABLE data (str String) ENGINE=MergeTree ORDER BY str;
INSERT INTO data (str) SELECT 'aa' FROM numbers(100000);
INSERT INTO data (str) SELECT 'ba' FROM numbers(100000);
INSERT INTO data (str) SELECT 'ca' FROM numbers(100000);
SELECT count()FROM data WHERE str NOT LIKE 'a%' SETTINGS force_primary_key=1;