Class Session

java.lang.Object
com.snowflake.snowpark_java.Session

public class Session extends Object
Stub implementation of Snowflake Snowpark Session for inline Java/Scala procedures. Injected into the procedure handler method as the first argument.

Mirrors the subset of the real Snowpark Session surface that handler code uses, and reproduces Snowflake's stored-procedure restrictions, all rejected at runtime: creating a new session, obtaining the underlying JDBC connection, running two queries at the same time (concurrency — see beginQuery() for why that is not the thread check the documentation's wording suggests), and creating named temporary objects under owner's rights. Matches the documented Java stored-procedure limitations (https://docs.snowflake.com/en/developer-guide/stored-procedure/java/procedure-java-limitations).

Deliberately does not expose the underlying DatabaseEngine; the real Snowpark Session has no such accessor, and exposing it would let handler code escape the session sandbox.

  • Constructor Details

    • Session

      public Session(DatabaseEngine engine)
    • Session

      public Session(DatabaseEngine engine, boolean ownersRights)
      Parameters:
      ownersRights - true when the procedure runs with the owner's rights (EXECUTE AS OWNER, the default), which forbids creating named temporary objects.
  • Method Details

    • sql

      public DataFrame sql(String sqlText)
      Build a plan over sqlText. Nothing is submitted here — see DataFrame.

      The refusals that used to live in this method moved to runPlan(java.lang.String), because that is where live raises them: a handler that calls session.sql("CREATE TEMPORARY TABLE …") under owner's rights and never collects returns normally on Snowflake, and only the added .collect() produces "Unsupported statement type 'temporary TABLE'".

    • table

      public DataFrame table(String tableName)
    • builder

      public static SessionBuilder builder()
      Entry point for the Session.builder()...create() idiom. Building configuration is permitted; the terminal SessionBuilder.create() call is rejected, because Snowflake prohibits creating a new session from within a stored procedure.
    • jdbcConnection

      public Connection jdbcConnection()
      Snowflake does not allow a stored procedure to access the session's underlying JDBC connection.
      Throws:
      UnsupportedOperationException - always