long2ice / asynch

An asyncio ClickHouse Python Driver with native (TCP) interface support.
https://github.com/long2ice/asynch
Apache License 2.0
185 stars 43 forks source link

A issue with the Date type #92

Closed cortelf closed 1 month ago

cortelf commented 9 months ago

Python: 3.12.0 ashynch: 0.2.3 ClickHouse: 23.8.5.16

Code

import asyncio

from asynch import connect

async def connect_database():
    conn = await connect("")
    async with conn.cursor() as cursor:
        await cursor.execute("""select makeDate(2149, 06, 06);""")
        ret = await cursor.fetchall()

asyncio.run(connect_database())

Traceback

Traceback (most recent call last):
  File "C:\Users\Cortel\Projects\Useless\test_asynch_date_issue\main.py", line 12, in <module>
    asyncio.run(connect_database())
  File "C:\Users\Cortel\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\Cortel\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Cortel\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 664, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\Cortel\Projects\Useless\test_asynch_date_issue\main.py", line 9, in connect_database
    await cursor.execute("""select makeDate(2149, 06, 06);""")
  File "C:\Users\Cortel\AppData\Local\pypoetry\Cache\virtualenvs\test-asynch-date-issue-CodK8wwF-py3.12\Lib\site-packages\asynch\cursors.py", line 60, in execute
    response = await execute(query, args=args, with_column_types=True, **execute_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Cortel\AppData\Local\pypoetry\Cache\virtualenvs\test-asynch-date-issue-CodK8wwF-py3.12\Lib\site-packages\asynch\proto\connection.py", line 633, in execute
    async with ExecuteContext(self, query, settings):
  File "C:\Users\Cortel\AppData\Local\pypoetry\Cache\virtualenvs\test-asynch-date-issue-CodK8wwF-py3.12\Lib\site-packages\asynch\proto\context.py", line 56, in __aexit__
    raise exc_val
  File "C:\Users\Cortel\AppData\Local\pypoetry\Cache\virtualenvs\test-asynch-date-issue-CodK8wwF-py3.12\Lib\site-packages\asynch\proto\connection.py", line 648, in execute
    rv = await self.process_ordinary_query(
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Cortel\AppData\Local\pypoetry\Cache\virtualenvs\test-asynch-date-issue-CodK8wwF-py3.12\Lib\site-packages\asynch\proto\connection.py", line 775, in process_ordinary_query
    return await self.receive_result(with_column_types=with_column_types, columnar=columnar)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Cortel\AppData\Local\pypoetry\Cache\virtualenvs\test-asynch-date-issue-CodK8wwF-py3.12\Lib\site-packages\asynch\proto\connection.py", line 498, in receive_result
    return await result.get_result()
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Cortel\AppData\Local\pypoetry\Cache\virtualenvs\test-asynch-date-issue-CodK8wwF-py3.12\Lib\site-packages\asynch\proto\result.py", line 56, in get_result
    async for packet in self.packet_generator:
  File "C:\Users\Cortel\AppData\Local\pypoetry\Cache\virtualenvs\test-asynch-date-issue-CodK8wwF-py3.12\Lib\site-packages\asynch\proto\connection.py", line 477, in packet_generator
    packet = await self.receive_packet()
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Cortel\AppData\Local\pypoetry\Cache\virtualenvs\test-asynch-date-issue-CodK8wwF-py3.12\Lib\site-packages\asynch\proto\connection.py", line 403, in receive_packet
    packet = await self._receive_packet()
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Cortel\AppData\Local\pypoetry\Cache\virtualenvs\test-asynch-date-issue-CodK8wwF-py3.12\Lib\site-packages\asynch\proto\connection.py", line 437, in _receive_packet
    packet.block = await self.receive_data()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Cortel\AppData\Local\pypoetry\Cache\virtualenvs\test-asynch-date-issue-CodK8wwF-py3.12\Lib\site-packages\asynch\proto\connection.py", line 340, in receive_data
    return await (self.block_reader_raw if raw else self.block_reader).read()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Cortel\AppData\Local\pypoetry\Cache\virtualenvs\test-asynch-date-issue-CodK8wwF-py3.12\Lib\site-packages\asynch\proto\streams\block.py", line 82, in read
    column = await read_column(
             ^^^^^^^^^^^^^^^^^^
  File "C:\Users\Cortel\AppData\Local\pypoetry\Cache\virtualenvs\test-asynch-date-issue-CodK8wwF-py3.12\Lib\site-packages\asynch\proto\columns\__init__.py", line 157, in read_column
    return await column.read_data(
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Cortel\AppData\Local\pypoetry\Cache\virtualenvs\test-asynch-date-issue-CodK8wwF-py3.12\Lib\site-packages\asynch\proto\columns\base.py", line 112, in read_data
    return await self._read_data(n_items, nulls_map=nulls_map)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Cortel\AppData\Local\pypoetry\Cache\virtualenvs\test-asynch-date-issue-CodK8wwF-py3.12\Lib\site-packages\asynch\proto\columns\base.py", line 120, in _read_data
    return self.after_read_items(items, nulls_map)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Cortel\AppData\Local\pypoetry\Cache\virtualenvs\test-asynch-date-issue-CodK8wwF-py3.12\Lib\site-packages\asynch\proto\columns\datecolumn.py", line 44, in after_read_items
    return tuple(date_lut[item] for item in items)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Cortel\AppData\Local\pypoetry\Cache\virtualenvs\test-asynch-date-issue-CodK8wwF-py3.12\Lib\site-packages\asynch\proto\columns\datecolumn.py", line 44, in <genexpr>
    return tuple(date_lut[item] for item in items)
                 ~~~~~~~~^^^^^^
KeyError: 65535
long2ice commented 9 months ago

fixed

stankudrow commented 1 month ago

@cortelf , could you possibly close the issue if it is resolved?