aws / aws/amazon-redshift-python-driver

VARBYTE is decoded into utf-8

Open
#261 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
220
Forks
86
PR merge metrics
No merged PRs in 30d

Description

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
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.