cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
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

3 REPLIES 3

Kaniz
Community Manager
Community Manager

Hi @Chandan Angadi​ , Can you please share the parameters of your cluster?

chandan_a_v
Valued Contributor

Hi @Kaniz Fatma​ ,

image

g_krilis
New Contributor II

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?

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.