kevin-struckhoff opened a new issue #16486:
URL: https://github.com/apache/superset/issues/16486


   Upon running the query for a newly built chart, an error message popped up 
saying 'Unexpected error' 'day_of_week'. Viewing the SQL for the query reveals 
a perfectly constructed SQL statement which runs just fine on my postgres db 
server. In the dataset for this table, the 'day_of_week' column is marked as 
'is temporal' and it self-populated the time column box as expected. I also 
used the column 'day_of_week' as the 'sort by' column by adding it using 
'custom sql'. The error is caused by the custom sql sort by setting. If I 
remove the  sort by the query runs but the data isn't sorted correctly. Sorting 
by non-metric columns is a must-have.
   
   I expected the query to run without error of course. In the attached 
screenshot, the query references the table calories_dow_agg which has 7 rows of 
data:
   
   create table calories_dow_agg (day_of_week char(8), avg_calories smallint);
   
    day_of_week | SUM(avg_calories)
   -------------+-------------------
     1 - Sun    |              1593
     2 - Mon    |              1618
     3 - Tue    |              1466
     4 - Wed    |              1431
     5 - Thu    |              1730
     6 - Fri    |              1559
     7 - Sat    |              1787
   (7 rows)
   
   #### How to reproduce the bug
   
   1. Create table and load data using the schema and data provided above.
   2. Add a new dataset for the table.
   3. Create a Bar chart and update the metric as 'SUM(avg_calories)', the 
series as 'day_of_week' and the sort by as 'day_of_week' in the custom sql tab.
   4. Press the Run button
   5. see the error
   
   ### Environment
   
   (please complete the following information):
   
   - superset version: `1.3.0`
   - python version: 3.8.6
   
   - any feature flags active: --with-threads --reload --debugger
   - 
   
![Unexpected-error](https://user-images.githubusercontent.com/88514509/131175919-02591217-869c-44b2-9781-d4e453fe64a9.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to