apache / doris

Apache Doris is an easy-to-use, high performance and unified analytics database.
https://doris.apache.org
Apache License 2.0
12.39k stars 3.22k forks source link

[Bug] fuzzy matching error of like '%%' #35693

Open boluoge opened 4 months ago

boluoge commented 4 months ago

Search before asking

Version

doris-2.0.3

What's Wrong?

the match result is error,in my example,‘gzt’ should not be match

What You Expected?

What is the reason for this error?

How to Reproduce?

select 'DCache.LiveLinkWanzhePanelDataKKV_gztMKVCacheServer3' like 'DCache.LiveLinkWanzhePanelData%MKVCacheServer%'

Anything Else?

No response

Are you willing to submit PR?

Code of Conduct

boluoge commented 4 months ago

Sorry, there was an error in my description of What's Wrong. Please correct it as follows: ‘KKV’ should not be match

Dragonliu2018 commented 4 months ago

the underscore (_) represents a single character. refer to doris - like I guess you want to use the literal underscore (_), so u should prepend it with a backslash: \_.
such as:

mysql> select 'DCache.LiveLinkWanzhePanelDataKKV_gzt_MKVCacheServer3' like 'DCache.LiveLinkWanzhePanelData_%MKVCacheServer%';
+------------------------------------------------------------------------------------------------------------------+
| ('DCache.LiveLinkWanzhePanelDataKKV_gzt_MKVCacheServer3' like 'DCache.LiveLinkWanzhePanelData_%MKVCacheServer%') |
+------------------------------------------------------------------------------------------------------------------+
|                                                                                                                1 |
+------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> select 'DCache.LiveLinkWanzhePanelDataKKV_gzt_MKVCacheServer3' like 'DCache.LiveLinkWanzhePanelData\_%MKVCacheServer%';
+-------------------------------------------------------------------------------------------------------------------+
| ('DCache.LiveLinkWanzhePanelDataKKV_gzt_MKVCacheServer3' like 'DCache.LiveLinkWanzhePanelData\_%MKVCacheServer%') |
+-------------------------------------------------------------------------------------------------------------------+
|                                                                                                                 0 |
+-------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)