Presto: Implement ILIKE predicate

Created on 13 Jan 2020  Â·  10Comments  Â·  Source: prestosql/presto

Comparing case-insensitive strings can be source for confusion.
we must use lower() on both sides of the query like shown:
https://stackoverflow.com/questions/42850329/how-to-configure-presto-searches-to-be-case-insensitive

Some DBs like PostgreSQL extended to support also ILIKE

The key word ILIKE can be used instead of LIKE to make the match case-insensitive according to the active locale. This is not in the SQL standard but is a PostgreSQL extension.

The operator ~~ is equivalent to LIKE, and ~~ * corresponds to ILIKE. There are also !~~ and !~~* operators that represent NOT LIKE and NOT ILIKE, respectively. All of these operators are PostgreSQL-specific.

https://www.postgresql.org/docs/current/functions-matching.html

This is very useful. I hope this can be added to Presto.

enhancement syntax-needs-review

Most helpful comment

We also could just add a function.

All 10 comments

I know it isn't the same, but Presto does support case insensitive regular expression matching with (?i) flag. See https://prestosql.io/docs/current/functions/regexp.html for more information.

so maybe on the backside the ILIKE can be implemented with regexp ?

The existing LIKE is implemented with a regular expression, so if ILIKE is added I would expect the same.

Adding the optional keyword might be one of the candidates. This is Teradata syntax to control the case sensitivity.

SELECT empname FROM tbl_emp WHERE empname LIKE '%JO%’;
SELECT empname FROM tbl_emp WHERE empname (CASESPECIFIC) LIKE '%JO%’;

We also could just add a function.

Yes, a function would be more appropriate than adding dedicated non-standard syntax.

I wonder why PostgreSQL choose ILIKE over a function in this case. They must had a reason

it is also ILIKE in Impala and SnowFlake if it is worth something. Came here looking how to do ILIKE in presto :)

@martint @ebyhr Does the "syntax needs review" label means that only after someone submit PR you will check if this idea is good or not? If there is no intention of accepting this there is no reason to keep this issue alive.

@RosterIn We use syntax needs review label when the syntax isn't yet decided. It doesn't mean PR won't be accepted.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jiangzhx picture jiangzhx  Â·  5Comments

bill-warshaw picture bill-warshaw  Â·  4Comments

findepi picture findepi  Â·  4Comments

JamesRTaylor picture JamesRTaylor  Â·  5Comments

electrum picture electrum  Â·  5Comments