Skip to content

Compiled sql for an input list parameter results in incorrect syntax in 4.0.4 #629

Open

Description

@jwhite3

In 4.0.4 it seems like the partial implementation of supporting complex types like arrays etc is resulting in incorrect syntax

For example (where the list parameter is [1, 2, 3]):

… WHERE something IN %s

Is resulting in:

… WHERE something IN ARRAY(1, 2, 3)

Which is invalid syntax as of the current runtime. It should be

… WHERE something IN (1, 2, 3)

Activity

  1. p-mit commented on Sep 3, 2025

    @p-mit

    I'm 100% sure that the author (jprakash-db) of the PR (#559) will kindly inform you why it looks like this and how to use it in your code as it seems like it's not backwards compatible change that's potentially error prone released as part of a patch release.

    Or maybe you should just open your PR as that won't ever happen, the PR wasn't tested properly and fix it yourself!

  2. yeiterjoe commented on Jan 6, 2026

    @yeiterjoe

    Running into the same issue myself. #559 broke all usages of parameters used with in statements.

    IMO SQL Arrays should have been handled with a specific parameter class rather than just converting all list parameters to Arrays.

  3. jprakash-db commented on Mar 16, 2026

    @jprakash-db
    Contributor

    Thanks for raising this issue. We implemented this approach to parse all the sequence objects as ARRAY is because of the upstream requirement of https://github.com/databricks/databricks-sqlalchemy . Support for complex types in sqlalchemy does not give us additional information of specific types to the PySQL Connector.
    As a workaround you can use this
    cursor.execute("SELECT * FROM table_name WHERE array_contains(:user_nums, user_num)", {"user_nums": [434]}) instead of the IN syntax

    Please feel free to reopen if needed. Thanks

  4. jwhite3 commented on Mar 17, 2026

    @jwhite3
    Author

    How does that workaround resolve this? Not supporting correct sql syntax for the databricks dialect due to design constraints in a separate tool points to a problem with the design that should be fixed.

  5. jprakash-db commented on Mar 18, 2026

    @jprakash-db
    Contributor

    Ack, have reopened the issue.

  6. jprakash-db commented on Mar 18, 2026

    @jprakash-db
    Contributor

    @msrathore-db Tagging in current oncall to evaluate this issue

  7. gyandeeps-hh commented on Apr 7, 2026

    @gyandeeps-hh

    is their a fix in the works? we have a pinned our version and which is not a good thing for long term support.

  8. fatkobra commented on Apr 20, 2026

    @fatkobra

    I worked on this and put PR #773 .

    Added a small inline-parameter fix in src/databricks/sql/utils.py.

    Then I added unit tests (regression tests) for inline list parameters used in IN clauses.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions