Skip to content

Conversation

@bvolpato
Copy link
Member

@bvolpato bvolpato commented Nov 19, 2025

Description

This PR implements the ILIKE operator for case-insensitive pattern matching, addressing #2491. ILIKE follows PostgreSQL semantics and works like LIKE but ignores case differences in both the value and pattern.

The implementation provides a native way to perform case-insensitive pattern matching without requiring manual lower() calls on both sides of the comparison.

Additional context and related issues

Rather than creating a separate ILIKE AST node, the implementation extends the existing LikePredicate with a caseInsensitive boolean flag. This minimizes code duplication and leverages the existing pattern matching infrastructure.

Compatibility:
ILIKE is natively supported by PostgreSQL, Snowflake, DuckDB, Databricks, and Redshift. This implementation works with all Trino connectors - pushdown is enabled for PostgreSQL, while other connectors evaluate ILIKE in Trino's engine.

Release notes

(x) Release notes are required, with the following suggested text:

## General
* Add `ILIKE` operator for case-insensitive pattern matching. ({issue}`2491`)

   Implement ILIKE operator following PostgreSQL semantics for
   case-insensitive string pattern matching. ILIKE works like LIKE
   but ignores case differences in both the value and pattern.

   Changes:
   - Added ILIKE token and grammar rule to SqlBase.g4
   - Extended LikePredicate AST node with caseInsensitive flag
   - Implemented ilikeChar() and ilikeVarchar() functions in LikeFunctions
   - Added pattern compilation with case-insensitive support in LikePattern
   - Updated expression analyzer and formatter to handle ILIKE
   - Added PostgreSQL connector pushdown support for ILIKE
   - Added comprehensive test coverage in TestLikeFunctions

   The implementation converts both pattern and values to lowercase
   using Locale.ROOT for consistent case-insensitive matching across
   locales. Full support for ESCAPE clause is included.

   Fixes trinodb#2491
@cla-bot cla-bot bot added the cla-signed label Nov 19, 2025
@github-actions github-actions bot added the postgresql PostgreSQL connector label Nov 19, 2025
@findepi
Copy link
Member

findepi commented Nov 23, 2025

@martint can you please weight in #2491 to clear syntax review?

@martint
Copy link
Member

martint commented Nov 24, 2025

Since this can be easily implemented as a function, that’s the preferred approach instead of adding dedicated syntax that’s not covered by the SQL specification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

Implement ILIKE predicate

4 participants