class_docstr: A client to interact with Snowflake.
  
  This hook requires the snowflake_conn_id connection. The snowflake account, login,
  and, password field must be setup in the connection. Other inputs can be defined
  in the connection or hook instantiation.
  
  :param snowflake_conn_id: Reference to
      :ref:`Snowflake connection id<howto/connection:snowflake>`
  :param account: snowflake account name
  :param authenticator: authenticator for Snowflake.
      'snowflake' (default) to use the internal Snowflake authenticator
      'externalbrowser' to authenticate using your web browser and
      Okta, ADFS or any other SAML 2.0-compliant identify provider
      (IdP) that has been defined for your account
      ``https://<your_okta_account_name>.okta.com`` to authenticate
      through native Okta.
  :param warehouse: name of snowflake warehouse
  :param database: name of snowflake database
  :param region: name of snowflake region
  :param role: name of snowflake role
  :param schema: name of snowflake schema
  :param session_parameters: You can set session-level parameters at
      the time you connect to Snowflake
  :param insecure_mode: Turns off OCSP certificate checks.
      For details, see: `How To: Turn Off OCSP Checking in Snowflake Client Drivers - Snowflake Community
      <https://community.snowflake.com/s/article/How-to-turn-off-OCSP-checking-in-Snowflake-client-drivers>`__
  
  .. note::
      ``get_sqlalchemy_engine()`` depends on ``snowflake-sqlalchemy``
  
  .. seealso::
      For more information on how to use this Snowflake connection, take a look at the guide:
      :ref:`howto/operator:SnowflakeOperator`
class_docstr_tok: ["A","client","to","interact","with","Snowflake",".","This","hook","requires","the","snowflake_conn_id","connection",".","The","snowflake","account",",","login",",","and",",","password","field","must","be","setup","in","the","connection",".","Other","inputs","can","be","defined","in","the","connection","or","hook","instantiation",".",":","param","snowflake_conn_id",":","Reference","to",":","ref",":","`","Snowflake","connection","id","<","howto\/connection",":","snowflake",">","`",":","param","account",":","snowflake","account","name",":","param","authenticator",":","authenticator","for","Snowflake",".","'snowflake","'","(","default",")","to","use","the","internal","Snowflake","authenticator","'externalbrowser","'","to","authenticate","using","your","web","browser","and","Okta",",","ADFS","or","any","other","SAML","2.0-compliant","identify","provider","(","IdP",")","that","has","been","defined","for","your","account","``","https",":","\/\/","<","your_okta_account_name",">",".okta.com","``","to","authenticate","through","native","Okta",".",":","param","warehouse",":","name","of","snowflake","warehouse",":","param","database",":","name","of","snowflake","database",":","param","region",":","name","of","snowflake","region",":","param","role",":","name","of","snowflake","role",":","param","schema",":","name","of","snowflake","schema",":","param","session_parameters",":","You","can","set","session-level","parameters","at","the","time","you","connect","to","Snowflake",":","param","insecure_mode",":","Turns","off","OCSP","certificate","checks",".","For","details",",","see",":","`","How","To",":","Turn","Off","OCSP","Checking","in","Snowflake","Client","Drivers","-","Snowflake","Community","<","https",":","\/\/community.snowflake.com\/s\/article\/How-to-turn-off-OCSP-checking-in-Snowflake-client-drivers",">","`","__","..","note",":",":","``","get_sqlalchemy_engine","(",")","``","depends","on","``","snowflake-sqlalchemy","``","..","seealso",":",":","For","more","information","on","how","to","use","this","Snowflake","connection",",","take","a","look","at","the","guide",":",":","ref",":","`","howto\/operator",":","SnowflakeOperator","`"]
docstr: Runs a command or a list of commands.
  
  Pass a list of SQL statements to the SQL parameter to get them to
  execute sequentially. The variable ``execution_info`` is returned so
  that it can be used in the Operators to modify the behavior depending on
  the result of the query (i.e fail the operator if the copy has processed
  0 files).
  
  :param sql: The SQL string to be executed with possibly multiple
      statements, or a list of sql statements to execute
  :param autocommit: What to set the connection's autocommit setting to
      before executing the query.
  :param parameters: The parameters to render the SQL query with.
  :param handler: The result handler which is called with the result of
      each statement.
  :param split_statements: Whether to split a single SQL string into
      statements and run separately
  :param return_last: Whether to return result for only last statement or
      for all after split.
  :param return_dictionaries: Whether to return dictionaries rather than
      regular DBAPI sequences as rows in the result. The dictionaries are
      of form ``{ 'column1_name': value1, 'column2_name': value2 ... }``.
  :return: Result of the last SQL statement if *handler* is set.
      *None* otherwise.
