MagicStack / MagicStack/asyncpg
decimal.InvalidOperation exception is thrown with AWS Redshift.
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 8.1k
- Fork
- 468
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
* **asyncpg version**: 0.23.0
* **PostgreSQL version**: PostgreSQL 8.0.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3), Redshift 1.0.27314
* **Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
the issue with a local PostgreSQL install?**: AWS Redshift.
* **Python version**: 3.6.13
* **Platform**: Linux 5.0.0-23-generic #24~18.04.1-Ubuntu SMP Mon Jul 29 16:12:28 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
* **Do you use pgbouncer?**: no
* **Did you install asyncpg with pip?**: yes
* **If you built asyncpg locally, which version of Cython did you use?**: no
* **Can the issue be reproduced under both asyncio and
[uvloop](https://github.com/magicstack/uvloop)?**: no
I am trying to use asyncpg with AWS Redshift. I got an decimal.InvalidOperation exception when I try to run a simple query as follows. Is there any way to make asyncpg work with AWS Redshift? psycopg2 is working with AWS Redshift without major issue so I expect asyncpg could work with AWS Redshift also. Thank you in advance.
```
import asyncio
import asyncpg
async def run():
conn = await asyncpg.connect(
user='user', password='password', database='database', host='host')
values = await conn.fetch('SELECT 1.0 / 0.5')
await conn.close()
loop = asyncio.get_event_loop()
loop.run_until_complete(run())
```
```
$ python asyncpg_redshift.py
Traceback (most recent call last):
File "asyncpg_redshift.py", line 11, in
loop.run_until_complete(run())
File "/home/taeho/.pyenv/versions/3.6.13/lib/python3.6/asyncio/base_events.py", line 488, in run_until_complete
return future.result()
File "asyncpg_redshift.py", line 7, in run
values = await conn.fetch('SELECT 1.0 / 0.5')
File "/home/taeho/.pyenv/versions/3.6.13/envs/asyncpg/lib/python3.6/site-packages/asyncpg/connection.py", line 588, in fetch
record_class=record_class,
File "/home/taeho/.pyenv/versions/3.6.13/envs/asyncpg/lib/python3.6/site-packages/asyncpg/connection.py", line 1632, in _execute
ignore_custom_codec=ignore_custom_codec,
File "/home/taeho/.pyenv/versions/3.6.13/envs/asyncpg/lib/python3.6/site-packages/asyncpg/connection.py", line 1655, in __execute
ignore_custom_codec=ignore_custom_codec,
File "/home/taeho/.pyenv/versions/3.6.13/envs/asyncpg/lib/python3.6/site-packages/asyncpg/connection.py", line 1697, in _do_execute
result = await executor(stmt, None)
File "asyncpg/protocol/protocol.pyx", line 201, in bind_execute
File "asyncpg/protocol/coreproto.pyx", line 70, in asyncpg.protocol.protocol.CoreProtocol._read_server_messages
File "asyncpg/protocol/coreproto.pyx", line 212, in asyncpg.protocol.protocol.CoreProtocol._process__bind_execute
File "asyncpg/protocol/coreproto.pyx", line 497, in asyncpg.protocol.protocol.CoreProtocol._parse_data_msgs
File "asyncpg/protocol/protocol.pyx", line 781, in asyncpg.protocol.protocol.BaseProtocol._decode_row
File "asyncpg/protocol/prepared_stmt.pyx", line 295, in asyncpg.protocol.protocol.PreparedStatementState._decode_row
File "asyncpg/protocol/codecs/base.pyx", line 289, in asyncpg.protocol.protocol.Codec.decode
File "asyncpg/protocol/codecs/base.pyx", line 196, in asyncpg.protocol.protocol.Codec.decode_scalar
File "asyncpg/pgproto/./codecs/numeric.pyx", line 287, in asyncpg.pgproto.pgproto.numeric_decode_binary
File "asyncpg/pgproto/./codecs/numeric.pyx", line 279, in asyncpg.pgproto.pgproto.numeric_decode_binary_ex
decimal.InvalidOperation: []
$
```
I think the strange result of the following query could be also related.
```
import asyncio
import asyncpg
async def run():
conn = await asyncpg.connect(
user='user', password='password', database='database', host='host')
values = await conn.fetch('SELECT CAST(1.0 AS DECIMAL(10, 1))')
print(values)
await conn.close()
loop = asyncio.get_event_loop()
loop.run_until_complete(run())
```
```
$ python asyncpg_redshift2.py
[]
$
```
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách chạy hai truy vấn Python được cung cấp trên AWS Redshift và so sánh kết quả của chúng với traceback. Kiểm tra asyncpg/pgproto/./codecs/numeric.pyx, nơi xảy ra lỗi trong quá trình giải mã số, và xác định dữ liệu số do Redshift trả về khác với biểu diễn mà PostgreSQL mong đợi như thế nào. Hoàn tất khi đã tái hiện được tính không tương thích và xác lập được hành vi được hỗ trợ hoặc một bản sửa lỗi có phạm vi giới hạn.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- aws, postgresql, python
- Lĩnh vực
- databases
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 30/100