class_docstr: A connection to Snowpark using snowflake.snowpark.session.Session. Initialize using
  ``st.connection("<name>", type="snowpark")``.
  
  In addition to providing access to the Snowpark Session, SnowparkConnection supports
  direct SQL querying using ``query("...")`` and thread safe access using
  ``with conn.safe_session():``. See methods below for more information.
  SnowparkConnections should always be created using ``st.connection()``, **not**
  initialized directly.
  
  .. note::
      We don't expect this iteration of SnowparkConnection to be able to scale
      well in apps with many concurrent users due to the lock contention that will occur
      over the single underlying Session object under high load.
class_docstr_tok: ["A","connection","to","Snowpark","using","snowflake.snowpark.session.Session",".","Initialize","using","``","st.connection","(","``","<","name",">","''",",","type=","''","snowpark","''",")","``",".","In","addition","to","providing","access","to","the","Snowpark","Session",",","SnowparkConnection","supports","direct","SQL","querying","using","``","query","(","``","...","''",")","``","and","thread","safe","access","using","``","with","conn.safe_session","(",")",":","``",".","See","methods","below","for","more","information",".","SnowparkConnections","should","always","be","created","using","``","st.connection","(",")","``",",","*","*","not","*","*","initialized","directly",".","..","note",":",":","We","do","n't","expect","this","iteration","of","SnowparkConnection","to","be","able","to","scale","well","in","apps","with","many","concurrent","users","due","to","the","lock","contention","that","will","occur","over","the","single","underlying","Session","object","under","high","load","."]
code: def _connect(self, **kwargs) -> "Session":
      from snowflake.snowpark.context import (
          get_active_session,
      )  # type:ignore[import]
      from snowflake.snowpark.exceptions import (  # type:ignore[import]
          SnowparkSessionException,
      )
      from snowflake.snowpark.session import Session
  
      # If we're running in SiS, just call get_active_session(). Otherwise, attempt to
      # create a new session from whatever credentials we have available.
      if running_in_sis():
          return get_active_session()
  
      conn_params = ChainMap(
          kwargs,
          self._secrets.to_dict(),
          load_from_snowsql_config_file(self._connection_name),
      )
  
      if not len(conn_params):
          raise StreamlitAPIException(
              "Missing Snowpark connection configuration. "
              f"Did you forget to set this in `secrets.toml`, `{SNOWSQL_CONNECTION_FILE}`, "
              "or as kwargs to `st.connection`?"
          )
  
      for p in _REQUIRED_CONNECTION_PARAMS:
          if p not in conn_params:
              raise StreamlitAPIException(
                  f"Missing Snowpark connection param: {p}"
              )
  
      return cast(
          Session, Session.builder.configs(conn_params).create()
      )
  
file_path: streamlit/lib/streamlit/connections/snowpark_connection.py
imports: import threading
  from collections import ChainMap
  from contextlib import contextmanager
  from datetime import timedelta
  from typing import TYPE_CHECKING, Iterator, Optional, Union, cast
  import pandas
  from streamlit.connections import BaseConnection
  from streamlit.connections.util import SNOWSQL_CONNECTION_FILE, load_from_snowsql_config_file, running_in_sis
  from streamlit.errors import StreamlitAPIException
  from streamlit.runtime.caching import cache_data
label_desc: Use image node_id 2 for calling the SnowparkConnection obj's underlying member method code with example usage: obj._connect() and returns: cast, get_active_session