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

Support parameter ($1) type inference for LIKE predicates #5617

Closed
alamb opened this issue Mar 15, 2023 · 3 comments · Fixed by #13632
Closed

Support parameter ($1) type inference for LIKE predicates #5617

alamb opened this issue Mar 15, 2023 · 3 comments · Fixed by #13632
Labels
enhancement New feature or request

Comments

@alamb
Copy link
Contributor

alamb commented Mar 15, 2023

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

We are trying to run a query like this:

SELECT ... WHERE col LIKE $1

However the type inference logic in https://github.com/apache/arrow-datafusion/blob/0f6931caa6f8b48e116a8e77e989c404f31f3f8d/datafusion/sql/src/expr/mod.rs#L503

only handles = predicates

cc @avantgardnerio

Describe the solution you'd like
I would like the type inference logic to handle LIKE, NOT LIKE, ILIKE and NOT ILIKE

Describe alternatives you've considered

Additional context
Found while implementing FlightSQL (via parameterized queries) in IOx: https://github.com/influxdata/influxdb_iox/pull/7213

@alamb alamb added the enhancement New feature or request label Mar 15, 2023
@alamb alamb assigned alamb and unassigned alamb Mar 15, 2023
@alamb
Copy link
Contributor Author

alamb commented Mar 15, 2023

I found a workaround that works for https://github.com/influxdata/influxdb_iox/pull/7213

@Weijun-H
Copy link
Member

What is the outcome of the SQL query SELECT ... WHERE col LIKE $1? 🤔

@alamb
Copy link
Contributor Author

alamb commented Mar 17, 2023

What is the outcome of the SQL query SELECT ... WHERE col LIKE $1? 🤔

It is a LogicalPlan with Expr::Placeholder entries. It will error during physical planning if the parameters are not supplied with https://docs.rs/datafusion/20.0.0/datafusion/dataframe/struct.DataFrame.html#method.with_param_values

However, today DataFusion will not create the LogicalPlan at all (it will error because it cant infer the type of $1 and that type is needed for the rest of the analysis)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants