Make sure these boxes are checked before submitting your issue - thank you!

- [ ] I have checked the superset logs for python stacktraces and included it 
here as text if any
- [ ] I have reproduced the issue with at least the latest released version of 
superset
- [ ] I have checked the issue tracker for the same issue and I haven't found 
one similar


### Superset version

0.26.3

### Expected results

Time Series - Line Chart rendered.

### Actual results

Error with no clear message.

### Steps to reproduce

1. Create a query in SQL Lab with a datetime column and an integer column (or 
just use any datasource that has a datetime column and group by that column to 
count the number of rows)
2. Click on 'Explore' to visualize the resulting table
![image](https://user-images.githubusercontent.com/32204890/44485429-21b80700-a616-11e8-8821-bc0239c73776.png)

3. Choose Time Series - Line Chart as an option to visualize
4. Add your integer column as value for the 'Metrics' option
5. Click on 'Run Query'
![image](https://user-images.githubusercontent.com/32204890/44484381-45c61900-a613-11e8-9d6d-4d06e860013c.png)

Here is the trackeback I get
`Traceback (most recent call last):
  File "/home/work/incubator-superset/superset/views/core.py", line 1115, in 
generate_json
    payload = viz_obj.get_payload()
  File "/home/work/incubator-superset/superset/viz.py", line 347, in get_payload
    payload['data'] = self.get_data(df)
  File "/home/work/incubator-superset/superset/viz.py", line 1217, in get_data
    df = self.process_data(df)
  File "/home/work/incubator-superset/superset/viz.py", line 1137, in 
process_data
    values=utils.get_metric_names(fd.get('metrics')))
  File "/usr/local/lib/python3.6/site-packages/pandas/core/frame.py", line 
5303, in pivot_table
    margins_name=margins_name)
  File "/usr/local/lib/python3.6/site-packages/pandas/core/reshape/pivot.py", 
line 61, in pivot_table
    raise KeyError(i)
KeyError: 'SUM(total_visits)'`

The traceback doesn't seem to be helpful.

This is the query that is generated automatically to visualize the resulting 
table:
`SELECT weekly AS __timestamp,
       SUM(total_visits) AS "SUM(total_visits)"
FROM
  (SELECT DATE_TRUNC('WEEK', "timestamp") weekly,
          COUNT(*) total_visits
   FROM my_table
   WHERE "timestamp" >= '2018-06-01'
   GROUP BY 1) AS expr_qry
WHERE weekly >= '1918-08-22 00:00:00'
GROUP BY weekly
ORDER BY "SUM(total_visits)" DESC
LIMIT 50000;`

I've tried the following to see if it works: 
- grouping the data by the column 'weekly' in the 'Query' options, 
- adding a value for Time Grain,
- trying to visualize using both Chrome and Mozilla Firefox,
- using a different time column in the table to see if there was any conflict 
caused by the name of the column being 'timestamp'
- changing the 'Metrics' definition from 'SUM(total_visits)' to 'total_visits' 
-> This produces another message:
![image](https://user-images.githubusercontent.com/32204890/44485903-bc651580-a617-11e8-9949-4e405d712a77.png)

![image](https://user-images.githubusercontent.com/32204890/44485956-e0c0f200-a617-11e8-8048-557bcf432c94.png)

[ Full content available at: 
https://github.com/apache/incubator-superset/issues/5700 ]
This message was relayed via gitbox.apache.org for [email protected]

Reply via email to