Package net.snowflake.client.core
Class StmtUtil
- java.lang.Object
-
- net.snowflake.client.core.StmtUtil
-
public class StmtUtil extends Object
Statement Util
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
StmtUtil.StmtOutput
Output for running a statement on server
-
Constructor Summary
Constructors Constructor Description StmtUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static void
cancel(net.snowflake.client.core.StmtUtil.StmtInput stmtInput)
Deprecated.usecancel(StmtInput, CancellationReason)
insteadstatic void
cancel(net.snowflake.client.core.StmtUtil.StmtInput stmtInput, CancellationReason cancellationReason)
Cancel a statement identifiable by a request idstatic SFStatementType
checkStageManageCommand(String sql)
A simple function to check if the statement is related to manipulate stage.static StmtUtil.StmtOutput
execute(net.snowflake.client.core.StmtUtil.StmtInput stmtInput, ExecTimeTelemetryData execTimeData)
Execute a statementprotected static String
getQueryResult(com.fasterxml.jackson.databind.JsonNode inProgressResponse, String previousGetResultPath, net.snowflake.client.core.StmtUtil.StmtInput stmtInput)
Issue get-result call to get query result given an in-progress response.protected static String
getQueryResult(String getResultPath, net.snowflake.client.core.StmtUtil.StmtInput stmtInput)
Issue get-result call to get query result given an in-progress response.protected static com.fasterxml.jackson.databind.JsonNode
getQueryResultJSON(String queryId, SFSession session)
Issue get-result call to get query result given an in progress response.static String
truncateSQL(String sql)
Truncate a SQL text for logging
-
-
-
Method Detail
-
execute
public static StmtUtil.StmtOutput execute(net.snowflake.client.core.StmtUtil.StmtInput stmtInput, ExecTimeTelemetryData execTimeData) throws SFException, SnowflakeSQLException
Execute a statementside effect: stmtInput.prevGetResultURL is set if we have started ping pong and receives an exception from session token expiration so that during retry we don't retry the query submission, but continue the ping pong process.
- Parameters:
stmtInput
- input statement- Returns:
- StmtOutput output statement
- Throws:
SFException
- exception raised from Snowflake componentsSnowflakeSQLException
- exception raised from Snowflake components
-
getQueryResult
protected static String getQueryResult(com.fasterxml.jackson.databind.JsonNode inProgressResponse, String previousGetResultPath, net.snowflake.client.core.StmtUtil.StmtInput stmtInput) throws SFException, SnowflakeSQLException
Issue get-result call to get query result given an in-progress response.- Parameters:
inProgressResponse
- In progress response in JSON formpreviousGetResultPath
- previous get results pathstmtInput
- input statement- Returns:
- results in string form
- Throws:
SFException
- exception raised from Snowflake componentsSnowflakeSQLException
- exception raised from Snowflake components
-
getQueryResult
protected static String getQueryResult(String getResultPath, net.snowflake.client.core.StmtUtil.StmtInput stmtInput) throws SFException, SnowflakeSQLException
Issue get-result call to get query result given an in-progress response.- Parameters:
getResultPath
- path to resultsstmtInput
- object with context information- Returns:
- results in string form
- Throws:
SFException
- exception raised from Snowflake componentsSnowflakeSQLException
- exception raised from Snowflake components
-
getQueryResultJSON
protected static com.fasterxml.jackson.databind.JsonNode getQueryResultJSON(String queryId, SFSession session) throws SFException, SnowflakeSQLException
Issue get-result call to get query result given an in progress response.- Parameters:
queryId
- id of query to get results forsession
- the current session- Returns:
- results in JSON
- Throws:
SFException
- exception raised from Snowflake componentsSnowflakeSQLException
- exception raised from Snowflake components
-
cancel
@Deprecated public static void cancel(net.snowflake.client.core.StmtUtil.StmtInput stmtInput) throws SFException, SnowflakeSQLException
Deprecated.usecancel(StmtInput, CancellationReason)
insteadCancel a statement identifiable by a request id- Parameters:
stmtInput
- input statement- Throws:
SFException
- if there is an internal exceptionSnowflakeSQLException
- if failed to cancel the statement
-
cancel
public static void cancel(net.snowflake.client.core.StmtUtil.StmtInput stmtInput, CancellationReason cancellationReason) throws SFException, SnowflakeSQLException
Cancel a statement identifiable by a request id- Parameters:
stmtInput
- input statementcancellationReason
- reason for the cancellation- Throws:
SFException
- if there is an internal exceptionSnowflakeSQLException
- if failed to cancel the statement
-
checkStageManageCommand
public static SFStatementType checkStageManageCommand(String sql)
A simple function to check if the statement is related to manipulate stage.- Parameters:
sql
- a SQL statement/command- Returns:
- PUT/GET/LIST/RM if statement belongs to one of them, otherwise return NULL
-
-