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
`static class` `StmtUtil.StmtOutput` Output for running a statement on server

### Constructor Summary

Constructors
`StmtUtil()`

### Method Summary

All Methods Static Methods Concrete Methods Deprecated Methods
`static void` `cancel​(net.snowflake.client.core.StmtUtil.StmtInput stmtInput)` Deprecated. use `cancel(StmtInput, CancellationReason)` instead
`static void` `cancel​(net.snowflake.client.core.StmtUtil.StmtInput stmtInput, CancellationReason cancellationReason)` Cancel a statement identifiable by a request id
`static 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 statement
`protected 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

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### StmtUtil

    public StmtUtil()

### Method Detail

#### execute

    public static StmtUtil.StmtOutput execute​(net.snowflake.client.core.StmtUtil.StmtInput stmtInput,
                                              ExecTimeTelemetryData execTimeData)
                                       throws SFException,
                                              SnowflakeSQLException

Execute a statement

side 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
  `execTimeData` - ExecTimeTelemetryData
Returns:
  StmtOutput output statement
Throws:
  `SFException` - exception raised from Snowflake components
  `SnowflakeSQLException` - 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 form
  `previousGetResultPath` - previous get results path
  `stmtInput` - input statement
Returns:
  results in string form
Throws:
  `SFException` - exception raised from Snowflake components
  `SnowflakeSQLException` - 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 results
  `stmtInput` - object with context information
Returns:
  results in string form
Throws:
  `SFException` - exception raised from Snowflake components
  `SnowflakeSQLException` - 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 for
  `session` - the current session
Returns:
  results in JSON
Throws:
  `SFException` - exception raised from Snowflake components
  `SnowflakeSQLException` - exception raised from Snowflake components

#### cancel

    @Deprecated
    public static void cancel​(net.snowflake.client.core.StmtUtil.StmtInput stmtInput)
                       throws SFException,
                              SnowflakeSQLException

Deprecated.
use `cancel(StmtInput, CancellationReason)` instead
Cancel a statement identifiable by a request id

Parameters:
  `stmtInput` - input statement
Throws:
  `SFException` - if there is an internal exception
  `SnowflakeSQLException` - 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 statement
  `cancellationReason` - reason for the cancellation
Throws:
  `SFException` - if there is an internal exception
  `SnowflakeSQLException` - 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

#### truncateSQL

    public static String truncateSQL​(String sql)

Truncate a SQL text for logging

Parameters:
  `sql` - original SQL
Returns:
  truncated SQL command