You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
An error occurs when trying to insert a value of UInt128 type.
To Reproduce
fromclickhouse_driverimportconnectwithconnect(dsn='clickhouse://localhost') asconnection:
withconnection.cursor() ascursor:
cursor.execute('DROP TABLE IF EXISTS test')
cursor.execute('CREATE TABLE IF NOT EXISTS test (`a` UInt128) ENGINE = MergeTree() ORDER BY (a)')
data= [
{'a': 2**127-1},
{'a': 2**127},
]
cursor.executemany('INSERT INTO test (a) VALUES', data)
cursor.execute('SELECT * FROM test')
print(cursor.fetchall())
Throws
Traceback (most recent call last):
File "/home/xxx/clickhouse.py", line 11, in <module>
cursor.executemany('INSERT INTO test (a) VALUES', data)
File "/usr/local/lib64/python3.9/site-packages/clickhouse_driver/dbapi/cursor.py", line 138, in executemany
response = execute(
File "/usr/local/lib64/python3.9/site-packages/clickhouse_driver/client.py", line 261, in execute
rv = self.process_insert_query(
File "/usr/local/lib64/python3.9/site-packages/clickhouse_driver/client.py", line 478, in process_insert_query
rv = self.send_data(sample_block, data,
File "/usr/local/lib64/python3.9/site-packages/clickhouse_driver/client.py", line 531, in send_data
self.connection.send_data(block)
File "/usr/local/lib64/python3.9/site-packages/clickhouse_driver/connection.py", line 566, in send_data
self.block_out.write(block)
File "/usr/local/lib64/python3.9/site-packages/clickhouse_driver/streams/native.py", line 38, in write
write_column(self.context, col_name, col_type, items,
File "/usr/local/lib64/python3.9/site-packages/clickhouse_driver/columns/service.py", line 113, in write_column
column.write_data(items, buf)
File "/usr/local/lib64/python3.9/site-packages/clickhouse_driver/columns/base.py", line 77, in write_data
self._write_data(items, buf)
File "/usr/local/lib64/python3.9/site-packages/clickhouse_driver/columns/base.py", line 81, in _write_data
self.write_items(prepared, buf)
File "/usr/local/lib64/python3.9/site-packages/clickhouse_driver/columns/intcolumn.py", line 115, in write_items
buf.write(s.pack(*uint_64_pairs))
struct.error: pack expected 4 items for packing (got 8)
Expected behavior
The UInt128 value is expected to be inserted successfully into the table.
If you change the UInt128 type to Int128
fromclickhouse_driverimportconnectwithconnect(dsn='clickhouse://localhost') asconnection:
withconnection.cursor() ascursor:
cursor.execute('DROP TABLE IF EXISTS test')
cursor.execute('CREATE TABLE IF NOT EXISTS test (`a` Int128) ENGINE = MergeTree() ORDER BY (a)')
data= [
{'a': 2**127-1},
{'a': 2**127},
]
cursor.executemany('INSERT INTO test (a) VALUES', data)
cursor.execute('SELECT * FROM test')
print(cursor.fetchall())
Describe the bug
An error occurs when trying to insert a value of UInt128 type.
To Reproduce
Throws
Expected behavior
The UInt128 value is expected to be inserted successfully into the table.
If you change the UInt128 type to Int128
Everything works well
Versions
The text was updated successfully, but these errors were encountered: