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: add global max row limit #16683

Merged
merged 10 commits into from
Sep 16, 2021
Merged

Conversation

villebro
Copy link
Member

@villebro villebro commented Sep 13, 2021

SUMMARY

Assume SQL_MAX_ROW as the global maximum row count for the following queries:

  • Chart data result requests
  • Chart data sample requests
  • SQL Lab queries

In addition, the old VIZ_ROW_LIMIT parameter is removed, as it has been replaced by ROW_LIMIT everywhere else except in the histogram chart, hence is not really used any longer.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • 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

@villebro villebro changed the title feat: add global max limit feat: add global max row limit Sep 13, 2021
@zhaoyongjie zhaoyongjie self-requested a review September 13, 2021 09:44
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

superset/config.py Outdated Show resolved Hide resolved
Copy link
Member

@etr2460 etr2460 left a comment

Choose a reason for hiding this comment

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

Instead of adding yet another sql limit, shouldn't we be using SQL_MAX_ROW to limit the max rows, regardless of what the user provides?

@villebro
Copy link
Member Author

@etr2460 well, I did remove one, so the change is net neutral 😄 Joking aside, that's not a bad idea - so should we apply SQL_MAX_ROW as the global max for any type of query, i.e. in this case use that instead of MAX_GLOBAL_ROW_LIMIT?

@etr2460
Copy link
Member

etr2460 commented Sep 14, 2021

@villebro I'm a fan of that approach personally, I think it's how it's actually supposed to work

@villebro
Copy link
Member Author

@villebro I'm a fan of that approach personally, I think it's how it's actually supposed to work

Perfect, I'll update accordingly!

@villebro villebro force-pushed the villebro/max-limit branch 3 times, most recently from c1de713 to dac8dfa Compare September 15, 2021 08:03
@@ -1762,3 +1762,29 @@ def parse_boolean_string(bool_str: Optional[str]) -> bool:
return bool(strtobool(bool_str.lower()))
except ValueError:
return False


def apply_max_row_limit(max_limit: Optional[int], limit: int) -> int:
Copy link
Member

Choose a reason for hiding this comment

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

instead of needing to pass in the max row limit, should we access the config value here? Seems like the first argument is always set to the same thing where this function is used

Copy link
Member Author

Choose a reason for hiding this comment

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

You know you're absolutely right, this current sig is really an artifact from earlier iterations of this PR. Will update accordingly 👍

@codecov
Copy link

codecov bot commented Sep 16, 2021

Codecov Report

Merging #16683 (cb311dc) into master (a839649) will decrease coverage by 0.20%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #16683      +/-   ##
==========================================
- Coverage   76.97%   76.76%   -0.21%     
==========================================
  Files        1007     1007              
  Lines       54163    54168       +5     
  Branches     7463     7374      -89     
==========================================
- Hits        41690    41582     -108     
- Misses      12233    12346     +113     
  Partials      240      240              
Flag Coverage Δ
hive ?
mysql 81.73% <100.00%> (+0.02%) ⬆️
postgres 81.79% <100.00%> (+0.02%) ⬆️
presto ?
python 81.88% <100.00%> (-0.41%) ⬇️
sqlite 81.36% <100.00%> (+0.02%) ⬆️

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

Impacted Files Coverage Δ
superset/common/query_actions.py 92.53% <ø> (-0.43%) ⬇️
superset/config.py 91.44% <ø> (-0.03%) ⬇️
superset/common/query_context.py 90.74% <100.00%> (ø)
superset/common/query_object.py 94.44% <100.00%> (+3.81%) ⬆️
superset/utils/core.py 89.84% <100.00%> (-0.05%) ⬇️
superset/utils/sqllab_execution_context.py 92.43% <100.00%> (+0.06%) ⬆️
superset/views/core.py 76.29% <100.00%> (+0.01%) ⬆️
superset/viz.py 57.91% <100.00%> (+0.05%) ⬆️
superset/db_engines/hive.py 0.00% <0.00%> (-82.15%) ⬇️
superset/db_engine_specs/hive.py 69.80% <0.00%> (-16.87%) ⬇️
... and 7 more

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 a839649...cb311dc. Read the comment docs.

Copy link
Member

@dpgaspar dpgaspar left a comment

Choose a reason for hiding this comment

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

LGTM

superset/common/query_object.py Outdated Show resolved Hide resolved
superset/config.py Outdated Show resolved Hide resolved
Copy link
Member

@etr2460 etr2460 left a comment

Choose a reason for hiding this comment

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

lgtm, thanks for iterating and the tests!

@villebro villebro merged commit 4e3d4f6 into apache:master Sep 16, 2021
@villebro villebro deleted the villebro/max-limit branch September 16, 2021 16:33
@villebro villebro added the v1.3 label Sep 16, 2021
stevenuray pushed a commit to preset-io/superset that referenced this pull request Sep 17, 2021
* feat: add global max limit

* fix lint and tests

* leave SAMPLES_ROW_LIMIT unchanged

* fix sample rowcount test

* replace max global limit with existing sql max row limit

* fix test

* make max_limit optional in util

* improve comments

(cherry picked from commit 4e3d4f6)
@villebro villebro removed the v1.3 label Sep 22, 2021
opus-42 pushed a commit to opus-42/incubator-superset that referenced this pull request Nov 14, 2021
* feat: add global max limit

* fix lint and tests

* leave SAMPLES_ROW_LIMIT unchanged

* fix sample rowcount test

* replace max global limit with existing sql max row limit

* fix test

* make max_limit optional in util

* improve comments
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 28, 2021
* feat: add global max limit

* fix lint and tests

* leave SAMPLES_ROW_LIMIT unchanged

* fix sample rowcount test

* replace max global limit with existing sql max row limit

* fix test

* make max_limit optional in util

* improve comments
@nickrbclark
Copy link

in https://domain.com/api/v1/dashboard/7/datasets I was getting a type mismatch error.
in apply_max_row_limit line 1833,
min(max_limit, limit)
I was getting a
'<' not supported between instances of 'str' and 'int'
I wasn't really sure what was going on, but I was able to fix it with
min(max_limit, int(limit))

I have no idea if there's something wrong with my config, or if the particular usage of the function through this api call was bad.

@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.4.0 labels Mar 13, 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 preset-io size/L 🚢 1.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants