I wrote a parent class:
class Parent():
def __init__(self, spark_session=None):
try:
# Instantiate Spark Session
self.spark = spark_session
if not self.spark:
self.spark = SparkSession.builder.config("spark.sql.debug.maxToStringFields", 1000).appName("SparkTest") \
.getOrCreate()
except Exception as e:
print("Initialization of spark & logging couldn't be performed: {}".format(e))
Then the child class has an extra argument in its constructor which is path:
class Child(Parent):
def __init__(self, path, spark=None):
self.spark = super().__init__(spark)
self.path = path
Then when I write this:
a = Child("path", None)
print(a.spak)
For:
self.spark = spark_session
I get:
AttributeError: 'NoneType' object has no attribute 'spark' None
Any idea how to fix this and make spark object instantiate as expected.
Regards