Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL: Inconsistent behavior when using LIKE operator with a string function #17174

Open
DominicRicardAdgear opened this issue Sep 26, 2024 · 1 comment

Comments

@DominicRicardAdgear
Copy link

Affected Version

Druid V.30.0.0

Description

Running the following query yields an error:

with t as (select 'a string' as col) 
select 
  col, 
  upper(col)
from t
where 
UPPER(t.col) LIKE UPPER('a%')

Result:

Error: UNCATEGORIZED (ADMIN)

Function[like] pattern argument must be a literal

Running the same comparator against a table does not result in an error. When doing explain plan for on the table query, the filter value is shown as being uppercased, which suggest druid is executing the UPPER function before building the plan.

explain plan for select count(1) from INFORMATION_SCHEMA.TABLES where upper(TABLE_NAME) like upper('%a%')

Result:

BindableAggregate(group=[{}], EXPR$0=[COUNT()])
  BindableFilter(condition=[LIKE(UPPER($2), '%A%')])
    BindableTableScan(table=[[INFORMATION_SCHEMA, TABLES]])
@data-wild
Copy link

I was curious about this and see that the query works fine so long as you wrap it in an additional CTE. For example, this works:

with t as (select 'a string' as col) 
, aa as (select 
  col, 
  upper(col)
from t)
select * from aa
where 
upper(col) like UPPER('a%')

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

No branches or pull requests

2 participants