pyspark.sql.utils.IllegalArgumentException: requirement failed: Temporary GCS path has not been set

Viewed 2257

On Google Cloud Platform, I am trying to submit a pyspark job that writes a dataframe to BigQuery. The code that executes the writing is as the following:

finalDF.write.format("bigquery")\
.mode('overwrite')\
.option("table","[PROJECT_ID].dataset.table")\
.save()

And I get the mentioned error in the title. How can I set the GCS temporary path?

2 Answers

As the github repository of spark-bigquery-connector states

One can specify it when writing:

df.write
.format("bigquery")
.option("temporaryGcsBucket","some-bucket")
.save("dataset.table")

Or in a global manner:

spark.conf.set("temporaryGcsBucket","some-bucket")

Property "temporaryGcsBucket" needs to be set either at the time of writing dataframe or while creating sparkSession.

.option("temporaryGcsBucket","some-bucket")

or like .option("temporaryGcsBucket","some-bucket/optional_path")

1. finalDF.write.format("bigquery") .mode('overwrite').option("temporaryGcsBucket","some-bucket").option("table","[PROJECT_ID].dataset.table") .save()

Related