Repository navigation
Propagate error in TFetchResults - #255
Conversation
c7eefc1 to
3225fc0
Compare
Signed-off-by: Vikrant Puppala <[email protected]>
3225fc0 to
ef393cd
Compare
| r.RowScanner = nil | ||
| } | ||
|
|
||
| if !r.ResultPageIterator.HasNext() { |
There was a problem hiding this comment.
can you check the r.error and return r.error instead?
There was a problem hiding this comment.
@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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
@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?
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]>
….6.1 to 1.8.0 (#351) Bumps [github.com/databricks/databricks-sql-go](https://github.com/databricks/databricks-sql-go) from 1.6.1 to 1.8.0. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/databricks/databricks-sql-go/releases">github.com/databricks/databricks-sql-go's releases</a>.</em></p> <blockquote> <h2>v1.8.0</h2> <h2>What's Changed</h2> <ul> <li>Ensure thrift field IDs stay within range by <a href="https://github.com/vikrantpuppala"><code>@vikrantpuppala</code></a> in <a href="https://redirect.github.com/databricks/databricks-sql-go/pull/276">databricks/databricks-sql-go#276</a></li> <li>Add Arrow IPC stream iterator for direct access to Arrow buffer by <a href="https://github.com/jadewang-db"><code>@jadewang-db</code></a> in <a href="https://redirect.github.com/databricks/databricks-sql-go/pull/279">databricks/databricks-sql-go#279</a></li> <li>Prepare for v1.8.0 release by <a href="https://github.com/jadewang-db"><code>@jadewang-db</code></a> in <a href="https://redirect.github.com/databricks/databricks-sql-go/pull/280">databricks/databricks-sql-go#280</a></li> </ul> <h2>New Contributors</h2> <ul> <li><a href="https://github.com/jadewang-db"><code>@jadewang-db</code></a> made their first contribution in <a href="https://redirect.github.com/databricks/databricks-sql-go/pull/279">databricks/databricks-sql-go#279</a></li> </ul> <p><strong>Full Changelog</strong>: <a href="https://github.com/databricks/databricks-sql-go/compare/v1.7.1...v1.8.0">https://github.com/databricks/databricks-sql-go/compare/v1.7.1...v1.8.0</a></p> <h2>v1.7.1</h2> <h2>What's Changed</h2> <ul> <li>Fix critical CVE-2024-45337 by <a href="https://github.com/vikrantpuppala"><code>@vikrantpuppala</code></a> in <a href="https://redirect.github.com/databricks/databricks-sql-go/pull/264">databricks/databricks-sql-go#264</a></li> <li>Add nil handling for isStagingOperation to handle older DBR versions by <a href="https://github.com/vikrantpuppala"><code>@vikrantpuppala</code></a> in <a href="https://redirect.github.com/databricks/databricks-sql-go/pull/266">databricks/databricks-sql-go#266</a></li> <li>[PECOBLR-402] Update thrift client library after cleaning up unused fields and structs by <a href="https://github.com/gopalldb"><code>@gopalldb</code></a> in <a href="https://redirect.github.com/databricks/databricks-sql-go/pull/268">databricks/databricks-sql-go#268</a></li> <li>Add schema to ArrowBatchIterator by <a href="https://github.com/vikrantpuppala"><code>@vikrantpuppala</code></a> in <a href="https://redirect.github.com/databricks/databricks-sql-go/pull/267">databricks/databricks-sql-go#267</a></li> </ul> <h2>New Contributors</h2> <ul> <li><a href="https://github.com/gopalldb"><code>@gopalldb</code></a> made their first contribution in <a href="https://redirect.github.com/databricks/databricks-sql-go/pull/268">databricks/databricks-sql-go#268</a></li> </ul> <p><strong>Full Changelog</strong>: <a href="https://github.com/databricks/databricks-sql-go/compare/v1.7.0...v1.7.1">https://github.com/databricks/databricks-sql-go/compare/v1.7.0...v1.7.1</a></p> <h2>v1.7.0</h2> <h2>What's Changed</h2> <ul> <li>Enable cloud fetch mode by default (<a href="https://redirect.github.com/databricks/databricks-sql-go/pull/260">databricks/databricks-sql-go#260</a> by <a href="https://github.com/shivam2680"><code>@shivam2680</code></a>)</li> <li>Handle thrift protocol version for conditional feature support (cloud fetch, LZ4 compression, Arrow support) (<a href="https://redirect.github.com/databricks/databricks-sql-go/pull/261">databricks/databricks-sql-go#261</a> by <a href="https://github.com/shivam2680"><code>@shivam2680</code></a>)</li> </ul> <h2>New Contributors</h2> <ul> <li><a href="https://github.com/shivam2680"><code>@shivam2680</code></a> made their first contribution in <a href="https://redirect.github.com/databricks/databricks-sql-go/pull/260">databricks/databricks-sql-go#260</a></li> </ul> <p><strong>Full Changelog</strong>: <a href="https://github.com/databricks/databricks-sql-go/compare/v1.6.2...v1.7.0">https://github.com/databricks/databricks-sql-go/compare/v1.6.2...v1.7.0</a></p> <h2>v1.6.2</h2> <h2>What's Changed</h2> <ul> <li>Support positional query parameters by <a href="https://github.com/kravets-levko"><code>@kravets-levko</code></a> in <a href="https://redirect.github.com/databricks/databricks-sql-go/pull/247">databricks/databricks-sql-go#247</a></li> <li>fix: Add custom auth headers into cloud fetch request by <a href="https://github.com/jackyhu-db"><code>@jackyhu-db</code></a> in <a href="https://redirect.github.com/databricks/databricks-sql-go/pull/249">databricks/databricks-sql-go#249</a></li> <li>fix: Propagate error in TFetchResults by <a href="https://github.com/vikrantpuppala"><code>@vikrantpuppala</code></a> in <a href="https://redirect.github.com/databricks/databricks-sql-go/pull/255">databricks/databricks-sql-go#255</a></li> <li>fix(security): GO-2024-2947, update to github.com/hashicorp/[email protected] (<a href="https://redirect.github.com/databricks/databricks-sql-go/issues/251">#251</a>) by <a href="https://github.com/prochac"><code>@prochac</code></a> in <a href="https://redirect.github.com/databricks/databricks-sql-go/pull/252">databricks/databricks-sql-go#252</a></li> <li>fix(security): update dependencies to fix CVE by <a href="https://github.com/vikrantpuppala"><code>@vikrantpuppala</code></a> in <a href="https://redirect.github.com/databricks/databricks-sql-go/pull/258">databricks/databricks-sql-go#258</a></li> </ul> <h2>New Contributors</h2> <ul> <li><a href="https://github.com/prochac"><code>@prochac</code></a> made their first contribution in <a href="https://redirect.github.com/databricks/databricks-sql-go/pull/252">databricks/databricks-sql-go#252</a></li> <li><a href="https://github.com/vikrantpuppala"><code>@vikrantpuppala</code></a> made their first contribution in <a href="https://redirect.github.com/databricks/databricks-sql-go/pull/258">databricks/databricks-sql-go#258</a></li> </ul> <p><strong>Full Changelog</strong>: <a href="https://github.com/databricks/databricks-sql-go/compare/v1.6.1...v1.6.2">https://github.com/databricks/databricks-sql-go/compare/v1.6.1...v1.6.2</a></p> </blockquote> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/databricks/databricks-sql-go/blob/main/CHANGELOG.md">github.com/databricks/databricks-sql-go's changelog</a>.</em></p> <blockquote> <h2>v1.8.0 (2025-07-24)</h2> <ul> <li>Add Arrow IPC Iterator</li> </ul> <h2>v1.7.1 (2025-05-20)</h2> <ul> <li><code>databricks/databricks-sql-go#267</code></li> <li><code>databricks/databricks-sql-go#268</code></li> <li><code>databricks/databricks-sql-go#266</code></li> <li><code>databricks/databricks-sql-go#264</code></li> </ul> <h2>v1.7.0 (2025-04-09)</h2> <ul> <li><code>databricks/databricks-sql-go#260</code></li> <li><code>databricks/databricks-sql-go#261</code></li> </ul> <h2>v1.6.2 (2025-03-18)</h2> <ul> <li><code>databricks/databricks-sql-go#247</code></li> <li><code>databricks/databricks-sql-go#249</code></li> <li><code>databricks/databricks-sql-go#251</code></li> <li><code>databricks/databricks-sql-go#258</code></li> <li><code>databricks/databricks-sql-go#255</code></li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/databricks/databricks-sql-go/commit/529d69c5ce36b0eeaad9ec573cfd77a7342cc5ff"><code>529d69c</code></a> Prepare for v1.8.0 release (<a href="https://redirect.github.com/databricks/databricks-sql-go/issues/280">#280</a>)</li> <li><a href="https://github.com/databricks/databricks-sql-go/commit/7bde0dc3d1a27a22354d50129a59e477af17add2"><code>7bde0dc</code></a> Add Arrow IPC stream iterator for direct access to Arrow buffer (<a href="https://redirect.github.com/databricks/databricks-sql-go/issues/279">#279</a>)</li> <li><a href="https://github.com/databricks/databricks-sql-go/commit/746c05de3ec5c8f06603879998a5fb703a35d473"><code>746c05d</code></a> Ensure thrift field IDs stay within range (<a href="https://redirect.github.com/databricks/databricks-sql-go/issues/276">#276</a>)</li> <li><a href="https://github.com/databricks/databricks-sql-go/commit/039c53ab5e21dbbfae5d29aa4595d36ea7a3465e"><code>039c53a</code></a> Add test to ensure thrift field IDs stay within range</li> <li><a href="https://github.com/databricks/databricks-sql-go/commit/12d2ceda465a8296b2d2080550c91581c71b3605"><code>12d2ced</code></a> Prepare for v1.7.1 (<a href="https://redirect.github.com/databricks/databricks-sql-go/issues/271">#271</a>)</li> <li><a href="https://github.com/databricks/databricks-sql-go/commit/01cd3d122125a0ec02aa035e62823fc6ef408911"><code>01cd3d1</code></a> Update CODEOWNERS (<a href="https://redirect.github.com/databricks/databricks-sql-go/issues/272">#272</a>)</li> <li><a href="https://github.com/databricks/databricks-sql-go/commit/2361714c73a38a23aed7334bf8240238803b608d"><code>2361714</code></a> Update CODEOWNERS</li> <li><a href="https://github.com/databricks/databricks-sql-go/commit/149e1ad615c847e33895c5d7299e6031cd593ad6"><code>149e1ad</code></a> Prepare for v1.7.1</li> <li><a href="https://github.com/databricks/databricks-sql-go/commit/c29199287a059c1056d1179402088acdd30706e1"><code>c291992</code></a> Add schema to ArrowBatchIterator (<a href="https://redirect.github.com/databricks/databricks-sql-go/issues/267">#267</a>)</li> <li><a href="https://github.com/databricks/databricks-sql-go/commit/7263c534751313073578e0adc3f0e34e15f75bad"><code>7263c53</code></a> [PECOBLR-402] Update thrift client library after cleaning up unused fields an...</li> <li>Additional commits viewable in <a href="https://github.com/databricks/databricks-sql-go/compare/v1.6.1...v1.8.0">compare view</a></li> </ul> </details> <br /> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) You can trigger a rebase of this PR by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> > **Note** > Automatic rebases have been disabled on this pull request as it has been open for over 30 days. Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…s#507) (databricks#509) ## Summary Automated fix for [databricks#507](databricks#507) — ArrowBatchIterator turns a failed FetchResults into io.EOF. Added an Err() accessor to the ResultPageIterator interface (and stopped HasNext from masking a stored fetch error with io.EOF) so arrowRecordIterator can distinguish a failed page fetch from a finished result set; the arrow iterator now keeps HasNext()==true while a page-fetch error is pending and returns that error from Next() instead of io.EOF (mirrors the database/sql fix databricks#255). Offline-only per the carve-out: this is a client-side error-propagation contract (analogue of databricks#254/databricks#255), anchored in the issue's stated expectation, and not observable end-to-end since it requires forcing a mid-stream FetchResults failure against the live server. ## Root cause & plan **Root cause:** arrowRecordIterator swallows a failed inter-page FetchResults as io.EOF. When FetchResults fails between pages, resultPageIterator.HasNext() stores the error (rpf.err), closes, sets isFinished, and returns false. arrowRecordIterator.checkFinished() ANDs !resultPageIterator.HasNext() into its `finished` decision with NO error check, so it treats the failure as end-of-results and calls Close(). arrowRecordIterator.HasNext() then returns false, so a `for it.HasNext()` caller loop exits without ever calling Next() and never sees the error (lastErr stays nil); the failed page looks like a complete result set. Compounding it, a later resultPageIterator.HasNext() call overwrites the stored error with io.EOF via `if rpf.isFinished && rpf.nextResultPage == nil { rpf.err = io.EOF }`. This is the Arrow-batch analogue of databricks#254; the database/sql path was fixed in databricks#255 by having rows.Next return the fetch error, but the arrow path decides termination via HasNext() and collapses error and done into one isFinished flag. **Files:** `internal/rows/rowscanner/resultPageIterator.go`, `internal/rows/arrowbased/arrowRecordIterator.go`, `internal/rows/arrowbased/arrowRecordIterator_test.go` **Planned coverage:** - TestArrowRecordIteratorSwallowsPageError (in internal/rows/arrowbased/arrowRecordIterator_test.go, next to TestArrowRecordIterator): using the directResultsMultipleFetch fixtures, direct results are page 1, the mock returns FetchResults1 on the first fetch, then fails the second fetch with 'FetchResults: connection reset'. Drive the iterator with `for it.HasNext() { rec, err := it.Next(); if err != nil { lastErr = err; break } ... }`. Assert lastErr ErrorContains 'connection reset'. Today the loop ends with lastErr == nil (bug); after the fix Next() returns the page-fetch error instead of io.EOF. _(ArrowBatchIterator (arrowRecordIterator) turns a failed inter-page FetchResults into io.EOF instead of surfacing the fetch error)_ ## Files changed - `internal/rows/arrowbased/arrowRecordIterator_test.go` - `internal/rows/rowscanner/resultPageIterator.go` - `internal/rows/arrowbased/arrowRecordIterator.go` ## Test plan - [x] `TestArrowRecordIteratorSwallowsPageError` — fails (red) against the original code, passes (green) after the fix 🤖 Generated by engineer-bot (bug-fix flow) — review before merge.
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