-
Notifications
You must be signed in to change notification settings - Fork 21
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
Add support for new features on query results #111
Conversation
Add support for a few features that will soon become available when retrieving query results: - specify the output columns - get a sample of the results - filter out some rows before retrieve the results - sort the results
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.
There's a few more places with asserts that I think are duplicate. Please check
if filters is not None: | ||
params["filters"] = filters | ||
if sort_by is not None and len(sort_by) > 0: | ||
params["sort_by"] = ",".join(sort_by) |
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.
Wouldn't you want to do the escaping here too?
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.
No, this will be the user's responsibility since we can't reliably do it. The way they'll specify the order is something like this:
sort_by=['column_1', '"column 2" DESC', '"column\\" 3" ASC']
This should then get converted to the following:
column_1,"column 2" DESC,"column\\" 3" ASC
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.
Ah makes sense. We'll have to check for SQL injection then tho, right?
assert ( | ||
# We are not sampling | ||
sample_count is None | ||
# We are sampling and don't use filters or pagination | ||
or (batch_size is None and filters is None) | ||
), "sampling cannot be combined with filters or pagination" |
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.
Isn't this already covered by the assert on the build params function?
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.
It would, but it would only run after the refresh
assert ( | ||
# We are not sampling | ||
sample_count is None | ||
# We are sampling and don't use filters or pagination | ||
or (batch_size is None and filters is None) | ||
), "sampling cannot be combined with filters or pagination" |
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
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.
minor improvements suggested.
- fix link to API docs (updated)
- add link to API docs on public function docstrings
- default values for sample+limit+offset on _build_parameters()
@@ -114,6 +179,14 @@ def get_latest_result( | |||
:param max_age_hours: re-executes the query if result is older than max_age_hours | |||
https://dune.com/docs/api/api-reference/get-results/latest-results |
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.
update link to docs
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.
Will follow up in a separate PR to update all links to the docs (we do have a redirect tho)
Add support for a few features that will soon become available when retrieving query results: