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

[Queries] Respect maxResults parameter when fetching query results #263

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ohaibbq
Copy link
Contributor

@ohaibbq ohaibbq commented Jan 25, 2024

Found while writing the Python client regression test for goccy/go-zetasqlite#132.

Closes #262
Closes #169

@@ -581,6 +583,22 @@ func parseQueryValueAsBool(r *http.Request, key string) bool {
return b
}

func parseQueryValueAsInt64(r *http.Request, key string, defaultValue int64) int64 {
Copy link
Owner

Choose a reason for hiding this comment

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

If we don't need to parse other int64 values, you can use a dedicated MaxResults function. e.g.) parseMaxResultValue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems likely that there may be other int64 values that we need to parse in the future, so it seems fine to leave as is

Copy link
Owner

Choose a reason for hiding this comment

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

Then I think it's ok to leave the function, just do the maxResults's validation somewhere else.

@goccy goccy added the reviewed label Apr 6, 2024
}

if r.maxResults != maxResultsDefaultValue {
rows = rows[:min(int64(len(rows)), r.maxResults)]
Copy link
Owner

Choose a reason for hiding this comment

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

If -1 is set as maxResults, I think panic may occur here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

-1 is the maxResultsDefaultValue. I can add a validation for < -1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants