Package com.snowflake.snowpark_java

## Class SessionBuilder

- java.lang.Object
- - com.snowflake.snowpark_java.SessionBuilder

-     public class SessionBuilder
      extends java.lang.Object

  Provides methods to set configuration properties and create a `Session`.
  Since:
    0.8.0
  See Also:
    `Session`

- - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `SessionBuilder` | `appName​(java.lang.String appName)` | Adds the app name to set in the query_tag after session creation.
    `SessionBuilder` | `config​(java.lang.String key, java.lang.String value)` | Adds the specified configuration property and value to the SessionBuilder configuration.
    `SessionBuilder` | `configFile​(java.lang.String path)` | Adds the configuration properties in the specified file to the `SessionBuilder` configuration.
    `SessionBuilder` | `configs​(java.util.Map<java.lang.String,​java.lang.String> configs)` | Adds the specified Map of configuration properties to the SessionBuilder configuration.
    `Session` | `create()` | Creates a new `Session`.
    `Session` | `getOrCreate()` | Returns the existing session if already exists or create it if not.

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

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

- - ### Method Detail

    - #### configFile

          public SessionBuilder configFile​(java.lang.String path)

      Adds the configuration properties in the specified file to the `SessionBuilder` configuration.
      Parameters:
        `path` - Path to the file containing the configuration properties.
      Returns:
        This `SessionBuilder` object.
      Since:
        0.8.0

    - #### config

          public SessionBuilder config​(java.lang.String key,
                                       java.lang.String value)

      Adds the specified configuration property and value to the SessionBuilder configuration.
      Parameters:
        `key` - Name of the configuration property.
        `value` - Value of the configuration property.
      Returns:
        A reference of this SessionBuilder object
      Since:
        1.1.0

    - #### configs

          public SessionBuilder configs​(java.util.Map<java.lang.String,​java.lang.String> configs)

      Adds the specified Map of configuration properties to the SessionBuilder configuration.

      Note that calling this method overwrites any existing configuration properties that you have already set in the SessionBuilder.

      Parameters:
        `configs` - A Java Map contains configurations
      Returns:
        A reference of this SessionBuilder object
      Since:
        1.1.0

    - #### create

          public Session create()

      Creates a new `Session`.
      Returns:
        A `Session` object
      Since:
        0.8.0

    - #### getOrCreate

          public Session getOrCreate()

      Returns the existing session if already exists or create it if not.
      Returns:
        A `Session` object
      Since:
        1.10.0

    - #### appName

          public SessionBuilder appName​(java.lang.String appName)

      Adds the app name to set in the query_tag after session creation.

      Since version 1.13.0, the app name is set to the query tag in JSON format. For example:

           Session session = Session.builder().appName("myApp").configFile(myConfigFile).create();
           System.out.println(session.getQueryTag().get());
           {"APPNAME":"myApp"}

      In previous versions it is set using a key=value format. For example:

           Session session = Session.builder().appName("myApp").configFile(myConfigFile).create();
           System.out.println(session.getQueryTag().get());
           APPNAME=myApp

      Parameters:
        `appName` - Name of the app.
      Returns:
        A `SessionBuilder` object
      Since:
        1.12.0