How to insert arrays into ARRAY<STRING> columns using native parameters?
還沒有人認領這個 Issue。
評估
研究方向
從 docs/parameters.md 中 named parameters 的使用範例開始,並使用提供的資料表定義、連接器版本和資料重現 insert_test()。檢查 SQL Warehouse 查詢歷程記錄,將繫結的 categories 值與預期的字串陣列進行比較;當插入的資料列包含兩個 category 值而不是 [] 時,即表示完成。
由索引模型根據 Issue 內容生成。
描述
Hi!
I am trying to insert an string array into a table with an ARRAY column, but it doesn't seem to register my Python string list.
CREATE TABLE prod_catalog.eu_projects.project_export (project_id bigint, categories ARRAY<STRING>);
def insert_test():
data = {
"project_id": 123456,
"categories": [
"Public Sector",
"Healthcare",
],
}
with get_databricks_connection() as connection:
cursor = connection.cursor()
cursor.execute(
"INSERT INTO prod_catalog.eu_projects.project_export(project_id, categories) VALUES (:project_id, Array(:categories))",
data
)
print("Test insert completed.")
This ends up as an empty array. If I check query history on the SQL Warehouse, it says that categories was an empty array []
I have tried to read the documentation, but it is very confusing.
I am using the following versions
Python 3.13.7
databricks-sql-connector==4.1.3
databricks-sdk==0.66.0
- 主要語言
- Python
- 星號
- 233
- 分支
- 152
- 平均合併
- 21 小時 5 分鐘
- 30 天內合併 PR
- 10
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
databricks/databricks-sql-python 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 78/100
-
難度 2/5 1-3 小時 新手友好度 76/100
-
難度 2/5 1-3 小時 新手友好度 78/100
-
難度 2/5 1-3 小時 新手友好度 72/100
-
難度 2/5 1-3 小時 新手友好度 84/100
查看 databricks/databricks-sql-python 的全部 Issue
相似的 Issue
-
enhancement
難度 2/5 1-3 小時 新手友好度 70/100
canonical/paas-charm#368 · 1 則留言 ·
-
難度 2/5 1-3 小時 新手友好度 75/100
-
tech debt
難度 2/5 1-3 小時 新手友好度 75/100
-
難度 1/5 1 小時以內 新手友好度 90/100
StevenBlack/hosts#3256 ·
-
難度 1/5 1 小時以內 新手友好度 90/100
qualcomm/qai-appbuilder#275 ·