You can connect a JDBC client to a specific, existing Livy session by referencing its name in the JDBC connection string. This allows you to create a persistent session and connect to it from multiple clients or reconnect after a client application has been restarted.
The Livy Named Sessions feature is useful for sharing temporary data, like a global temporary view, across different client connections.
Create a named Livy session using the REST API by using cURL to send a REST API request to the Livy server to create a new
Spark session with a specific name.
In this example, persistent-bi-session is the name assigned to the session.
LIVY_URL=http://[*** Livy Thrift Server Host ***]:8998
curl -X POST --data '{"kind": "spark", "name": "persistent-bi-session"}' -H "Content-Type: application/json" $LIVY_URL/sessions
Create a Global Temporary View in the named Livy session by creating a DataFrame and register it as a global temporary view.
Connect to the existing session through Beeline by using the Beeline JDBC client to connect to the Livy Thrift Server and passing the session name in the livy.session.name property in the connection URL.