snowflake-jdbc
snowflake-jdbc copied to clipboard
SNOW-159714: Not possible to see query errors using async API
The async method Statement.executeAsyncQuery
returns SFAsyncResultSet
which lets us use getStatus()
until the query is finished but in case the query is finished with status FAILED_WITH_ERROR
there is no way to see the underlying error.
SFAsyncResultSet
returns the following exception in this case: (see: https://github.com/snowflakedb/snowflake-jdbc/blob/e64d5d4a045ee43d46bef9b25aeec68fcbac4277/src/main/java/net/snowflake/client/jdbc/SFAsyncResultSet.java#L162)
Status of query associated with resultSet is FAILED_WITH_ERROR. Results not generated.
Is there any update on this? Not sure if the maintainers are looking into the Github Issues. 🤔
@buremba We are looking into this.
It's been a year and I see this issue today with my job. Has this been fixed and release in a new version? or is it closed?
I don't think it's fixed. Looks like it's not prioritized and probably dead in their backlog. :(
@sfc-gh-hkapre @sfc-gh-mknister this still makes it incredibly difficult to debug entire classes of errors using the Snowflake JDBC lib. I don't think it just affects Async queries either. Any chance we can get the details from this added to the exception thrown? https://docs.snowflake.com/en/user-guide/jdbc-api.html#id13
Glad to see this bug has work in progress. I'm facing the same issue in one of my workflows.
@buremba @odykstra @sixdimensionalarray We are now adding the error message to be displayed in the SQLException message body. There is already a way to see the query's underlying error message and code by calling QueryStatus.getErrorMessage() and QueryStatus.getErrorCode() as seen in the 2 examples of asynchronous querying documentation here: https://docs.snowflake.com/en/developer-guide/jdbc/jdbc-using#examples-of-asynchronous-queries. Another example would be:
try {
ResultSet rs = statement.unwrap(SnowflakeStatement.class).executeAsyncQuery("select * from nonexistentTable");
rs.next();
} catch (SQLException ex) {
// Print query error message
System.out.println(rs.unwrap(SnowflakeResultSet.class).getStatus().getErrorMessage());
// Print query error code
System.out.println(rs.unwrap(SnowflakeResultSet.class).getStatus().getErrorCode());
}
The getErrorMessage()
function is inside the QueryStatus class. Is this an ask to make the error message fetchable from the SnowflakeResultSet class as well, like adding a similar SnowflakeResultSet.getQueryErrorMessage
?
Added function SnowflakeResultSet.getQueryErrorMessage() in case customers want to access error message from ResultSet class. PR: https://github.com/snowflakedb/snowflake-jdbc/pull/1328