Class StmtUtil


  • public class StmtUtil
    extends Object
    Statement Util
    • 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
        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

        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