Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(filter-box): sort by metric on backend #14340

Merged
merged 1 commit into from
Apr 26, 2021

Conversation

villebro
Copy link
Member

@villebro villebro commented Apr 26, 2021

SUMMARY

Currently when sorting a filter box select by metric, the ordering isn't being applied in the query, making it possible for relevant rows to be missing in the query if they fall below the default 1000 row limit.

This was found while working on adding feature parity to the native select filter. While we're aiming to deprecate filter box soon, I wanted to make sure the results in the select filter are consistent with those returned by the select filter when reconciling results.

SCREENSHOTS

When ordering countries in descending order by population
image
Query:

SELECT country_name AS country_name,
       sum("SP_POP_TOTL") AS "sum__SP_POP_TOTL"
FROM wb_health_population
GROUP BY country_name
ORDER BY "sum__SP_POP_TOTL" DESC
LIMIT 1000
OFFSET 0

SCREENSHOTS

When ordering countries in descending order by population
image
Query:

SELECT country_name AS country_name,
       sum("SP_POP_TOTL") AS "sum__SP_POP_TOTL"
FROM wb_health_population
GROUP BY country_name
ORDER BY "sum__SP_POP_TOTL" ASC
LIMIT 1000
OFFSET 0

When ordering

TEST PLAN

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@codecov
Copy link

codecov bot commented Apr 26, 2021

Codecov Report

Merging #14340 (3c555d3) into master (4d2c932) will decrease coverage by 0.00%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #14340      +/-   ##
==========================================
- Coverage   77.18%   77.17%   -0.01%     
==========================================
  Files         954      954              
  Lines       48134    48137       +3     
  Branches     5985     5985              
==========================================
- Hits        37151    37149       -2     
- Misses      10786    10791       +5     
  Partials      197      197              
Flag Coverage Δ
hive 80.77% <0.00%> (-0.01%) ⬇️
mysql 81.03% <0.00%> (-0.01%) ⬇️
postgres 81.07% <0.00%> (-0.01%) ⬇️
presto 80.76% <0.00%> (-0.02%) ⬇️
python 81.60% <0.00%> (-0.02%) ⬇️
sqlite 80.67% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
superset/viz.py 55.49% <0.00%> (-0.10%) ⬇️
superset/db_engine_specs/presto.py 89.89% <0.00%> (-0.43%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4d2c932...3c555d3. Read the comment docs.

@zhaoyongjie zhaoyongjie self-requested a review April 26, 2021 08:52
Copy link
Member

@zhaoyongjie zhaoyongjie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
In general, limit and order by clause need to appear in pairs so that the database returns consistent result set.

@junlincc junlincc added the dashboard:native-filters Related to the native filters of the Dashboard label Apr 26, 2021
@villebro villebro merged commit d7fc203 into apache:master Apr 26, 2021
@villebro villebro deleted the villebro/filterbox-orderby branch April 26, 2021 18:06
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 29, 2021
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.2.0 labels Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels dashboard:native-filters Related to the native filters of the Dashboard preset-io size/XS 🚢 1.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants