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?