You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2018/07/24 15:00:30 UTC

[GitHub] HankCalzaretta opened a new issue #5473: Metric labels changed in SA Dialect result in KeyError in Superset

HankCalzaretta opened a new issue #5473: Metric labels changed in SA Dialect result in KeyError in Superset
URL: https://github.com/apache/incubator-superset/issues/5473
 
 
   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
   Superset 0.25.6
   
   ### Expected results
   Our company is developing a new database that we want to be supported by Superset/SQLAlchemy.
   Our SQL syntax doesn't support the default metric labels used by Superset so we modify the labels in our SA dialect.
   
   For example, we change this syntax in our SA dialect:
   
       SUM(amount) AS "SUM(amount)"
   
   to this (changed paren to underscore):
   
       SUM(amount) AS "SUM_amount"
   
   This syntax works for tabular views in Superset but for charts we get the following error:
   
       KeyError: u'SUM(amount)'
   
   ### Actual results
   2018-07-24 08:57:43,680:ERROR:root:u'SUM(amount)'
   Traceback (most recent call last):
     File "/usr/local/lib/python2.7/dist-packages/superset/views/core.py", line 1107, in generate_json
       payload = viz_obj.get_payload()
     File "/usr/local/lib/python2.7/dist-packages/superset/viz.py", line 329, in get_payload
       payload['data'] = self.get_data(df)
     File "/usr/local/lib/python2.7/dist-packages/superset/viz.py", line 1430, in get_data
       row = df.groupby(self.groupby).sum()[self.metrics[0]].copy()
     File "/usr/local/lib/python2.7/dist-packages/pandas/core/frame.py", line 2688, in __getitem__
       return self._getitem_column(key)
     File "/usr/local/lib/python2.7/dist-packages/pandas/core/frame.py", line 2695, in _getitem_column
       return self._get_item_cache(key)
     File "/usr/local/lib/python2.7/dist-packages/pandas/core/generic.py", line 2486, in _get_item_cache
       values = self._data.get(item)
     File "/usr/local/lib/python2.7/dist-packages/pandas/core/internals.py", line 4115, in get
       loc = self.items.get_loc(item)
     File "/usr/local/lib/python2.7/dist-packages/pandas/core/indexes/base.py", line 3066, in get_loc
       return self._engine.get_loc(self._maybe_cast_indexer(key))
     File "pandas/_libs/index.pyx", line 140, in pandas._libs.index.IndexEngine.get_loc
     File "pandas/_libs/index.pyx", line 162, in pandas._libs.index.IndexEngine.get_loc
     File "pandas/_libs/hashtable_class_helper.pxi", line 1492, in pandas._libs.hashtable.PyObjectHashTable.get_item
     File "pandas/_libs/hashtable_class_helper.pxi", line 1500, in pandas._libs.hashtable.PyObjectHashTable.get_item
   KeyError: u'SUM(amount)'
   
   ### Steps to reproduce
   Obviously Superset is 'remembering' the old, unmodified label.  Any suggestions on the proper way to modify these metric labels such that both Superset and our SQL syntax is happy? 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org