Skip to content

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

Closed

Description

@alamb

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

Activity

  1. assigned and unassigned on Mar 15, 2023
  2. alamb commented on Mar 15, 2023

    @alamb
    ContributorAuthor
  3. Weijun-H commented on Mar 16, 2023

    @Weijun-H
    Member

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

  4. alamb commented on Mar 17, 2023

    @alamb
    ContributorAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions