behanjc opened a new issue #4662: Key Error in Viz using Snowflake Connector
URL: https://github.com/apache/incubator-superset/issues/4662
 
 
   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.23.3
   
   ### Expected results
   I am able to produce a simple Distribution Bar Chart using SQL Lab + 
Visualize for a Snowflake query
   
   ### Actual results
   I receive a superset Key Error
   
   ### Steps to reproduce
   Follow below with a Snowflake connection:
   
   I tested with Snowflake and Sqlite, the same exact query (which doesn't 
actually select from the databases):
   
   ```
   SELECT 'TEST1' as TESTCOL1, 5 as TESTCOLCOUNT
   UNION
   SELECT 'TEST2' as TESTCOL1, 10 as TESTCOLCOUNT;
   ```
   
   When I select TESTCOL1 as my dimension, and TESTCOLCOUNT (Sum(x)) as my 
metric, the chart is produced fine when I use sqlite.
   
   When I use the Snowflake connection instead, I receive the following 
traceback:
   ```
   Traceback (most recent call last):
     File 
"/Users/tud499/anaconda/envs/superset/lib/python3.5/site-packages/superset/views/core.py",
 line 1059, in generate_json
       payload = viz_obj.get_payload()
     File 
"/Users/tud499/anaconda/envs/superset/lib/python3.5/site-packages/superset/viz.py",
 line 293, in get_payload
       payload['data'] = self.get_data(df)
     File 
"/Users/tud499/anaconda/envs/superset/lib/python3.5/site-packages/superset/viz.py",
 line 1359, in get_data
       row = df.groupby(self.groupby).sum()[self.metrics[0]].copy()
     File 
"/Users/tud499/anaconda/envs/superset/lib/python3.5/site-packages/pandas/core/generic.py",
 line 5162, in groupby
       **kwargs)
     File 
"/Users/tud499/anaconda/envs/superset/lib/python3.5/site-packages/pandas/core/groupby.py",
 line 1848, in groupby
       return klass(obj, by, **kwds)
     File 
"/Users/tud499/anaconda/envs/superset/lib/python3.5/site-packages/pandas/core/groupby.py",
 line 516, in __init__
       mutated=self.mutated)
     File 
"/Users/tud499/anaconda/envs/superset/lib/python3.5/site-packages/pandas/core/groupby.py",
 line 2934, in _get_grouper
       raise KeyError(gpr)
   KeyError: 'TESTCOL1'
   ```
   
   Within the Viz screen, I checked the actual query being run (the wrapped 
superset version), and it was identical to what was run for the sqlite version:
   ```
   SELECT "TESTCOL1" AS "TESTCOL1",
          sum(TESTCOLCOUNT) AS "sum__TESTCOLCOUNT"
   FROM
     (SELECT 'TEST1' as TESTCOL1,
             5 as TESTCOLCOUNT
      UNION SELECT 'TEST2' as TESTCOL1,
                   10 as TESTCOLCOUNT) AS expr_qry
   GROUP BY "TESTCOL1"
   ORDER BY "sum__TESTCOLCOUNT" DESC
   LIMIT 50000
   ```
   
   Since everything looks identical to when I just try the same thing on a 
sqlite DB, I guessed it's something specific with the snowflake connector, but 
the query generated above, ran fine with snowflake and sqlalchemy, and it seems 
like it's a superset specific function that is failing after the query has 
successfully run. Does anyone have any ideas?
   
   

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to