docstr_tok: ["Runs","a","command","or","a","list","of","commands",".","Pass","a","list","of","SQL","statements","to","the","SQL","parameter","to","get","them","to","execute","sequentially",".","The","variable","``","execution_info","``","is","returned","so","that","it","can","be","used","in","the","Operators","to","modify","the","behavior","depending","on","the","result","of","the","query","(","i.e","fail","the","operator","if","the","copy","has","processed","0","files",")",".",":","param","sql",":","The","SQL","string","to","be","executed","with","possibly","multiple","statements",",","or","a","list","of","sql","statements","to","execute",":","param","autocommit",":","What","to","set","the","connection","'s","autocommit","setting","to","before","executing","the","query",".",":","param","parameters",":","The","parameters","to","render","the","SQL","query","with",".",":","param","handler",":","The","result","handler","which","is","called","with","the","result","of","each","statement",".",":","param","split_statements",":","Whether","to","split","a","single","SQL","string","into","statements","and","run","separately",":","param","return_last",":","Whether","to","return","result","for","only","last","statement","or","for","all","after","split",".",":","param","return_dictionaries",":","Whether","to","return","dictionaries","rather","than","regular","DBAPI","sequences","as","rows","in","the","result",".","The","dictionaries","are","of","form","``","{","'column1_name","'",":","value1",",","'column2_name","'",":","value2","...","}","``",".",":","return",":","Result","of","the","last","SQL","statement","if","*","handler","*","is","set",".","*","None","*","otherwise","."]
code: def run(
      self,
      sql: str | Iterable[str],
      autocommit: bool = False,
      parameters: Iterable | Mapping[str, Any] | None = None,
      handler: Callable[[Any], T] | None = None,
      split_statements: bool = True,
      return_last: bool = True,
      return_dictionaries: bool = False,
  ) -> tuple | list[tuple] | list[list[tuple] | tuple] | None:
      """Runs a command or a list of commands.
  
      Pass a list of SQL statements to the SQL parameter to get them to
      execute sequentially. The variable ``execution_info`` is returned so
      that it can be used in the Operators to modify the behavior depending on
      the result of the query (i.e fail the operator if the copy has processed
      0 files).
  
      :param sql: The SQL string to be executed with possibly multiple
          statements, or a list of sql statements to execute
      :param autocommit: What to set the connection's autocommit setting to
          before executing the query.
      :param parameters: The parameters to render the SQL query with.
      :param handler: The result handler which is called with the result of
          each statement.
      :param split_statements: Whether to split a single SQL string into
          statements and run separately
      :param return_last: Whether to return result for only last statement or
          for all after split.
      :param return_dictionaries: Whether to return dictionaries rather than
          regular DBAPI sequences as rows in the result. The dictionaries are
          of form ``{ 'column1_name': value1, 'column2_name': value2 ... }``.
      :return: Result of the last SQL statement if *handler* is set.
          *None* otherwise.
      """
      self.query_ids = []
  
      if isinstance(sql, str):
          if split_statements:
              split_statements_tuple = util_text.split_statements(
                  StringIO(sql)
              )
              sql_list: Iterable[str] = [
                  sql_string
                  for sql_string, _ in split_statements_tuple
                  if sql_string
              ]
          else:
              sql_list = [self.strip_sql_string(sql)]
      else:
          sql_list = sql
  
      if sql_list:
          self.log.debug(
              "Executing following statements against Snowflake DB: %s",
              sql_list,
          )
      else:
          raise ValueError("List of SQL statements is empty")
  
      with closing(self.get_conn()) as conn:
          self.set_autocommit(conn, autocommit)
  
          with self._get_cursor(conn, return_dictionaries) as cur:
              results = []
              for sql_statement in sql_list:
                  self._run_command(cur, sql_statement, parameters)  # type: ignore[attr-defined]
  
                  if handler is not None:
                      result = self._make_common_data_structure(handler(cur))  # type: ignore[attr-defined]
                      if return_single_query_results(
                          sql, return_last, split_statements
                      ):
                          _last_result = result
                          _last_description = cur.description
                      else:
                          results.append(result)
                          self.descriptions.append(cur.description)
  
                  query_id = cur.sfqid
                  self.log.info("Rows affected: %s", cur.rowcount)
                  self.log.info("Snowflake query id: %s", query_id)
                  self.query_ids.append(query_id)
  
          # If autocommit was set to False or db does not support autocommit, we do a manual commit.
          if not self.get_autocommit(conn):
              conn.commit()
  
      if handler is None:
          return None
      if return_single_query_results(
          sql, return_last, split_statements
      ):
          self.descriptions = [_last_description]
          return _last_result
      else:
          return results
  
imports: from __future__ import annotations
  import os
  from contextlib import closing, contextmanager
  from io import StringIO
  from pathlib import Path
  from typing import TYPE_CHECKING, Any, Callable, Iterable, Mapping, TypeVar, overload
  from urllib.parse import urlparse
  from cryptography.hazmat.backends import default_backend
  from cryptography.hazmat.primitives import serialization
  from snowflake import connector
  from snowflake.connector import DictCursor, SnowflakeConnection, util_text
  from snowflake.sqlalchemy import URL
  from sqlalchemy import create_engine
  from airflow.exceptions import AirflowException
  from airflow.providers.common.sql.hooks.sql import DbApiHook, return_single_query_results
  from airflow.utils.strings import to_boolean
label_desc: Use image node_id 14 for calling the SnowflakeHook obj's underlying member method code with example usage: obj.run(sql, autocommit, parameters, handler, split_statements, return_last, return_dictionaries) and returns: None, _last_result, results