<p dir="auto">Running a simple <code class="notranslate">select *</code> query on a DB table and getting an error: <code class="notranslate">DatetimeTZDtype' object has no attribute 'char'</code></p>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have checked the superset logs for python stacktraces and included it here as text if any</li>
</ul>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  File &quot;/Users/ruchir/venv/lib/python2.7/site-packages/superset/views/core.py&quot;, line 2076, in sql_json
    query_id=query_id, return_results=True)
  File &quot;/Users/ruchir/venv/lib/python2.7/site-packages/celery/local.py&quot;, line 188, in __call__
    return self._get_current_object()(*a, **kw)
  File &quot;/Users/ruchir/venv/lib/python2.7/site-packages/celery/app/task.py&quot;, line 428, in __call__
    return self.run(*args, **kwargs)
  File &quot;/Users/ruchir/venv/lib/python2.7/site-packages/superset/sql_lab.py&quot;, line 91, in get_sql_results
    ctask, query_id, return_results, store_results)
  File &quot;/Users/ruchir/venv/lib/python2.7/site-packages/superset/sql_lab.py&quot;, line 233, in execute_sql
    'columns': cdf.columns if cdf.columns else [],
  File &quot;/Users/ruchir/venv/lib/python2.7/site-packages/superset/dataframe.py&quot;, line 108, in columns
    col_db_type = self.db_type(self.__df.dtypes[col])
  File &quot;/Users/ruchir/venv/lib/python2.7/site-packages/superset/dataframe.py&quot;, line 55, in db_type
    return cls.type_map.get(dtype.char)
AttributeError: 'DatetimeTZDtype' object has no attribute 'char'"><pre class="notranslate"><code class="notranslate">Traceback (most recent call last):
  File "/Users/ruchir/venv/lib/python2.7/site-packages/superset/views/core.py", line 2076, in sql_json
    query_id=query_id, return_results=True)
  File "/Users/ruchir/venv/lib/python2.7/site-packages/celery/local.py", line 188, in __call__
    return self._get_current_object()(*a, **kw)
  File "/Users/ruchir/venv/lib/python2.7/site-packages/celery/app/task.py", line 428, in __call__
    return self.run(*args, **kwargs)
  File "/Users/ruchir/venv/lib/python2.7/site-packages/superset/sql_lab.py", line 91, in get_sql_results
    ctask, query_id, return_results, store_results)
  File "/Users/ruchir/venv/lib/python2.7/site-packages/superset/sql_lab.py", line 233, in execute_sql
    'columns': cdf.columns if cdf.columns else [],
  File "/Users/ruchir/venv/lib/python2.7/site-packages/superset/dataframe.py", line 108, in columns
    col_db_type = self.db_type(self.__df.dtypes[col])
  File "/Users/ruchir/venv/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'
</code></pre></div>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have reproduced the issue with at least the latest released version of superset<br>
Yes</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> I have checked the issue tracker for the same issue and I haven't found one similar<br>
Found this: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="230288393" data-permission-text="Title is private" data-url="https://github.com/apache/superset/issues/2791" data-hovercard-type="issue" data-hovercard-url="/apache/superset/issues/2791/hovercard" href="https://github.com/apache/superset/issues/2791">#2791</a> but does not address how to deal with situation when the DB table already exists</li>
</ul>
<h3 dir="auto">Superset version</h3>
<p dir="auto">0.19.1</p>
<h3 dir="auto">Expected results</h3>
<p dir="auto">Should return result of SQL query</p>
<h3 dir="auto">Actual results</h3>
<p dir="auto">Getting Error: 'DatetimeTZDtype' object has no attribute 'char'</p>
<h3 dir="auto">Steps to reproduce</h3>
<p dir="auto">Run any query on a DB which has a timestamptz column type</p>
<p dir="auto">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.</p>
<p dir="auto"><code class="notranslate">AttributeError: 'DatetimeTZDtype' object has no attribute 'char'</code></p>
<h3 dir="auto">Superset version</h3>
<p dir="auto"><code class="notranslate">{ GIT_SHA: "", version: "0.18.2" }</code></p>
<h3 dir="auto">Expected results</h3>
<p dir="auto">SQL query should give all the columns for give query.</p>
<h3 dir="auto">Actual results</h3>
<p dir="auto">Python error (see below).</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="2017-05-22 10:32:10,890:ERROR:root:'DatetimeTZDtype' object has no attribute 'char'
Traceback (most recent call last):
  File &quot;/home/neeraj/Apps/superset-env/local/lib/python2.7/site-packages/superset/views/core.py&quot;, line 2028, in sql_json
    query_id=query_id, return_results=True)
  File &quot;/home/neeraj/Apps/superset-env/local/lib/python2.7/site-packages/celery/local.py&quot;, line 188, in __call__
    return self._get_current_object()(*a, **kw)
  File &quot;/home/neeraj/Apps/superset-env/local/lib/python2.7/site-packages/celery/app/task.py&quot;, line 420, in __call__
    return self.run(*args, **kwargs)
  File &quot;/home/neeraj/Apps/superset-env/local/lib/python2.7/site-packages/superset/sql_lab.py&quot;, line 181, in get_sql_results
    'columns': cdf.columns if cdf.columns else [],
  File &quot;/home/neeraj/Apps/superset-env/local/lib/python2.7/site-packages/superset/dataframe.py&quot;, line 108, in columns
    col_db_type = self.db_type(self.__df.dtypes[col])
  File &quot;/home/neeraj/Apps/superset-env/local/lib/python2.7/site-packages/superset/dataframe.py&quot;, line 55, in db_type
    return cls.type_map.get(dtype.char)
AttributeError: 'DatetimeTZDtype' object has no attribute 'char'"><pre class="notranslate"><code class="notranslate">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'
</code></pre></div>
<h3 dir="auto">Steps to reproduce</h3>
<ol dir="auto">
<li>Create the following table in clickhouse.</li>
</ol>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="CREATE TABLE gauge_metric
(
    EventDate Date,
    Timestamp DateTime,
    Node String,
    Name String,
    Value Float32
) ENGINE = MergeTree(EventDate, (Name, Node, Timestamp), 8192);"><pre class="notranslate"><code class="notranslate">CREATE TABLE gauge_metric
(
    EventDate Date,
    Timestamp DateTime,
    Node String,
    Name String,
    Value Float32
) ENGINE = MergeTree(EventDate, (Name, Node, Timestamp), 8192);
</code></pre></div>
<ol start="2" dir="auto">
<li>
<p dir="auto">Insert some data into the above table.</p>
</li>
<li>
<p dir="auto">Install <a href="https://github.com/cloudflare/sqlalchemy-clickhouse">sqlalchemy-clickhouse</a> along with <a href="https://github.com/airbnb/superset">superset</a>.</p>
</li>
<li>
<p dir="auto">Add clickhouse as datasource with "clickhouse://:8123" as the SQLAlchemy URI.</p>
</li>
<li>
<p dir="auto">Open SQL Lab and try executing the following query.</p>
</li>
</ol>
<p dir="auto"><code class="notranslate">select EventDate,Node,Value,Timestamp,Name from dbname.gauge_metric LIMIT 10;</code></p>