Class QueryStatus
- java.lang.Object
-
- net.snowflake.client.api.resultset.QueryStatus
-
public final class QueryStatus extends Object
Represents detailed status information for a query execution.This class provides comprehensive metadata about a query's execution, including timing information, warehouse details, and error information if applicable. Use this class to monitor query progress and diagnose execution issues.
Usage Example
String queryId = statement.unwrap(SnowflakeStatement.class).getQueryID(); QueryStatus status = connection.unwrap(SnowflakeConnection.class) .getQueryStatus(queryId); System.out.println("Query Status: " + status.getStatus()); System.out.println("Duration: " + status.getTotalDuration() + "ms"); if (status.getErrorCode() != 0) { System.err.println("Error: " + status.getErrorMessage()); }
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classQueryStatus.Status
-
Constructor Summary
Constructors Constructor Description QueryStatus(long endTime, int errorCode, String errorMessage, String id, String name, long sessionId, String sqlText, long startTime, String state, int totalDuration, String warehouseExternalSize, int warehouseId, String warehouseName, String warehouseServerType)Constructs a QueryStatus object with detailed query execution information.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static QueryStatusempty()Creates an empty QueryStatus instance with default values.StringgetDescription()Gets the status description.longgetEndTime()Gets the end time of query execution.intgetErrorCode()Gets the error code if the query failed.StringgetErrorMessage()Gets the error message if the query failed.StringgetId()Gets the unique query ID.StringgetName()Gets the query status name.longgetSessionId()Gets the session ID that executed the query.StringgetSqlText()Gets the SQL text of the query.longgetStartTime()Gets the start time of query execution.StringgetState()Gets the internal state of the query.QueryStatus.StatusgetStatus()Gets the query status enum value.intgetTotalDuration()Gets the total duration of query execution.StringgetWarehouseExternalSize()Gets the external size of the warehouse that executed the query.intgetWarehouseId()Gets the warehouse ID that executed the query.StringgetWarehouseName()Gets the warehouse name that executed the query.StringgetWarehouseServerType()Gets the warehouse server type that executed the query.booleanisAnError()Checks if the query encountered an error.booleanisEmpty()Checks if this query status is empty (no data).booleanisStillRunning()Checks if the query is still running.booleanisSuccess()Checks if the query completed successfully.
-
-
-
Constructor Detail
-
QueryStatus
public QueryStatus(long endTime, int errorCode, String errorMessage, String id, String name, long sessionId, String sqlText, long startTime, String state, int totalDuration, String warehouseExternalSize, int warehouseId, String warehouseName, String warehouseServerType)Constructs a QueryStatus object with detailed query execution information.- Parameters:
endTime- the end time of the query in milliseconds since epocherrorCode- the error code if query failed, 0 otherwiseerrorMessage- the error message if query failed, empty otherwiseid- the unique query IDname- the query status namesessionId- the session ID that executed the querysqlText- the SQL text of the querystartTime- the start time of the query in milliseconds since epochstate- the internal state of the querytotalDuration- the total duration of query execution in millisecondswarehouseExternalSize- the external size of the warehouse (e.g., "X-Small")warehouseId- the warehouse IDwarehouseName- the warehouse namewarehouseServerType- the warehouse server type
-
-
Method Detail
-
empty
public static QueryStatus empty()
Creates an empty QueryStatus instance with default values.- Returns:
- an empty QueryStatus object
-
isEmpty
public boolean isEmpty()
Checks if this query status is empty (no data).- Returns:
- true if the status name is empty
-
isStillRunning
public boolean isStillRunning()
Checks if the query is still running.- Returns:
- true if the query is in a running state
-
isSuccess
public boolean isSuccess()
Checks if the query completed successfully.- Returns:
- true if the query status is SUCCESS
-
isAnError
public boolean isAnError()
Checks if the query encountered an error.- Returns:
- true if the query is in an error state
-
getEndTime
public long getEndTime()
Gets the end time of query execution.- Returns:
- the end time in milliseconds since epoch
-
getErrorCode
public int getErrorCode()
Gets the error code if the query failed.- Returns:
- the error code, or 0 if no error occurred
-
getErrorMessage
public String getErrorMessage()
Gets the error message if the query failed.- Returns:
- the error message, or empty string if no error occurred
-
getId
public String getId()
Gets the unique query ID.- Returns:
- the query ID
-
getName
public String getName()
Gets the query status name.- Returns:
- the status name (e.g., "RUNNING", "SUCCESS")
-
getSessionId
public long getSessionId()
Gets the session ID that executed the query.- Returns:
- the session ID
-
getSqlText
public String getSqlText()
Gets the SQL text of the query.- Returns:
- the SQL query text
-
getStartTime
public long getStartTime()
Gets the start time of query execution.- Returns:
- the start time in milliseconds since epoch
-
getState
public String getState()
Gets the internal state of the query.- Returns:
- the internal query state
-
getTotalDuration
public int getTotalDuration()
Gets the total duration of query execution.- Returns:
- the total duration in milliseconds
-
getWarehouseExternalSize
public String getWarehouseExternalSize()
Gets the external size of the warehouse that executed the query.- Returns:
- the warehouse size (e.g., "X-Small", "Small", "Medium")
-
getWarehouseId
public int getWarehouseId()
Gets the warehouse ID that executed the query.- Returns:
- the warehouse ID
-
getWarehouseName
public String getWarehouseName()
Gets the warehouse name that executed the query.- Returns:
- the warehouse name
-
getWarehouseServerType
public String getWarehouseServerType()
Gets the warehouse server type that executed the query.- Returns:
- the warehouse server type
-
getDescription
public String getDescription()
Gets the status description.- Returns:
- the status name
-
getStatus
public QueryStatus.Status getStatus()
Gets the query status enum value.- Returns:
- the Status enum representing the current state
-
-