Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
id: 2b59e8e6c1
question: How do I use Spark with BigQuery as a data source and sink?
sort_order: 62
---

Add the connector package: `com.google.cloud.spark:spark-bigquery-with-dependencies_2.12`

Read from BigQuery:

```python
df = spark.read.format("bigquery") \
.option("table", "project.dataset.table") \
.load()
```

Write to BigQuery:

```python
df.write.format("bigquery") \
.option("table", "project.dataset.output_table") \
.mode("overwrite") \
.save()
```

Make sure:
- your GCP credentials are configured
- dataset location matches your query location
- the output dataset exists

This enables distributed processing on top of warehouse data.