PySpark, setting spark conf values in a function and catching for errors

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

PySpark, setting spark conf values in a function and catching for errors

Mich Talebzadeh


I have multiple routines that are using Spark for Google BigQuery that set these configuration values. I have decided to put them in a PySpark function as below with spark as an input.

def setSparkConfSet(spark):


        spark.conf.set("GcpJsonKeyFile", config['GCPVariables']['jsonKeyFile'])

        spark.conf.set("BigQueryProjectId", config['GCPVariables']['projectId'])

        spark.conf.set("BigQueryDatasetLocation", config['GCPVariables']['datasetLocation'])

        spark.conf.set("", "true")

        spark.conf.set("", config['GCPVariables']['projectId'])

        spark.conf.set("", "")

        spark.conf.set("", "")

        spark.conf.set("temporaryGcsBucket", config['GCPVariables']['tmp_bucket'])


        print(f"""Could not set spark config variables, quitting""")


Two questions

Is it necessary to catch any error or simply call the function in the main routine or do the error handling in the module that is calling this function?




Disclaimer: Use it at your own risk. Any and all responsibility for any loss, damage or destruction of data or any other property which may arise from relying on this email's technical content is explicitly disclaimed. The author will in no case be liable for any monetary damages arising from such loss, damage or destruction.