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

Propagate error in TFetchResults #255

Merged

Conversation

vikrantpuppala
Copy link
Collaborator

Currently, an error thrown in TFetchResults within getNextPage in resultPageIterator will be swallowed and an EOF err will be returned instead. This PR solves #254

Signed-off-by: Vikrant Puppala <[email protected]>
@@ -456,10 +455,6 @@ func (r *rows) fetchResultPage() error {
r.RowScanner = nil
}

if !r.ResultPageIterator.HasNext() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you check the r.error and return r.error instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

@jackyhu-db I think it is possible to do a check like that, but I would like to clarify what is the use of HasNext if Next itself can just return nil, io.EOF to signify an end of the stream?

My question is more structural: why the additional complexity of HasNext when Next itself can interface and encapsulate the concept of HasNext? It is possible to now check for the error in r.ResultPageIterator.err and bubble that up, but I'm afraid any divergence between Next's logic and HasNext's logic in the future can lead to similar problems

Copy link
Contributor

@mdibaiee mdibaiee Mar 14, 2025

Choose a reason for hiding this comment

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

I think it is worth considering whether HasNext can be simply rewritten as: r.ResultPageIterator.Next() == (nil, io.EOF), and if so, it is not really useful to keep it, any consumer of ResultPageIterator can use Next for the purpose of checking whether there are any items left or not

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@jackyhu-db, we would also need to update the function signature to return (bool, error) and also make changes to https://github.com/databricks/databricks-sql-go/blob/main/internal/rows/arrowbased/arrowRecordIterator.go#L86 to also return the error, do we want to go down that route?

@jackyhu-db jackyhu-db self-requested a review March 13, 2025 22:16
@jackyhu-db jackyhu-db merged commit 2a39cfa into databricks:main Mar 18, 2025
2 of 3 checks passed
@vikrantpuppala vikrantpuppala mentioned this pull request Mar 18, 2025
jackyhu-db pushed a commit that referenced this pull request Mar 18, 2025
Prepare for the next release of go driver (1.6.2) which adds the
following changes:

- Support positional query parameters (#247)
- Add custom auth headers into cloud fetch request
(#249)
- Security: GO-2024-2947 - Update go-retryablehttp
(#251)
- Security: CVE-2025-27144 - Resolve vulnerability in go-jose
(#258)
- Bugfix: Handle incorrect EOF in fetchResultPage when TFetchResults
call fails with an error (#255)

Signed-off-by: Vikrant Puppala <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants