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: 

ConnectException error

Raymond_Hu
New Contributor

I'm using PySpark on Databricks and trying to pivot a 27753444 X 3 matrix.

If I do it in Spark DataFrame:

df = df.groupBy("A").pivot("B").avg("C")

it takes forever (after 2 hours and I canceled it).

If I convert it to pandas dataframe and then pivot:

pandas_df = pandas_df.pivot(index='A',columns='B',values='C').fillna(0)

It always gives me an error:

ConnectException: Connection refused (Connection refused)
Error while obtaining a new communication channel 
ConnectException error: This is often caused by an OOM error that causes the connection to the Python REPL to be closed. Check your query's memory usage.

However, I've already increased memory of my clusters to 192 GB and it still doesn't work.

Can someone help?

Thanks!

1 REPLY 1

shyam_9
Valued Contributor

Hi @Raymond_Hu,

This means that the driver crashed because of an OOM (Out of memory) exception and after that, it's not able to establish a new connection with the driver. Please try below options

  • Try increasing driver-side memory and then retry.
  • You can look at the spark job dag which give you more info on data flow.

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