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

Exception when inserting into a Dynamic type #450

Open
benedetto73 opened this issue Aug 21, 2024 · 4 comments
Open

Exception when inserting into a Dynamic type #450

benedetto73 opened this issue Aug 21, 2024 · 4 comments

Comments

@benedetto73
Copy link

benedetto73 commented Aug 21, 2024

Describe the bug
I get this error when trying to insert data into a a table with a dynamic type. Actually a map with Dynamic values.
Insertions without dynamic types work fine.

Schema of the table:

# ColumnName DataType
1 EventReceivedTime DateTime64(3)
2 Name LowCardinality(String)
3 Type LowCardinality(String)
4 data Map(LowCardinality(String), Dynamic)

Error I get:

Traceback (most recent call last):
  File "C:\Users\bened\AppData\Local\Programs\Python\Python311\Lib\site-packages\clickhouse_driver\columns\service.py", line 139, in get_column_by_spec
    cls = column_by_type[spec]
          ~~~~~~~~~~~~~~^^^^^^
KeyError: 'Dynamic'

To Reproduce

        record = (
                EventReceivedTime,
                Name,
                Type
                ,
                json.dumps({
                    'clientID': clientID,
                    'message' : message
                })
         )
        records.append(record)
            
        query = f'INSERT INTO {table_name} (EventReceivedTime,Name,Type,data) VALUES'
        client.execute(query, records)

Expected behavior
I would expect the code to work unless Dynamc types aren't explicitly supported.

Versions

  • Version of clickhouse-driver: 0.2.9
  • ClickHouse server version: 24.6.2.17
  • Python version. 3.11.4
@xzkostyan
Copy link
Member

Hi.

How do you expect this should work if driver doesn't know anything about Dynamic type?

@benedetto73
Copy link
Author

How would I know that the driver doesn't know about the Dynamic type?
I would expect the driver to support all ClickHouse features.

@xzkostyan
Copy link
Member

Feel free to make a PR if you want it asap.

@xzkostyan
Copy link
Member

You can see all the supported types in the driver docs: https://clickhouse-driver.readthedocs.io/en/latest/types.html

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