aws / aws/amazon-redshift-python-driver

VARBYTE is decoded into utf-8

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

描述

In readme VARBYTE is stated as supported as Python's `bytes` type. When trying to query data VARBYTE data from Redshift, 'utf-8' decoding error is thrown.

### Reproduction

```python
import redshift_connector

DROP_DDL = "drop table if exists varbyte_repro"
CREATE_DDL = """create table varbyte_repro(
my_var varbyte
);
"""
INSERT_DML = "insert into varbyte_repro(my_var) values (from_hex(SHA1('hello')))"
QUERY = "select * from varbyte_repro"

with redshift_connector.connect(
host="replaced",
database="replaced",
user="replaced",
password="replaced",
) as conn, conn.cursor() as cursor:
conn.autocommit = True
cursor.execute(DROP_DDL)
cursor.execute(CREATE_DDL)
cursor.execute(INSERT_DML)
cursor.execute(QUERY)
```

### Expected

Last `cursor.execute` runs without issue (so that later something like `cursor.fetchall` could be used)

### Actual

Error thrown:
```
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xaa in position 0: invalid start byte
```

貢獻指南

開啟貢獻指南

研究方向

針對 Redshift 執行提供的 Python 重現程式碼,並在執行最終查詢時檢查 connector 的 VARBYTE 結果解碼路徑。確認 VARBYTE 值會以 Python bytes 傳回且不會出現 UnicodeDecodeError,然後為所示範的查詢行為新增或更新涵蓋範圍。

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

評估

技術堆疊
python
領域
database
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
描述清楚
新手友好度
45/100

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

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