Unable to insert Python lists into ARRAY<STRING> columns using pandas to_sql
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
Research direction
Start with DatabricksArray and the pandas DataFrame.to_sql INSERT path, using the provided minimal example to reproduce the empty arrays. Trace how Python list parameters are bound for ARRAY; done means both rows retain their email elements instead of becoming empty arrays, with regression coverage for both examples.
Written by the indexing model from the issue text.
Description
Description
Hello,
I am trying to insert Python lists into a Databricks
ARRAY<STRING> column using pandas DataFrame.to_sql() with
the Databricks SQLAlchemy dialect.
The table is created correctly with an ARRAY<STRING> column,
but the inserted arrays are stored as empty arrays.
Minimal reproducible example
import pandas as pd
from sqlalchemy import create_engine, String, Integer
from databricks.sqlalchemy import DatabricksArray
from urllib.parse import quote_plus
df = pd.DataFrame([
{
"GROUP_ID": 1,
"PARAM": ["abc@mail.com", "xyz@mail.com"],
},
{
"GROUP_ID": 2,
"PARAM": ["test@mail.com"],
},
])
connection_string = (
f"databricks://token:{quote_plus(TOKEN)}@{DATABRICKS_HOST}?"
f"http_path={quote_plus(DATABRICKS_HTTP_PATH)}"
f"&catalog={quote_plus(CATALOG)}"
f"&schema={quote_plus(SCHEMA)}"
)
engine = create_engine(connection_string, echo=True)
df.to_sql(
"mailing_group",
con=engine,
index=False,
if_exists="replace",
dtype={
"GROUP_ID": Integer,
"PARAM": DatabricksArray(String),
},
)
Logs:
2026-08-11 08:15:07,657 INFO sqlalchemy.engine.Engine
CREATE TABLE mailing_group (
GROUP_ID INT,
PARAM ARRAY
) USING DELTA
TBLPROPERTIES('delta.feature.allowColumnDefaults' = 'enabled')
2026-08-11 08:15:07,657 INFO sqlalchemy.engine.Engine [no key 0.00074s] {}
2026-08-11 08:15:09,665 INFO sqlalchemy.engine.Engine INSERT INTO mailing_group (GROUP_ID, PARAM) VALUES (:GROUP_ID, :PARAM)
2026-08-11 08:15:09,666 INFO sqlalchemy.engine.Engine [generated in 0.00110s] [{'GROUP_ID': 1, 'PARAM': ['abc@mail.com', 'xyz@mail.com']}, {'GROUP_ID': 2, 'PARAM': ['test@mail.com']}]
Environment
- Python : 3.12
- Pandas : 2.2.3
- databricks-sqlalchemy : 2.0.10
- DBSQL Version: 2026.20
- databricks-sql-connector: 4.0.5
- Dominant language
- Python
- Stars
- 24
- Forks
- 18
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from databricks/databricks-sqlalchemy
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
All issues in databricks/databricks-sqlalchemy
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
use-agent-os/agent-os#3314 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
BasedHardware/omi#15662 · 1 comment ·
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
AiursoftWeb/AnduinOS-2#19 ·