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
BUG: AttributeError: 'list' object has no attribute 'tolist' when insert_dataframe with use_numpy on #218
Comments
I've run into issue using insert_dataframe as well. I've followed the above suggestions from issue but am getting errors. When I use I end up getting the error below when trying to call AttributeError: 'numpy.ndarray' object has no attribute 'values' I've tried using TypeError: Unsupported column type: <class 'numpy.ndarray'>. list or tuple is expected. When I tried to convert the df to a list and pass it in it gives the error below: AttributeError: 'list' object has no attribute 'transpose' When I set AttributeError: 'list' object has no attribute 'values' Any idea what I'm doing wrong here? python = 3.8.2 |
@panwenbin , please see this ticket: #76 |
problem still persisting. Anyone has a solution? clickhouse-driver = 0.2.2 |
@ghego master branch has fix for this bug you can install package directly form github. |
Update to the latest ver 0.2.3 and the problem is sorted out |
Describe the bug
get a dataframe by query_dataframe() then insert it by insert_dataframe(), an error occurs.
To Reproduce
test.a has a column of Array(String)
df = client.query_dataframe("SELECT * FROM test.a LIMIT 10;")
client.insert_dataframe("INSERT INTO test.b VALUES ", df, settings={"use_numpy": True})
got:
Traceback (most recent call last):
File "ch_test.py", line 7, in
client.insert_dataframe("INSERT INTO test.b VALUES ", df, settings={"use_numpy": True})
File "/home/panwenbin/github/panwenbin/ch_test/venv/lib/python3.7/site-packages/clickhouse_driver/client.py", line 418, in insert_dataframe
query_id=query_id, settings=settings
File "/home/panwenbin/github/panwenbin/ch_test/venv/lib/python3.7/site-packages/clickhouse_driver/client.py", line 245, in execute
columnar=columnar
File "/home/panwenbin/github/panwenbin/ch_test/venv/lib/python3.7/site-packages/clickhouse_driver/client.py", line 472, in process_insert_query
types_check=types_check, columnar=columnar)
File "/home/panwenbin/github/panwenbin/ch_test/venv/lib/python3.7/site-packages/clickhouse_driver/client.py", line 524, in send_data
self.connection.send_data(block)
File "/home/panwenbin/github/panwenbin/ch_test/venv/lib/python3.7/site-packages/clickhouse_driver/connection.py", line 554, in send_data
self.block_out.write(block)
File "/home/panwenbin/github/panwenbin/ch_test/venv/lib/python3.7/site-packages/clickhouse_driver/streams/native.py", line 39, in write
self.fout, types_check=block.types_check)
File "/home/panwenbin/github/panwenbin/ch_test/venv/lib/python3.7/site-packages/clickhouse_driver/columns/service.py", line 107, in write_column
column.write_data(items, buf)
File "/home/panwenbin/github/panwenbin/ch_test/venv/lib/python3.7/site-packages/clickhouse_driver/columns/arraycolumn.py", line 44, in write_data
self._write(data, buf)
File "/home/panwenbin/github/panwenbin/ch_test/venv/lib/python3.7/site-packages/clickhouse_driver/columns/arraycolumn.py", line 104, in _write
self._write_data(value, buf)
File "/home/panwenbin/github/panwenbin/ch_test/venv/lib/python3.7/site-packages/clickhouse_driver/columns/arraycolumn.py", line 88, in _write_data
self.nested_column._write_data(value, buf)
File "/home/panwenbin/github/panwenbin/ch_test/venv/lib/python3.7/site-packages/clickhouse_driver/columns/arraycolumn.py", line 88, in _write_data
self.nested_column._write_data(value, buf)
File "/home/panwenbin/github/panwenbin/ch_test/venv/lib/python3.7/site-packages/clickhouse_driver/columns/base.py", line 81, in _write_data
self.write_items(prepared, buf)
File "/home/panwenbin/github/panwenbin/ch_test/venv/lib/python3.7/site-packages/clickhouse_driver/columns/numpy/stringcolumn.py", line 22, in write_items
return buf.write_strings(items.tolist(), encoding=self.encoding)
AttributeError: 'list' object has no attribute 'tolist'
Expected behavior
expected without error
Versions
The text was updated successfully, but these errors were encountered: