Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError when selecting a Decimal column #416

Closed
dvincelli opened this issue Feb 14, 2024 · 1 comment
Closed

TypeError when selecting a Decimal column #416

dvincelli opened this issue Feb 14, 2024 · 1 comment

Comments

@dvincelli
Copy link

Describe the bug

When selecting from a schema containing a Decimal(21, 3), the client raises TypeError: int128_from_quads() takes exactly 2 positional arguments (3 given):

Traceback (most recent call last):
  File "/Users/dvincelli/.pyenv/versions/3.9.13/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/dvincelli/.pyenv/versions/3.9.13/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/dvincelli/src/github.com/Company/project/clicktools/export.py", line 70, in <module>
    results = client.execute(sale_facts_export)
  File "/Users/dvincelli/src/github.com/Company/project/clicktools/clickhouse_db.py", line 70, in execute
    return client.execute(query)
  File "/Users/dvincelli/.pyenv/virtualenvs/project/3.9.13/lib/python3.9/site-packages/clickhouse_driver/client.py", line 373, in execute
    rv = self.process_ordinary_query(
  File "/Users/dvincelli/.pyenv/virtualenvs/project/3.9.13/lib/python3.9/site-packages/clickhouse_driver/client.py", line 571, in process_ordinary_query
    return self.receive_result(with_column_types=with_column_types,
  File "/Users/dvincelli/.pyenv/virtualenvs/project/3.9.13/lib/python3.9/site-packages/clickhouse_driver/client.py", line 204, in receive_result
    return result.get_result()
  File "/Users/dvincelli/.pyenv/virtualenvs/project/3.9.13/lib/python3.9/site-packages/clickhouse_driver/result.py", line 50, in get_result
    for packet in self.packet_generator:
  File "/Users/dvincelli/.pyenv/virtualenvs/project/3.9.13/lib/python3.9/site-packages/clickhouse_driver/client.py", line 220, in packet_generator
    packet = self.receive_packet()
  File "/Users/dvincelli/.pyenv/virtualenvs/project/3.9.13/lib/python3.9/site-packages/clickhouse_driver/client.py", line 234, in receive_packet
    packet = self.connection.receive_packet()
  File "/Users/dvincelli/.pyenv/virtualenvs/project/3.9.13/lib/python3.9/site-packages/clickhouse_driver/connection.py", line 565, in receive_packet
    packet.block = self.receive_data(may_be_use_numpy=True)
  File "/Users/dvincelli/.pyenv/virtualenvs/project/3.9.13/lib/python3.9/site-packages/clickhouse_driver/connection.py", line 640, in receive_data
    return reader.read(use_numpy=use_numpy)
  File "/Users/dvincelli/.pyenv/virtualenvs/project/3.9.13/lib/python3.9/site-packages/clickhouse_driver/streams/native.py", line 83, in read
    column = read_column(
  File "/Users/dvincelli/.pyenv/virtualenvs/project/3.9.13/lib/python3.9/site-packages/clickhouse_driver/columns/service.py", line 154, in read_column
    return col.read_data(n_items, buf)
  File "/Users/dvincelli/.pyenv/virtualenvs/project/3.9.13/lib/python3.9/site-packages/clickhouse_driver/columns/base.py", line 162, in read_data
    items = self._read_data(n_items, buf, nulls_map=nulls_map)
  File "/Users/dvincelli/.pyenv/virtualenvs/project/3.9.13/lib/python3.9/site-packages/clickhouse_driver/columns/decimalcolumn.py", line 75, in _read_data
    return super(DecimalColumn, self)._read_data(
  File "/Users/dvincelli/.pyenv/virtualenvs/project/3.9.13/lib/python3.9/site-packages/clickhouse_driver/columns/base.py", line 166, in _read_data
    items = self.read_items(n_items, buf)
  File "/Users/dvincelli/.pyenv/virtualenvs/project/3.9.13/lib/python3.9/site-packages/clickhouse_driver/columns/intcolumn.py", line 121, in read_items
    return self.from_quads(items, n_items)
  File "clickhouse_driver/columns/largeint.pyx", line 10, in clickhouse_driver.columns.largeint.int128_from_quads
TypeError: int128_from_quads() takes exactly 2 positional arguments (3 given)
> /Users/dvincelli/src/github.com/Company/project/clickhouse_driver/columns/largeint.pyx(10)clickhouse_driver.columns.largeint.int128_from_quads()

To Reproduce

client.execute('''
    CREATE TABLE IF NOT EXISTS default.test (
        val Decimal(21, 3)
     ) ENGINE = MergeTree()
    ORDER BY tuple()
''')
client.execute('''INSERT INTO default.test VALUES (0)''')
result = client.execute('''SELECT * FROM default.test''')
print(result[0][0])

Expected behavior

Parse the decimal value and return it in the results.

Versions

  • Python version: 3.9.13
  • Version of package: 0.2.6
  • ClickHouse server version: 24.1.2.5
@xzkostyan
Copy link
Member

Duplicates #400.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants