You are viewing documentation about an older version (1.2.0). View latest version

Snowpark Session

Session

Session(conn)

Establishes a connection with a Snowflake database and provides methods for creating DataFrames and accessing objects for working with files in stages.

Methods

Session.add_import(path[, import_path])

Registers a remote file in stage or a local file as an import of a user-defined function (UDF).

Session.add_packages(*packages)

Adds third-party packages as dependencies of a user-defined function (UDF).

Session.add_requirements(file_path)

Adds a requirement file that contains a list of packages as dependencies of a user-defined function (UDF).

Session.call(sproc_name, *args)

Calls a stored procedure by name.

Session.cancel_all()

Cancel all action methods that are running currently.

Session.clear_imports()

Clears all files in a stage or local files from the imports of a user-defined function (UDF).

Session.clear_packages()

Clears all third-party packages of a user-defined function (UDF).

Session.close()

Close this session.

Session.createDataFrame(data[, schema])

Creates a new DataFrame containing the specified values from the local data.

Session.create_async_job(query_id)

Creates an AsyncJob from a query ID.

Session.create_dataframe(data[, schema])

Creates a new DataFrame containing the specified values from the local data.

Session.flatten(input[, path, outer, ...])

Creates a new DataFrame by flattening compound values into multiple rows.

Session.generator(*columns[, rowcount, ...])

Creates a new DataFrame using the Generator table function.

Session.get_current_account()

Returns the name of the current account for the Python connector session attached to this session.

Session.get_current_database()

Returns the name of the current database for the Python connector session attached to this session.

Session.get_current_role()

Returns the name of the primary role in use for the current session.

Session.get_current_schema()

Returns the name of the current schema for the Python connector session attached to this session.

Session.get_current_warehouse()

Returns the name of the warehouse in use for the current session.

Session.get_fully_qualified_current_schema()

Returns the fully qualified name of the current schema for the session.

Session.get_imports()

Returns a list of imports added for user defined functions (UDFs).

Session.get_packages()

Returns a dict of packages added for user-defined functions (UDFs).

Session.get_session_stage()

Returns the name of the temporary stage created by the Snowpark library for uploading and storing temporary artifacts for this session.

Session.query_history()

Create an instance of QueryHistory as a context manager to record queries that are pushed down to the Snowflake database.

Session.range(start[, end, step])

Creates a new DataFrame from a range of numbers.

Session.remove_import(path)

Removes a file in stage or local file from the imports of a user-defined function (UDF).

Session.remove_package(package)

Removes a third-party package from the dependency list of a user-defined function (UDF).

Session.sql(query)

Returns a new DataFrame representing the results of a SQL query.

Session.table(name)

Returns a Table that points the specified table.

Session.table_function(func_name, ...)

Creates a new DataFrame from the given snowflake SQL table function.

Session.use_database(database)

Specifies the active/current database for the session.

Session.use_role(role)

Specifies the active/current primary role for the session.

Session.use_schema(schema)

Specifies the active/current schema for the session.

Session.use_secondary_roles(roles)

Specifies the active/current secondary roles for the session.

Session.use_warehouse(warehouse)

Specifies the active/current warehouse for the session.

Session.write_pandas(df, table_name, *[, ...])

Writes a pandas DataFrame to a table in Snowflake and returns a Snowpark DataFrame object referring to the table where the pandas DataFrame was written to.

Attributes

Session.builder

Returns a builder you can use to set configuration properties and create a Session object.

Session.file

Returns a FileOperation object that you can use to perform file operations on stages.

Session.query_tag

The query tag for this session.

Session.read

Returns a DataFrameReader that you can use to read data from various supported sources (e.g.

Session.sproc

Returns a stored_procedure.StoredProcedureRegistration object that you can use to register stored procedures.

Session.sql_simplifier_enabled

Session.telemetry_enabled

Returns whether telemetry is enabled.

Session.udf

Returns a udf.UDFRegistration object that you can use to register UDFs.

Session.udtf

Returns a udtf.UDTFRegistration object that you can use to register UDTFs.