snowflake.snowpark.Session.SessionBuilder.getOrCreate¶
- SessionBuilder.getOrCreate() Session¶
Returns the single active session, or creates one if needed.
Unlike
create(), which creates a new session, this method reuses the active session when exactly one exists and its connection hasn’t expired. Builder configuration options aren’t applied to a reused session.If no active session exists, or the single active session’s connection has expired, this method calls
create()using this builder’s configuration. If multiple sessions are active, it raisesSnowparkSessionExceptioninstead of selecting the most recently created session.- Returns:
The existing active session or a newly created
Session.