Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue while creating SparkSession object using SparkConf

I am new to Spark and need some guidance on the below issue - Whenever I am trying to create a SparkSession object using a SparkConf object I am getting the below error -

AttributeError: 'SparkConf' object has no attribute '_get_object_id'

I am using Spark 2.3 with Python 3.7 in local mode .

sconf=SparkConf.setAppName("test")
ss=SparkSession.builder.config(conf=sconf).getOrCreate()

I have read some of the solutions available in internet but none of them has resolved my issue .

Even when I am trying to create the SparkSession object directly i.e. without explicit SparkConf object , then also I am getting the same error -

ss=SparkSession.builder.master("local").getOrCreate()

AttributeError: 'SparkConf' object has no attribute '_get_object_id'
like image 410
ForeverStudent Avatar asked Jul 02 '26 18:07

ForeverStudent


1 Answers

Do not create a new SparkConf() object : it will be a python object, apparently not compatible with the non-python parts of Spark (it doesn't have the mandatory _get_object_id() method, as expressed by the error message).

The config() method from the builder is cumulative, so you should do :

ss = SparkSession \
    .builder \
    .appName("test") \
    .config("some.parameter", "some.value") \
    .config("some.other.parameter", "some.other.value") \ 
       etc...
    .getOrCreate()
like image 112
Manur Avatar answered Jul 04 '26 09:07

Manur



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!