Expand description
The async statement driver: pump the pure StatementMachine against the
live franken-snowflake-http transport, cancel-correctly.
This is the thin async glue over the pure lifecycle logic. All decisions
(status routing, the poll loop, partition assembly) live in
crate::lifecycle; this module only performs the network steps the machine
asks for and, crucially, fires the SQL API cancel endpoint when the
ambient Cx is cancelled after a statement handle exists — so no Snowflake
statement is orphaned (the obligation/bracket contract from
docs/asupersync_leverage.md).
The cancel path delegates to the transport’s own
cancel_after_local_cancel, which masks local cancellation for the bounded
cleanup request and single-sources the cancel-policy table. Either way the
local outcome is Cancelled.
Structs§
- Driver
Stats - Observed effort for one driven statement, for
budget_consumedreporting. - Multi
Statement Result - The results of a multi-statement request (reality-check bead L1).
- Statement
Hooks - Optional per-run hooks: a streaming row sink and a progress observer.
Enums§
- Driver
Event - What happened during a statement run, for progress reporting (reality-check bead E5). Carries no SQL text and no credential.
Traits§
- Auth
Provider - Supplies the bearer for each SQL API request and decides what to do when the
API answers
401. - Driver
Observer - Receives
DriverEvents while a statement runs. - RowSink
- Receives a statement’s rows in partition order while it streams (reality-check bead E5).
- Statement
Transport - The transport operations the driver needs.
SnowflakeHttpClientis the production implementation; tests inject a scripted fake so the driver’s error and cancellation paths are provable without a socket or an account.
Functions§
- run_
multi_ statement_ hooked - Run a request whose
MULTI_STATEMENT_COUNTis above one (reality-check bead L1): the parent statement, then each statement fetched by the handle the parent lists (GET /api/v2/statements/{handle}), in statement order. Each statement assembles like a single one (polls, partitions, the plan’s row cap). A failing statement fails the request with422before any result is fetched. The observer sees every step. - run_
statement - Submit a statement and drive it to completion: submit -> poll/await ->
partition fetch -> assemble, firing the remote cancel endpoint if the ambient
Cxis cancelled mid-flight. - run_
statement_ hooked run_statement_with_authwith optionalStatementHooks.- run_
statement_ streaming run_statement_with_auth, handing rows tosinkas each fetch window completes instead of assembling them, so peak memory is one window of partitions. The returnedCompletedStatementkeeps the metadata; itsrowsare empty because every row went to the sink.- run_
statement_ with_ auth run_statement_with_statswith a refreshingAuthProvider: the bearer is re-derived before every request and a401triggers one re-sign + retry of the same step when the provider can refresh.- run_
statement_ with_ stats run_statementplus the poll/partition counts it consumed.
Type Aliases§
- Statement
Outcome - The driver outcome: a fully-assembled
CompletedStatementor one of the fourSnowflakeOutcometerminal states.