Skip to content

Commit

Permalink
If FuncGet() returns no code dont convert to str (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
madisonchamberlain authored and rajsigma committed Sep 8, 2023
1 parent 9befc5a commit f36ec3d
Showing 1 changed file with 40 additions and 34 deletions.
74 changes: 40 additions & 34 deletions monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,40 +328,46 @@ func (sc *snowflakeConn) rowsForRunningQuery(

// Wait for query to complete from a query id from /queries/<qid>/result endpoint.
func (sc *snowflakeConn) blockOnRunningQuery(
ctx context.Context, qid string) error {
resultPath := fmt.Sprintf(urlQueriesResultFmt, qid)
resp, err := sc.waitForCompletedQueryResultResp(ctx, resultPath)
if err != nil {
logger.WithContext(ctx).Errorf("error: %v", err)
if resp != nil {
code, err := strconv.Atoi(resp.Code)
if err != nil {
return err
}
return (&SnowflakeError{
Number: code,
SQLState: resp.Data.SQLState,
Message: err.Error(),
QueryID: resp.Data.QueryID,
}).exceptionTelemetry(sc)
}
return err
}
if !resp.Success {
message := resp.Message
code, err := strconv.Atoi(resp.Code)
if err != nil {
code = ErrQueryStatus
message = fmt.Sprintf("%s: (failed to parse original code: %s: %s)", message, resp.Code, err.Error())
}
return (&SnowflakeError{
Number: code,
SQLState: resp.Data.SQLState,
Message: message,
QueryID: resp.Data.QueryID,
}).exceptionTelemetry(sc)
}
return nil
ctx context.Context, qid string) error {
resultPath := fmt.Sprintf(urlQueriesResultFmt, qid)
resp, err := sc.waitForCompletedQueryResultResp(ctx, resultPath)
if err != nil {
logger.WithContext(ctx).Errorf("error: %v", err)
if resp != nil {
code := -1
if resp.Code != "" {
code, err = strconv.Atoi(resp.Code)
if err != nil {
return err
}
}
return (&SnowflakeError{
Number: code,
SQLState: resp.Data.SQLState,
Message: err.Error(),
QueryID: resp.Data.QueryID,
}).exceptionTelemetry(sc)
}
return err
}
if !resp.Success {
message := resp.Message
code := -1
if resp.Code != "" {
code, err = strconv.Atoi(resp.Code)
if err != nil {
code = ErrQueryStatus
message = fmt.Sprintf("%s: (failed to parse original code: %s: %s)", message, resp.Code, err.Error())
}
}
return (&SnowflakeError{
Number: code,
SQLState: resp.Data.SQLState,
Message: message,
QueryID: resp.Data.QueryID,
}).exceptionTelemetry(sc)
}
return nil
}

// prepare a Rows object to return for query of 'qid'
Expand Down

0 comments on commit f36ec3d

Please sign in to comment.