andrusha / snowflake-rs

Snowflake API libraries for Rust
Apache License 2.0
31 stars 26 forks source link

Add support for async query response #42

Open sgrebnov opened 7 months ago

sgrebnov commented 7 months ago

Queries longer than 45s returns response as they were executed with exec_async=true parameter and needs additional logic to get result once it is available. PR adds async ExecResponse::QueryAsync response type and get_async_exec_result method to handle this case. Implementation is similar to Go (reference)

If async parameter is not specified or is set to false, a statement is executed and the results are returned if the execution is completed in 45 seconds. If the statement execution takes longer to complete, the statement handle is returned.https://docs.snowflake.com/en/developer-guide/sql-api/reference#query-parameters

Example response

{
  "data" : {
  "queryId" : "01b41e53-0002-66e9-005e-e38700025036",
  "getResultUrl" : "/queries/01b41e53-0002-66e9-005e-e38700025036/result",
  "queryAbortsAfterSecs" : 300,
  "progressDesc" : null
},
  "code" : "333334",
  "message" : "Asynchronous execution in progress. Use provided query id to perform query monitoring and management.",
  "success" : true
}