mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
Merge pull request #45244 from bigo-sg/improve_like
Add fast path for col like '%%' or col like '%' or match(col, '.*')
This commit is contained in:
commit
ff493c439c
@ -118,6 +118,16 @@ struct MatchImpl
|
||||
if (haystack_offsets.empty())
|
||||
return;
|
||||
|
||||
/// Shortcut for the silly but practical case that the pattern matches everything/nothing independently of the haystack:
|
||||
/// - col [not] [i]like '%' / '%%'
|
||||
/// - match(col, '.*')
|
||||
if ((is_like && (needle == "%" or needle == "%%")) || (!is_like && (needle == ".*" || needle == ".*?")))
|
||||
{
|
||||
for (auto & x : res)
|
||||
x = !negate;
|
||||
return;
|
||||
}
|
||||
|
||||
/// Special case that the [I]LIKE expression reduces to finding a substring in a string
|
||||
String strstr_pattern;
|
||||
if (is_like && impl::likePatternIsSubstring(needle, strstr_pattern))
|
||||
@ -267,6 +277,16 @@ struct MatchImpl
|
||||
if (haystack.empty())
|
||||
return;
|
||||
|
||||
/// Shortcut for the silly but practical case that the pattern matches everything/nothing independently of the haystack:
|
||||
/// - col [not] [i]like '%' / '%%'
|
||||
/// - match(col, '.*')
|
||||
if ((is_like && (needle == "%" or needle == "%%")) || (!is_like && (needle == ".*" || needle == ".*?")))
|
||||
{
|
||||
for (auto & x : res)
|
||||
x = !negate;
|
||||
return;
|
||||
}
|
||||
|
||||
/// Special case that the [I]LIKE expression reduces to finding a substring in a string
|
||||
String strstr_pattern;
|
||||
if (is_like && impl::likePatternIsSubstring(needle, strstr_pattern))
|
||||
|
Loading…
Reference in New Issue
Block a user