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

Issue with integer columns: KeyError: '0' #34

Open
alter opened this issue Jul 18, 2021 · 0 comments
Open

Issue with integer columns: KeyError: '0' #34

alter opened this issue Jul 18, 2021 · 0 comments

Comments

@alter
Copy link

alter commented Jul 18, 2021

Describe the bug
I try to create table with pandahouse:

  create_table = f"CREATE TABLE data.sma({fields}) ENGINE=Log"
  ph.execute(create_table, connection=connection)

and got as a result:

Traceback (most recent call last):
  File "./SMA_test_alter.py", line 128, in <module>
    main()
  File "./SMA_test_alter.py", line 125, in main
    ch_client.execute('INSERT into data.sma VALUES', dfs.to_dict('records'))
  File "/home/1/.local/lib/python3.8/site-packages/clickhouse_driver/client.py", line 261, in execute
    rv = self.process_insert_query(
  File "/home/1/.local/lib/python3.8/site-packages/clickhouse_driver/client.py", line 478, in process_insert_query
    rv = self.send_data(sample_block, data,
  File "/home/1/.local/lib/python3.8/site-packages/clickhouse_driver/client.py", line 529, in send_data
    block = block_cls(sample_block.columns_with_types, chunk,
  File "/home/1/.local/lib/python3.8/site-packages/clickhouse_driver/block.py", line 39, in __init__
    self.data = self.normalize(data or [])
  File "/home/1/.local/lib/python3.8/site-packages/clickhouse_driver/block.py", line 127, in normalize
    self._mutate_dicts_to_rows(data)
  File "/home/1/.local/lib/python3.8/site-packages/clickhouse_driver/block.py", line 161, in _mutate_dicts_to_rows
    data[i] = [row[name] for name in column_names]
  File "/home/1/.local/lib/python3.8/site-packages/clickhouse_driver/block.py", line 161, in <listcomp>
    data[i] = [row[name] for name in column_names]
KeyError: '0'

To Reproduce

create table = "CREATE TABLE data.sma(`3` Float64 , `4` Float64 , `5` Float64 , `6` Float64 , `7` Float64 , `8` Float64 , `9` Float64 , `10` Float64 , `1-2` LowCardinality(String), `1-3` LowCardinality(String), `1-4` LowCardinality(String), `1-5` LowCardinality(String), `1-6` LowCardinality(String), `1-7` LowCardinality(String), `1-8` LowCardinality(String), `2-3` LowCardinality(String), `2-4` LowCardinality(String), `2-5` LowCardinality(String), `2-6` LowCardinality(String), `2-7` LowCardinality(String), `2-8` LowCardinality(String), `3-4` LowCardinality(String), `3-5` LowCardinality(String), `3-6` LowCardinality(String), `3-7` LowCardinality(String), `3-8` LowCardinality(String), `4-5` LowCardinality(String), `4-6` LowCardinality(String), `4-7` LowCardinality(String), `4-8` LowCardinality(String), `5-6` LowCardinality(String), `5-7` LowCardinality(String), `5-8` LowCardinality(String), `6-7` LowCardinality(String), `6-8` LowCardinality(String), `7-8` LowCardinality(String)) ENGINE=Log"

ph.execute(create_table, connection=connection)

Expected behavior
created table(b/c I just copied create_table string and it works if I manually push it using ch client.

Versions

  • Version of package with the problem.
    pandahouse==0.2.7

  • Python version.
    python -V
    Python 3.8.10

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

1 participant