aonurdemir opened a new issue #15144:
URL: https://github.com/apache/superset/issues/15144


   Although I am not checking `sort by descending` checkbox, it sorts series 
limit data by desc.
   
   ### Expected results
   
   It is expected to be sorted by asc and query should be like below:
   ```sql
   SELECT "gift_id" AS "gift_id",
          COUNT(*) AS "count"
   FROM "druid"."druid_big_table_events"
   WHERE "__time" >= '2021-06-07 08:46:26.000000'
     AND "__time" < '2021-06-14 08:46:26.000000'
     AND "event_name" = 'gift'
   GROUP BY "gift_id"
   ORDER BY "count" ASC
   LIMIT 5;
   
   SELECT FLOOR("__time" TO DAY) AS "__timestamp",
          "gift_id" AS "gift_id",
          COUNT(*) AS "count"
   FROM "druid"."druid_big_table_events"
   WHERE "__time" >= '2021-06-07 08:46:26.000000'
     AND "__time" < '2021-06-14 08:46:26.000000'
     AND "event_name" = 'gift'
     AND ("gift_id" = 'heart'
          OR "gift_id" = 'rose'
          OR "gift_id" = 'perfume'
          OR "gift_id" = 'kiss'
          OR "gift_id" = 'chocolate')
   GROUP BY "gift_id",
            FLOOR("__time" TO DAY)
   LIMIT 50000;
   ``` 
   
   ### Actual results
   
   It builds the query like this:
   ```sql
   SELECT "gift_id" AS "gift_id",
          COUNT(*) AS "count"
   FROM "druid"."druid_big_table_events"
   WHERE "__time" >= '2021-06-07 08:46:26.000000'
     AND "__time" < '2021-06-14 08:46:26.000000'
     AND "event_name" = 'gift'
   GROUP BY "gift_id"
   ORDER BY "count" DESC
   LIMIT 5;
   
   SELECT FLOOR("__time" TO DAY) AS "__timestamp",
          "gift_id" AS "gift_id",
          COUNT(*) AS "count"
   FROM "druid"."druid_big_table_events"
   WHERE "__time" >= '2021-06-07 08:46:26.000000'
     AND "__time" < '2021-06-14 08:46:26.000000'
     AND "event_name" = 'gift'
     AND ("gift_id" = 'heart'
          OR "gift_id" = 'rose'
          OR "gift_id" = 'perfume'
          OR "gift_id" = 'kiss'
          OR "gift_id" = 'chocolate')
   GROUP BY "gift_id",
            FLOOR("__time" TO DAY)
   LIMIT 50000;
   ``` 
   
   #### Screenshots
   [ss1](https://i.ibb.co/VCG3JCH/3.png)
   [ss2](https://i.ibb.co/sPHc7Wz/4.png)
   
   #### How to reproduce the bug
   
   1. Choose a dataset to create a chart
   2. Choose VISUALIZATION TYPE  as `line chart`
   3. Choose `count(*)` as metric
   4. Choose a breakdown column as group by column
   5. Set a small series limit
   6. Choose `count(*)` as sort by column
   7. **DO NOT** check `SORT DESCENDING` checkbox
   8. Click `View Query` on the top-right menu
   9. See that the first query is built using `ORDER BY "count" DESC` phrase
   
   ### Environment
   
   (please complete the following information):
   
   - docker image: `apache/superset:1.1.0`
   
   ### Checklist
   
   Make sure to follow these steps before submitting your issue - thank you!
   
   - [ ] I have checked the superset logs for python stacktraces and included 
it here as text if there are 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.
   
   ### Additional context
   
   The problem seems to be reproduced on druid databases. It works correctly 
with mysql.
   


-- 
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.

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