cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to restart the Spark session within the notebook without reattaching the notebook?

chandan_a_v
Valued Contributor

Hi All,

I want to run an ETL pipeline in a sequential way in my DB notebook. If I run it without resetting the Spark session or restarting the cluster I am getting a data frame key error. I think this might be because of the Spark cache because If I restart the cluster and run the next item of the sequence I don't get this issue. I am clearing the Spark cache at the end of the ETL pipeline for each run but still, I am facing the same issue. I thought stopping the Spark session and starting it again will fix this, but that will reattach the notebook. And execution starts from the beginning not from the next item in the sequence.

Thanks,

Chandan

2 REPLIES 2

chandan_a_v
Valued Contributor

Hi @Kaniz Fatma​ ,

image

Anonymous
Not applicable

Is there a solution to the above problem? I also would like to restart SparkSession to free my cluster's resources, but when calling

spark.stop()

the notebook automatically detach and the following error occurs:

The spark context has stopped and the driver is restarting. Your notebook will be automatically reattached. 

Is there a recommended way to restart SparkSession?

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group