-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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: the samples endpoint supports filters and pagination #20683
Conversation
Codecov Report
@@ Coverage Diff @@
## master #20683 +/- ##
==========================================
- Coverage 66.29% 66.14% -0.16%
==========================================
Files 1758 1757 -1
Lines 66801 66742 -59
Branches 7055 7055
==========================================
- Hits 44288 44148 -140
- Misses 20713 20794 +81
Partials 1800 1800
Flags with carried forward coverage won't be shown. Click here to find out more.
|
594745a
to
6dca2b9
Compare
6dca2b9
to
b7edacf
Compare
if limit < 0 or limit > samples_row_limit: | ||
# reset limit value if input is invalid | ||
limit = samples_row_limit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be easily refactored to raise an exception if needed
if offset < 0: | ||
# reset offset value if input is invalid | ||
offset = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @zhaoyongjie. I left some first-pass comments.
# reset limit value if input is invalid | ||
limit = samples_row_limit | ||
|
||
offset = (int(page) - 1) * limit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the frontend defaults to 0-indexed page numbers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The page number starts from 1 instead of 0.
b25ee21
to
d93c211
Compare
ac82e08
to
db8382b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some nits. Would love to test this out once CI passes
db8382b
to
ea4aa7f
Compare
ea4aa7f
to
1a7b381
Compare
@zhaoyongjie This looks good to me! One question, are we not considering this part of the public API, and that's why it's not under the |
@zhaoyongjie Thank you so much for cleaning the duplicated |
@codyml @michael-s-molina this is an interesting question, because now it is not dataset samples but different types of datasouce samples, so it should not be put under dataset, ----- introduced different datasource from PR ---- That's why I moved it to datasource. v1 API still has a lot of work to do, for example:
So the view and v1 api will coexist for a long time. I will address these issues in the seprated PR. |
Thank you for the explanation @zhaoyongjie. It seems we're missing this new concept in v1 as you said. About deleting the old endpoints. I did something slightly different for the old |
Does the superset-fronted support sample filters when request sample ? I've tested the v3.1, it did't work. For hive, presto, this may cause all partitions scan. |
SUMMARY
The original Superset had been using a query API(
/api/v1/chart/data
) to get data samples, but was refactored to use a separate API for getting data samples. The purpose of the refactoring is to get samples by passing onlydataset/datasouce id
.The recent PR introduced multiple datasouce type and duplicate samples codes.
The purpose of this PR is to merge all samples logic and to provide filtering and pagination on top of the original samples API.
We can remove the original sample function from the
/api/v1/chart/data
, In the separate PR.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
pure backend feature, so that there aren't screenshots.
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION