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

Failure while pulling clickhouse table with datetime (DatetimeTZDtype has no attribute 'char') #2791

Closed
neeraj9 opened this issue May 22, 2017 · 3 comments

Comments

@neeraj9
Copy link

neeraj9 commented May 22, 2017

While pulling data from clickhouse within superset things work as long as fields are not of type datetime. When trying to get data for a datetime column then it gives the following python error.

AttributeError: 'DatetimeTZDtype' object has no attribute 'char'

Superset version

{ GIT_SHA: "", version: "0.18.2" }

Expected results

SQL query should give all the columns for give query.

Actual results

Python error (see below).

2017-05-22 10:32:10,890:ERROR:root:'DatetimeTZDtype' object has no attribute 'char'
Traceback (most recent call last):
  File "/home/neeraj/Apps/superset-env/local/lib/python2.7/site-packages/superset/views/core.py", line 2028, in sql_json
    query_id=query_id, return_results=True)
  File "/home/neeraj/Apps/superset-env/local/lib/python2.7/site-packages/celery/local.py", line 188, in __call__
    return self._get_current_object()(*a, **kw)
  File "/home/neeraj/Apps/superset-env/local/lib/python2.7/site-packages/celery/app/task.py", line 420, in __call__
    return self.run(*args, **kwargs)
  File "/home/neeraj/Apps/superset-env/local/lib/python2.7/site-packages/superset/sql_lab.py", line 181, in get_sql_results
    'columns': cdf.columns if cdf.columns else [],
  File "/home/neeraj/Apps/superset-env/local/lib/python2.7/site-packages/superset/dataframe.py", line 108, in columns
    col_db_type = self.db_type(self.__df.dtypes[col])
  File "/home/neeraj/Apps/superset-env/local/lib/python2.7/site-packages/superset/dataframe.py", line 55, in db_type
    return cls.type_map.get(dtype.char)
AttributeError: 'DatetimeTZDtype' object has no attribute 'char'

Steps to reproduce

  1. Create the following table in clickhouse.
CREATE TABLE gauge_metric
(
    EventDate Date,
    Timestamp DateTime,
    Node String,
    Name String,
    Value Float32
) ENGINE = MergeTree(EventDate, (Name, Node, Timestamp), 8192);
  1. Insert some data into the above table.

  2. Install sqlalchemy-clickhouse along with superset.

  3. Add clickhouse as datasource with "clickhouse://:8123" as the SQLAlchemy URI.

  4. Open SQL Lab and try executing the following query.

select EventDate,Node,Value,Timestamp,Name from dbname.gauge_metric LIMIT 10;

@ratb3rt
Copy link

ratb3rt commented Jun 22, 2017

This is a Pandas bug: pandas-dev/pandas#12985
A workaround is to use toString(Timestamp). If you need to have Timestamp as a datetime data type for slices, then use the toString version to initially create the table in Superset, then edit the definition to take out the toString and change the column to a DATETIME data type.

@fabianmenges
Copy link
Contributor

#2937 should fix this

@mistercrunch
Copy link
Member

Notice: this issue has been closed because it has been inactive for 213 days. Feel free to comment and request for this issue to be reopened.

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

4 participants