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

.insert_df fails to insert df column in UInt256 ch column #452

Closed
Dynortice opened this issue Jan 10, 2025 · 0 comments · Fixed by #454
Closed

.insert_df fails to insert df column in UInt256 ch column #452

Dynortice opened this issue Jan 10, 2025 · 0 comments · Fixed by #454
Labels
bug Something isn't working

Comments

@Dynortice
Copy link

Describe the bug

When attempting to use .insert_df to insert a DataFrame into a ClickHouse table that includes a UInt256 column, the operation fails with an AttributeError. Specifically, it appears that the code attempts to call the to_bytes method on a numpy.int64 object, which does not have this method even when dtype of column is Python built-in int.

Steps to reproduce

  1. Create a ClickHouse table with a UInt256 column.
  2. Use the insert_df method a pandas DataFrame containing a column meant to populate the UInt256 column.
  3. Observe error.

Expected behaviour

The .insert_df method should successfully convert the pandas DataFrame column to the appropriate format for insertion into the UInt256 column in ClickHouse.

Code example

import clickhouse_connect
client = clickhouse_connect.get_client(host='localhost', port=9000, username='default', password='')
client.command('CREATE TABLE test_table (id UInt256) ENGINE = Memory')
data = pd.DataFrame({'id': [1, 2, 3]})
client.insert_df('test_table', data)

clickhouse-connect and/or ClickHouse server logs

Traceback (most recent call last):
  ...
AttributeError: 'numpy.int64' object has no attribute 'to_bytes'. Did you mean: 'tobytes'?

Configuration

Environment

  • clickhouse-connect version: 0.8.13
  • pandas version: 2.2.3
  • Python version: 3.12.0
  • Operating system: Windows 11 Pro 22631.4602

ClickHouse server

  • ClickHouse Server version: 23.6.2.18
@Dynortice Dynortice added the bug Something isn't working label Jan 10, 2025
@genzgd genzgd mentioned this issue Jan 14, 2025
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant