Repository navigation
Handle async query result-polling (getResultUrl ping-pong) - #77
Open
muratdursun wants to merge 1 commit into
Open
muratdursun wants to merge 1 commit into
muratdursun wants to merge 1 commit into
Conversation
When a query doesn't complete within the initial request window (a suspended warehouse resuming, or a slow statement), Snowflake returns an "in progress" envelope carrying only `getResultUrl`/`queryId` and no result rows. The client must GET that URL until the real result arrives. This crate never did, so the untagged `ExecResponse` rejected the response (every variant's required fields were absent) and surfaced as reqwest's opaque "error decoding response body". - Soft-default the result-bearing fields of `QueryExecResponseData` so the in-progress envelope deserializes (detected via `get_result_url`). - `Connection::get_result` GETs a result URL with a fresh request id + the session auth header. - `await_query_result` polls `getResultUrl` (500ms × up to 120 = ~60s ceiling) until a completed result comes back; synchronous results pass straight through. - Decode responses via `serde_json::from_str` so a schema mismatch surfaces serde's precise error instead of reqwest's opaque one. - Regression test for the in-progress envelope. Fixes the Dataglot Snowflake connector failing at catalog build (peakacom OSS-241). (cherry picked from commit ec8d581)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a query doesn't complete within the initial
queries/v1/query-requestwindow — most commonly while a warehouse resumes from auto-suspend, or for any slow statement — Snowflake returns an async "query in progress" envelope whosedatacontains onlygetResultUrl,queryId,progressDesc,queryAbortsAfterSecs(no result rows). The client is expected toGETthatgetResultUrluntil the real result is returned.This crate never followed that ping-pong, so the untagged
ExecResponserejected the in-progress envelope (every variant's required result fields were absent) and it surfaced as reqwest's opaqueerror decoding response body. In practice this makes the very first query against a cold warehouse fail.Reproduced against a live account: the raw 200 response body was
{"data":{"getResultUrl":"/queries/<id>/result","queryId":"<id>","progressDesc":"","queryAbortsAfterSecs":300},"code":"333334","success":true}Fix
getResultUrluntil a completed result comes back (await_query_result): 500ms interval, ~60s ceiling. Synchronous results (nogetResultUrl) pass straight through unchanged.Connection::get_resultperforms the polling GET with a fresh request id + the session auth header, matching the original request's Accept MIME.QueryExecResponseDataso the in-progress envelope deserializes; the caller detects it viaget_result_url.serde_json::from_strso a schema mismatch surfaces serde's precise error instead of reqwest's opaqueerror decoding response body.SnowflakeApiError::QueryInProgressTimeoutand a regression test for the in-progress envelope.Testing
cargo test+cargo clippyclean. Verified end-to-end against a live Snowflake account (PAT auth): queries against a coldCOMPUTE_WHnow succeed via the polling path where they previously failed to decode.