superset icon indicating copy to clipboard operation
superset copied to clipboard

0.26.0 unable to query/connect to clickhouse

Open zyclonite opened this issue 8 years ago • 5 comments

Make sure these boxes are checked before submitting your issue - thank you!

  • [x] I have checked the superset logs for python stacktraces and included it here as text if any
  • [x] I have reproduced the issue with at least the latest released version of superset
  • [x] I have checked the issue tracker for the same issue and I haven't found one similar

Superset version

0.26.0 with all pip dependencies from the requirements.txt

additional libs

sqlalchemy-clickhouse==0.1.3.post0

Expected results

same charts and query results like before the update from 0.25.6 (same sqlalchemy-clickhouse version)

Actual results

no chart, no dashboard, nor any single query in the lab works

2018-07-04 16:11:33,668:ERROR:root:'str' object has no attribute 'db_type'
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/superset/connectors/sqla/models.py", line 743, in query
    df = self.database.get_df(sql, self.schema)
  File "/usr/local/lib/python3.6/site-packages/superset/models/core.py", line 700, in get_df
    df = pd.read_sql_query(sqls[-1], eng)
  File "/usr/local/lib/python3.6/site-packages/pandas/io/sql.py", line 332, in read_sql_query
    parse_dates=parse_dates, chunksize=chunksize)
  File "/usr/local/lib/python3.6/site-packages/pandas/io/sql.py", line 1092, in read_query
    result = self.execute(*args)
  File "/usr/local/lib/python3.6/site-packages/pandas/io/sql.py", line 983, in execute
    return self.connectable.execute(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2075, in execute
    return connection.execute(statement, *multiparams, **params)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 942, in execute
    return self._execute_text(object, multiparams, params)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1104, in _execute_text
    statement, parameters
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1200, in _execute_context
    context)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1416, in _handle_dbapi_exception
    util.reraise(*exc_info)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 187, in reraise
    raise value
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
    context)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 507, in do_execute
    cursor.execute(statement, parameters)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy_clickhouse/connector.py", line 209, in execute
    self._process_response(response)
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy_clickhouse/connector.py", line 342, in _process_response
    cols = [(f[0], f[1].db_type) for f in r._fields]
  File "/usr/local/lib/python3.6/site-packages/sqlalchemy_clickhouse/connector.py", line 342, in <listcomp>
    cols = [(f[0], f[1].db_type) for f in r._fields]
AttributeError: 'str' object has no attribute 'db_type'

Steps to reproduce

docker run --name superset -p 8088:8088 noenv/superset:0.26.0 and try to connect to a clickhouse instance

zyclonite avatar Jul 04 '18 16:07 zyclonite

On our side it's a simple pandas.read_sql_query and it's sqlalchemy_clickhouse raising the issue, this seems external to Superset. Maybe 0.26.0 requires a newer Pandas that doesn't play well with the clickhouse dialect?

mistercrunch avatar Jul 04 '18 21:07 mistercrunch

pandas, sqlalchemy and the clickhouse lib are the same versions between 0.25.6 and 0.26.0

zyclonite avatar Jul 05 '18 06:07 zyclonite

tested 0.26.3 now

  • same issue on existing installation
  • even after a clean install, adding a database fails already

zyclonite avatar Jul 06 '18 08:07 zyclonite

the issue comes from the upgrade of infi.clickhouse-orm from 0.9.8 to 1.0.0
this lib is a dependency of sqlalchemy_clickhouse

so not a superset issue

zyclonite avatar Jul 06 '18 10:07 zyclonite

When connecting the superset with clickhouse, I faced the same issue that "Error:'str' object has no attribute 'db_type'. After reading this conversation, I downgraded my infi.clickhouse-orm package using the following command: sudo pip install infi.clickhouse-orm==0.9.8

then, I restarted my superset server and now, Its working fine. Thank you, Manikandan.K

Manikandan25 avatar Aug 06 '18 07:08 Manikandan25