-
Notifications
You must be signed in to change notification settings - Fork 131
Open
Description
The following example works with databricks-sql-connector version 2.9.3, but fails with version 3.0.1:
import numpy as np
import pandas as pd
from sqlalchemy import create_engine
sqlalchemy_connection_string = f"databricks://token:{access_token}@{host}?http_path={http_path}&catalog={catalog}&schema={schema}"
engine = create_engine(sqlalchemy_connection_string)
shape = (50, 16)
random_df = pd.DataFrame(
data=np.random.standard_normal(size=shape),
columns=[f"col{i}" for i in range(shape[1])]
)
table_name = "pandas_sqlalchemy_insert"
random_df.to_sql(table_name, engine, if_exists="replace", index=False, method="multi")The error is: OperationalError: (databricks.sql.exc.RequestError) Error during request to server
With setting chunksize in random_df.to_sql to any value which is 15 or lower (to make the number of table cells inserted less than 256), the insert runs without issue.
What I have tried
- Instead of
random_df.to_sql(table_name, engine, if_exists="replace", index=False, method="multi")used:
with engine.connect() as conn:
random_df.to_sql(table_name, conn, if_exists="replace", index=False, method="multi")-- the observed behavior is the same in all cases.
- Various other DataFrames and chunksizes. Anything under 256 cells works, anything with 256 or more cells fails with the described exception.
Versions
Not working: databricks-sql-connector==3.0.1, sqlalchemy==2.0.23, pandas==2.1.4
Working: databricks-sql-connector==2.9.3, sqlalchemy==1.4.50, pandas==2.1.4
noamsto, wr-aarmstrong and beefupinetree
Metadata
Metadata
Assignees
Labels
No labels