superset icon indicating copy to clipboard operation
superset copied to clipboard

Get an error unhashable type: 'dict' in a TableView with a NUMERIC type using PostgreSQL

Open llozanoc opened this issue 8 years ago • 4 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.25.6

Expected results

Colum with the numeric values

Actual results

ERROR:root:unhashable type: 'dict'
Traceback (most recent call last):
  File "\site-packages\superset\viz.py", line 364, in get_df_payload
    df = self.get_df(query_obj)
  File "\site-packages\superset\viz.py", line 162, in get_df
    self.results = self.datasource.query(query_obj)
  File "\site-packages\superset\connectors\sqla\models.py", line 713, in query
    sql = self.get_query_str(query_obj)
  File "\site-packages\superset\connectors\sqla\models.py", line 422, in get_query_str
    qry = self.get_sqla_query(**query_obj)
  File "\site-packages\superset\connectors\sqla\models.py", line 520, in get_sqla_query
    elif m in metrics_dict:
TypeError: unhashable type: 'dict'

image

Steps to reproduce

  • Create Table View chart visualization
  • Time column since ever
  • Putting metrics
  • No filters & No clauses
  • Run query

llozanoc avatar Jun 14 '18 17:06 llozanoc

I and a few others have the exact same problem. The same issue happens when I use a heatmap. Possibly related #4984

Pivot table traceback

Traceback (most recent call last):
  File "/home/ubuntu/venv/lib/python3.5/site-packages/superset/views/core.py", line 1107, in generate_json
    payload = viz_obj.get_payload()
  File "/home/ubuntu/venv/lib/python3.5/site-packages/superset/viz.py", line 329, in get_payload
    payload['data'] = self.get_data(df)
  File "/home/ubuntu/venv/lib/python3.5/site-packages/superset/viz.py", line 628, in get_data
    margins=self.form_data.get('pivot_margins'),
  File "/home/ubuntu/venv/lib/python3.5/site-packages/pandas/core/frame.py", line 5303, in pivot_table
    margins_name=margins_name)
  File "/home/ubuntu/venv/lib/python3.5/site-packages/pandas/core/reshape/pivot.py", line 60, in pivot_table
    if i not in data:
  File "/home/ubuntu/venv/lib/python3.5/site-packages/pandas/core/generic.py", line 1519, in __contains__
    return key in self._info_axis
  File "/home/ubuntu/venv/lib/python3.5/site-packages/pandas/core/indexes/base.py", line 2021, in __contains__
    hash(key)
TypeError: unhashable type: 'dict'
2018-06-22 10:33:24,148:INFO:werkzeug:ip - - [22/Jun/2018 10:33:24] "POST /superset/explore_json/ HTTP/1.1" 500 -

Heatmap traceback

Traceback (most recent call last):
  File "/home/ubuntu/venv/lib/python3.5/site-packages/superset/views/core.py", line 1107, in generate_json 
    payload = viz_obj.get_payload()
  File "/home/ubuntu/venv/lib/python3.5/site-packages/superset/viz.py", line 329, in get_payload
    payload['data'] = self.get_data(df)
  File "/home/ubuntu/venv/lib/python3.5/site-packages/superset/viz.py", line 1801, in get_data
    df = df[[x, y, v]]
  File "/home/ubuntu/venv/lib/python3.5/site-packages/pandas/core/frame.py", line 2682, in __getitem__
    return self._getitem_array(key)
  File "/home/ubuntu/venv/lib/python3.5/site-packages/pandas/core/frame.py", line 2726, in _getitem_array  
    indexer = self.loc._convert_to_indexer(key, axis=1)
  File "/home/ubuntu/venv/lib/python3.5/site-packages/pandas/core/indexing.py", line 1314, in _convert_to_indexer
    indexer = check = labels.get_indexer(objarr)
  File "/home/ubuntu/venv/lib/python3.5/site-packages/pandas/core/indexes/base.py", line 3245, in get_indexer
    indexer = self._engine.get_indexer(target._ndarray_values)
  File "pandas/_libs/index.pyx", line 301, in pandas._libs.index.IndexEngine.get_indexer
  File "pandas/_libs/hashtable_class_helper.pxi", line 1544, in pandas._libs.hashtable.PyObjectHashTable.lookup
TypeError: unhashable type: 'dict'
2018-06-22 10:27:07,098:INFO:werkzeug:ip - - [22/Jun/2018 10:27:07] "POST /superset/explore_json/ HTTP/1.1" 500 -

pandas==0.23.1 PostgreSQL

tomwojcik avatar Jun 22 '18 10:06 tomwojcik

@llozanoc You've got to add an agg function or else it won't know how to parse your request...

teewhyli avatar Jun 25 '18 01:06 teewhyli

@TianyangLi Are you sure about that? I can make similar queries with other data types without any problem.

llozanoc avatar Jun 26 '18 07:06 llozanoc

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.

stale[bot] avatar Apr 10 '19 19:04 stale[bot]