Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion snowflake-api/examples/tracing/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ async fn run_in_span(api: &snowflake_api::SnowflakeApi) -> anyhow::Result<()> {

match res {
QueryResult::Arrow(a) => {
println!("{}", pretty_format_batches(&a).unwrap());
println!("{}", pretty_format_batches(&a[..]).unwrap());
}
QueryResult::Json(j) => {
println!("{}", j);
Expand Down
8 changes: 4 additions & 4 deletions snowflake-api/src/responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ pub enum ExecResponse {
Error(ExecErrorResponse),
}

// todo: add close session response, which should be just empty?
#[allow(clippy::large_enum_variant)]
#[derive(Deserialize, Debug)]
#[serde(untagged)]
Expand All @@ -21,6 +20,8 @@ pub enum AuthResponse {
Renew(RenewSessionResponse),
Close(CloseSessionResponse),
Error(AuthErrorResponse),
ExecError(ExecErrorResponse),
Other(serde_json::Value),
}

#[derive(Deserialize, Debug)]
Expand Down Expand Up @@ -53,9 +54,8 @@ pub struct ExecErrorResponseData {
pub line: Option<i64>,
pub pos: Option<i64>,

// fixme: only valid for exec query response error? present in any exec query response?
pub query_id: String,
pub sql_state: String,
pub query_id: Option<String>,
pub sql_state: Option<String>,
}

#[derive(Deserialize, Debug)]
Expand Down
23 changes: 19 additions & 4 deletions snowflake-api/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub enum AuthError {
MissingCertificate,

#[error("Unexpected API response")]
UnexpectedResponse,
UnexpectedResponse(Option<serde_json::Value>),

// todo: add code mapping to meaningful message and/or refer to docs
// eg https://docs.snowflake.com/en/user-guide/key-pair-auth-troubleshooting
Expand Down Expand Up @@ -269,7 +269,12 @@ impl Session {
e.code.unwrap_or_default(),
e.message.unwrap_or_default(),
)),
_ => Err(AuthError::UnexpectedResponse),
AuthResponse::ExecError(e) => Err(AuthError::AuthFailed(
e.code.unwrap_or_default(),
e.message.unwrap_or_default(),
)),
AuthResponse::Other(value) => Err(AuthError::UnexpectedResponse(Some(value))),
_ => Err(AuthError::UnexpectedResponse(None)),
}
} else {
Ok(())
Expand Down Expand Up @@ -356,7 +361,12 @@ impl Session {
e.code.unwrap_or_default(),
e.message.unwrap_or_default(),
)),
_ => Err(AuthError::UnexpectedResponse),
AuthResponse::ExecError(e) => Err(AuthError::AuthFailed(
e.code.unwrap_or_default(),
e.message.unwrap_or_default(),
)),
AuthResponse::Other(value) => Err(AuthError::UnexpectedResponse(Some(value))),
_ => Err(AuthError::UnexpectedResponse(None)),
}
}

Expand Down Expand Up @@ -416,7 +426,12 @@ impl Session {
e.code.unwrap_or_default(),
e.message.unwrap_or_default(),
)),
_ => Err(AuthError::UnexpectedResponse),
AuthResponse::ExecError(e) => Err(AuthError::AuthFailed(
e.code.unwrap_or_default(),
e.message.unwrap_or_default(),
)),
AuthResponse::Other(value) => Err(AuthError::UnexpectedResponse(Some(value))),
_ => Err(AuthError::UnexpectedResponse(None)),
}
}
}