I have the below folder structure in hdfs.
/home/myid -main.py -test1.py -test2.py
In main.py I am trying to import both test1 and test2.
from pyspark.context import SparkContext
from pyspark.sql.session import SparkSession
sc=SparkContext('local')
spark= SparkSession(sc)
from test1 import test_function
from test2 import new_function
test_function()
new_function()
All 3 files are in same folder.
Test1.py
def test_function():
print("test1")
Test2.py
def new_function():
print("test2")
When I try to execute main.py using spark-submit main.py, it says cannot import new_function.
It is able to import test1.py but not test2.py
I also tried with sc.addPyFile before import. Didn't work.
Tried by giving --py-files along with spark submit and it didn't work either.
Tried zipping both the test1 and test2 and added it along with spark context. It didn't work either.
Trying to understand why it's not working and how to resolve this.