Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure Presto searches to be case-insensitive?

Tags:

presto

trino

In my case, Presto connects to a MySQL database which has been configured to be case-insensitive. But any search through Presto seems to be case-sensitive.

Questions:

1) Is there a way to configure Presto searches to be case-insensitive? If not, can something be changed in the Presto-MySQL connector to make the searches case-insensitive?

2) If underlying DB is case-insensitive, shouldn't Presto searches also be case-insensitive? (I presume that Presto only generates the query plan and the actual execution happens on the underlying database)

Example: Consider the below table on MySQL.

name
____
adam

Alan


select * from table where name like '%a%'
// returns adam, Alan on MySQL
// returns only adam on Presto

select * from table where name = 'Adam'
// returns adam on MySQL
// returns NIL on Presto
like image 573
felarof99 Avatar asked Mar 17 '17 06:03

felarof99


1 Answers

You have to explicitly ask for case-insensitive comparison by normalizing compared values either to-lower, or to-upper, like this:

select * from table where lower(name) like '%a%';

select * from table where lower(name) = lower('Adam');
like image 103
Piotr Findeisen Avatar answered Oct 11 '22 12:10

Piotr Findeisen