v.20.5Improvement
Enhanced Parsing of C-style Backslash Escapes for Better LIKE and Regular Expression Compatibility in ClickHouse
When parsing C-style backslash escapes in string literals, VALUES and various text formats (this is an extension to SQL standard that is endemic for ClickHouse and MySQL), keep backslash if unknown escape sequence is found (e.g.%or\w) that will make usage ofLIKEandmatchregular expressions more convenient (it's enough to writename LIKE 'used_cars'instead ofname LIKE 'used\_cars') and more compatible at the same time. This fixes #10922. #11208 (alexey-milovidov).
Why it matters
This feature addresses the problem of cumbersome escaping in string patterns involving backslashes, especially when usingLIKE and regex matches. By keeping unknown escape sequences intact (e.g., % or \w), it reduces the need for double escaping and improves compatibility with MySQL and user expectations, simplifying pattern writing.How to use it
No explicit configuration is needed. The updated parser automatically retains unknown backslash escapes in string literals, VALUES, and applicable text formats, allowing users to write patterns like:SELECT * FROM table WHERE name LIKE 'used_cars'instead of double escaping the underscore.