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 support for query offset #10010

Merged
merged 2 commits into from Jun 9, 2020
Merged

Conversation

villebro
Copy link
Member

@villebro villebro commented Jun 8, 2020

SUMMARY

In order to support server side pagination, support for row_offset needs to be added to to complement row_limit in QueryObject.

TEST PLAN

CI + new tests

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

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.

Looks good, just a couple of comments

@@ -664,6 +664,7 @@ class ChartDataQueryObjectSchema(Schema):
row_limit = fields.Integer(
description='Maximum row count. Default: `config["ROW_LIMIT"]`',
)
row_offset = fields.Integer(description="Number of rows to skip. Default: `0`",)
Copy link
Member

Choose a reason for hiding this comment

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

consider enforcing row_offset is >0

validate=[Range(min=0, error=_("row_offset must be greater than 0"))])

superset/charts/schemas.py Show resolved Hide resolved
self.login(username="admin")
table = self.get_table_by_name("birth_names")
request_payload = get_query_context(table.name, table.id, table.type)
request_payload["queries"][0]["row_limit"] = 5
Copy link
Member

Choose a reason for hiding this comment

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

Would be nice to a couple of simple tests with invalid row_limit and row_offset. negative values, bigger then SAMPLES_ROW_LIMIT

Copy link
Member Author

Choose a reason for hiding this comment

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

Added schema validation tests (tests/chart/schema_tests.py) for validation of row_limit and row_offset and e2e tests (tests/chart/api_tests.py) to ensure regular and sample row limits produce correct row counts.

@codecov-commenter
Copy link

codecov-commenter commented Jun 8, 2020

Codecov Report

Merging #10010 into master will increase coverage by 4.82%.
The diff coverage is 92.85%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10010      +/-   ##
==========================================
+ Coverage   65.59%   70.41%   +4.82%     
==========================================
  Files         585      585              
  Lines       31046    31056      +10     
  Branches     3277     3277              
==========================================
+ Hits        20364    21868    +1504     
+ Misses      10501     9077    -1424     
+ Partials      181      111      -70     
Flag Coverage Δ
#cypress 53.92% <ø> (?)
#javascript 59.36% <ø> (ø)
#python 69.99% <92.85%> (+0.01%) ⬆️
Impacted Files Coverage Δ
superset/connectors/druid/models.py 82.44% <50.00%> (-0.08%) ⬇️
superset/charts/schemas.py 100.00% <100.00%> (ø)
superset/common/query_context.py 79.37% <100.00%> (+0.12%) ⬆️
superset/common/query_object.py 89.81% <100.00%> (+0.29%) ⬆️
superset/connectors/sqla/models.py 88.95% <100.00%> (+0.18%) ⬆️
...rontend/src/SqlLab/components/AceEditorWrapper.tsx 56.98% <0.00%> (+1.07%) ⬆️
superset-frontend/src/components/EditableTitle.jsx 81.69% <0.00%> (+1.40%) ⬆️
...perset-frontend/src/components/CopyToClipboard.jsx 36.36% <0.00%> (+1.51%) ⬆️
...hboard/components/resizable/ResizableContainer.jsx 71.87% <0.00%> (+1.56%) ⬆️
... and 144 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 91517a5...09ca1dc. Read the comment docs.

@villebro villebro merged commit 315518d into apache:master Jun 9, 2020
@villebro villebro deleted the villebro/offset branch June 9, 2020 08:47
auxten pushed a commit to auxten/incubator-superset that referenced this pull request Nov 20, 2020
* feat: add support for query offset

* Address comments and add new tests
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.37.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 size/L 🚢 0.37.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants