aws / aws/amazon-redshift-python-driver

The field names should be presented.

未關閉
#240 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Python
星號
220
分支
86
PR 合併指標
30 天內沒有已合併 PR

描述

The generated sql code for insert do not point the field names.

Then the only way to make it work is to order the field names in the dataframe.

```
if not self.__is_valid_table(table):
raise InterfaceError("Invalid table name passed to write_dataframe: {}".format(table))
sanitized_table_name: str = self.__sanitize_str(table)
arrays: list = df.values.tolist()
placeholder: str = ", ".join(["%s"] * len(arrays[0]))
sql: str = "insert into {table} values ({placeholder})".format(
table=sanitized_table_name, placeholder=placeholder
)
```
https://github.com/aws/amazon-redshift-python-driver/blob/64cbd54ef6a5e71d98ce193630d09267cc154379/redshift_connector/cursor.py#L584C1-L591C10

貢獻指南

開啟貢獻指南

研究方向

從 redshift_connector/cursor.py 中連結的行開始,追蹤 write_dataframe 的 SQL 產生流程。確認 dataframe 欄位名稱是如何取得的,然後驗證產生的 INSERT 陳述式包含欄位名稱,使結果不再依賴 dataframe 的欄位順序。

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

評估

技術堆疊
aws, python
領域
databases
Issue 類型
缺陷
難度
2/5
預估耗時
1-3 小時
活躍度
停滯
描述清晰度
基本清楚
新手友好度
48/100

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

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