IMPALA-15641: Interpret escapes in the fast paths of LIKE

LikePredicate::OptimizeConstantPatternMatch() matched constant patterns
and simple prefix, suffix and substring patterns verbatim, while the
regex path, which is also used for patterns that are not constant,
treats a backslash as an escape for any character and ignores a
trailing backslash. So the result depended on the shape of the
pattern, e.g. 'abc%x' LIKE 'abc\%%' was false, but
'abc%x' LIKE 'abc\%_%' was true. IMPALA-10849 and IMPALA-14731 fixed
this only for patterns that end with an escaped '%'.

Now all paths follow the same rule: a backslash escapes '%', '_' and
itself, and before any other character, or at the end of the pattern,
it is a literal backslash. This matches Hive, except that '\\' is two
backslashes in Hive. The fast paths are chosen and their search strings
computed after interpreting the escapes, so they are only an
optimization. Patterns that are not valid UTF-8 still take the regex
path, which rejects them.

Changed results, where '...' is any string and '?' is any character.
The patterns are after SQL string literal unescaping, e.g.
s LIKE 'C:\\dir%' is the pattern C:\dir%.

  Pattern    Path    Before        After
  abc\%%     fast    abc\...       abc%...
  %\%%       fast    ...\...       ...%...
  a\\b%      fast    a\\b...       a\b...
  C:\dir_%   regex   C:dir?...     C:\dir?...
  a%\        regex   a...          a...\

Patterns that are not constant and ILIKE always took the regex path,
e.g. C:\dir% matched C:dir... for them.

IcebergPredicateConverter mirrored the verbatim fast paths when pushing
down LIKE to Iceberg (IMPALA-15634). Now it unescapes every pattern the
same way as the backend.

Documented the escapes of LIKE and the change in the 5.0 incompatible
changes. Removed the IMPALA-2422 known issue, its example works since
IMPALA-10849.

Testing:
 - Added BE tests for the escapes, also checking that the fast paths
   match the same values as the regex for non-constant patterns.
 - Updated FE tests and added EE tests for LIKE push down with escapes.
 - Built plain-html docs without errors.

Change-Id: Ia8b6872a6a200bfadb36d3ee83869bde76b8f3a5
Assisted-by: Claude Opus 5.5 (Claude Code)
Reviewed-on: https://gerrit.cloudera.org/25198
Reviewed-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
10 files changed
tree: a2d9846e2e3920dab9e0a59feb2cc4ab94b307ca
  1. .agents/
  2. .devcontainer/
  3. .devcontainer-build/
  4. .vscode-defaults/
  5. be/
  6. bin/
  7. cmake_modules/
  8. common/
  9. docker/
  10. docs/
  11. fe/
  12. helm/
  13. infra/
  14. java/
  15. lib/
  16. operator/
  17. package/
  18. security/
  19. shell/
  20. ssh_keys/
  21. testdata/
  22. tests/
  23. www/
  24. .asf.yaml
  25. .clang-format
  26. .clang-tidy
  27. .gitattributes
  28. .gitignore
  29. .isort.cfg
  30. AGENTS.md
  31. buildall.sh
  32. CMakeLists.txt
  33. EXPORT_CONTROL.md
  34. LICENSE.txt
  35. LOGS.md
  36. NOTICE.txt
  37. README-build.md
  38. README.md
  39. SECURITY.md
  40. setup.cfg
README.md

Welcome to Impala

Lightning-fast, distributed SQL queries for petabytes of data stored in open data and table formats.

Impala is a modern, massively-distributed, massively-parallel, C++ query engine that lets you analyze, transform and combine data from a variety of data sources:

More about Impala

The fastest way to try out Impala is a quickstart Docker container. You can try out running queries and processing data sets in Impala on a single machine without installing dependencies. It can automatically load test data sets into Apache Kudu and Apache Parquet formats and you can start playing around with Apache Impala SQL within minutes.

To learn more about Impala as a user or administrator, or to try Impala, please visit the Impala homepage. Detailed documentation for administrators and users is available at Apache Impala documentation.

If you are interested in contributing to Impala as a developer, or learning more about Impala's internals and architecture, visit the Impala wiki.

Supported Platforms

Impala only supports Linux at the moment. Impala supports x86_64 and arm64 (as of Impala 4.4). Impala Requirements contains more detailed information on the minimum CPU requirements.

Supported OS Distributions

Impala runs on Linux systems only. The supported distros are

  • Ubuntu 20.04/22.04/24.04
  • Rocky/RHEL 8/9/10

Other systems, e.g. SLES15/16, may also be supported but are not tested by the community.

Export Control Notice

This distribution uses cryptographic software and may be subject to export controls. Please refer to EXPORT_CONTROL.md for more information.

Build Instructions

See Impala's developer documentation to get started.

Detailed build notes has some detailed information on the project layout and build.