narasimha_reddy
New Contributor II

You cannot use Spark session explicitly inside Executor logic. Here you are trying mapPartitions which makes the customlogic to get executed inside the executor thread. Either you need to change whole problem approach to segregate spark variable usage to outside of executor logic Or you can use python native functions /modules inside the Executor.