Skip to content

IN clause with list parameter broken in 4.0.4 (regression from 4.0.3) #738

Closed as duplicate

Description

@PaulArnaud

Describe the bug

When using use_inline_params=True and passing a Python list as a parameter for an IN clause, the connector incorrectly renders it using ARRAY(...) syntax instead of a parenthesized tuple. This results in invalid SQL that Databricks rejects.

❗ This is a regression: the same code works correctly with version 4.0.3 and fails with 4.0.4.

To Reproduce

from databricks import sql
from databricks.sdk.core import Config, oauth_service_principal


query = """SELECT 'a' WHERE 'a' IN %(foo)s"""
parameters = {"foo": ["a", "b"]}

config = Config(
   host=f"https://{DATABRICKS_SERVER_HOSTNAME}",
   client_id=DATABRICKS_CLIENT_ID,
   client_secret=DATABRICKS_CLIENT_SECRET,
)

def credential_provider():
   return oauth_service_principal(config)

with sql.connect(
   server_hostname=DATABRICKS_SERVER_HOSTNAME,
   http_path=DATABRICKS_HTTP_PATH,
   credentials_provider=credential_provider,
   use_inline_params=True,
) as connection:
    with connection.cursor() as cursor:
        cursor.execute(
            operation=query,
            parameters=parameters,
        )
        return cursor.fetchall_arrow().to_pandas()

With this pyproject.toml

[project]
name = "minimal-sample"
version = "0.1.0"
requires-python = ">=3.13"
dependencies = [
    "databricks-sdk==0.91.0",
    "databricks-sql-connector[pyarrow]==4.0.4",
]

-> Expected behavior

The query should be rendered as:

SELECT 'a' WHERE 'a' IN ('a', 'b')

-> Actual behavior

The query is rendered as:

SELECT 'a' WHERE 'a' IN ARRAY('a','b')

Which causes an error because ARRAY(...) is not valid SQL syntax inside an IN clause.

databricks.sql.exc.ServerOperationError: 
[PARSE_SYNTAX_ERROR] Syntax error at or near 'IN'. SQLSTATE: 42601 (line 1, pos 21)

== SQL ==
SELECT 'a' WHERE 'a' IN ARRAY('a','b')
---------------------^^^

Note:
This works perfectly with the 4.0.3 version !!!!

Activity

  1. PaulArnaud commented on Mar 2, 2026

    @PaulArnaud
    Author

    This is a duplicate from #629

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