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
-
难度 2/5 1-3 小时 新手友好度 82/100
-
难度 2/5 1-3 小时 新手友好度 84/100
-
难度 2/5 1-3 小时 新手友好度 68/100
-
难度 2/5 1-3 小时 新手友好度 86/100
-
🐛 Bug 🔔 Pending processing
难度 2/5 1-3 小时 新手友好度 84/100
jumpserver/jumpserver#17584 ·