Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

Appending a local Pandas dataframe to a Delta table in Azure is slow

未關閉
#450 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
35/100
Issue 類型
缺陷
描述清晰度
需要釐清
活躍度
停滯
技術堆疊
azure, pandas, python, sqlalchemy

研究方向

未指定 repository 檔案或測試。首先,使用 databricks-sql-connector 3.4.0,針對所述的 SQL warehouse 重現提供的 pandas DataFrame.to_sql 範例,然後追蹤 SQLAlchemy 和 connector 的寫入路徑,以定位每列延遲。完成的標準是找出受支援的更快速寫入路徑,或記錄該限制及其原因。

由索引模型根據 Issue 內容生成。

描述

I followed the instructions on this page to create a SQLAlchemy engine and used it with the Pandas to_sql() method. It's taking around 2 seconds to append one data point to a Delta table in Azure Databricks, and it seems to be scaling linearly. A dataframe containing 1 column and 10 rows is taking ~20 seconds to push to Azure.

Is there a way to make writing back to Databricks from a local machine faster?

Example code:

from sqlalchemy import create_engine
import pandas as pd
import os

server = 'my_server.azuredatabricks.net'
http_path = "/sql/1.0/warehouses/my_warehouse"
access_token = "MY_TOKEN"
catalog = "my_catalog"
schema = "my_schema"

if "NO_PROXY" in os.environ:
    os.environ["NO_PROXY"] = os.environ["NO_PROXY"] + "," + server
else:
    os.environ["NO_PROXY"] = server

if "no_proxy" in os.environ:
    os.environ["no_proxy"] = os.environ["no_proxy"] + "," + server
else:
    os.environ["no_proxy"] = server

engine = create_engine(f"databricks://token:{access_token}@{server}?" +
        f"http_path={http_path}&catalog={catalog}&schema={schema}"
)

df = pd.DataFrame({'name' : ['User 1', 'User 2', 'User 3', User 4', 'User 5', 'User 6', User 7', 'User 8', 'User 9', 'User 10']})

# The next command takes around 20 seconds to complete
df.to_sql(name='my_test_table', con=engine, if_exists='append', index=False)

Local specs:
databricks-sql-connector==3.4.0
pandas==2.2.2
Python 3.10.14

Azure specs:
Databricks SQL warehouse cluster
Runtime==13.3 LTS

主要語言
Python
星號
233
分支
152
平均合併
21 小時 5 分鐘
30 天內合併 PR
10

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

databricks/databricks-sql-python 的其他 Issue

查看 databricks/databricks-sql-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。