cloudflare / sqlalchemy-clickhouse

Apache License 2.0
314 stars 105 forks source link

UUID field class absent #14

Open Perlovka opened 7 years ago

Perlovka commented 7 years ago

ClickHouse added new data type UUID: https://github.com/yandex/ClickHouse/blob/master/CHANGELOG.md#clickhouse-release-1154276

sqlalchemy-clickhouse raises following error when trying to open table with UUID fields in Superset:

ERROR:root:No field class for UUID
Traceback (most recent call last):
  File "/root/superset/lib/python2.7/site-packages/superset/sql_lab.py", line 180, in execute_sql
    query.executed_sql, **db_engine_spec.cursor_execute_kwargs)
  File "/root/superset/lib/python2.7/site-packages/sqlalchemy_clickhouse/connector.py", line 200, in execute
    self._process_response(response)
  File "/root/superset/lib/python2.7/site-packages/sqlalchemy_clickhouse/connector.py", line 331, in _process_response
    for r in response:
  File "/root/superset/lib/python2.7/site-packages/infi/clickhouse_orm/database.py", line 162, in select
    model_class = model_class or ModelBase.create_ad_hoc_model(zip(field_names, field_types))
  File "/root/superset/lib/python2.7/site-packages/infi/clickhouse_orm/models.py", line 47, in create_ad_hoc_model
    attrs[name] = cls.create_ad_hoc_field(db_type)
  File "/root/superset/lib/python2.7/site-packages/sqlalchemy_clickhouse/connector.py", line 82, in create_ad_hoc_field
    raise NotImplementedError('No field class for %s' % db_type)
NotImplementedError: No field class for UUID
pkesso commented 4 years ago

Same trouble on Version 0.1.5

pkesso commented 4 years ago

Ok, it seems we have a solution:

add following code

if db_type.startswith('UUID'):
    db_type = 'String'

to the create_ad_hoc_field method in connector.py