Loading Academy Hub...
Run cost-effective managed Spark workloads: Cloud Dataproc workflow templates, ephemeral single-job clusters, preemptible / Spot VM autoscaling, and high-speed BigQuery connector.
[!NOTE] Google Cloud Dataproc provides fast (sub-90-second provisioning) managed Apache Spark and Hadoop clusters. The production pattern uses Ephemeral Clusters: create a cluster, run a single job, and immediately delete the cluster to eliminate idle costs.
Batches): Never leave idle Dataproc GCE clusters sitting overnight for cron PySpark jobs. Run Dataproc Serverless Batches (zero cluster provisioning, auto-scaling executors) or ephemeral Workflow Templates that spin up per DAG run, read/write GCS directly, and self-destruct immediately on completion.Storage Read/Write API): Avoid legacy GCS-staging export mode when reading/writing massive BigQuery tables from Spark—use the spark-bigquery-connector v2 (Storage Read API + DIRECT Storage Write API) for parallel Apache Arrow streams directly into Spark partitions.2–4) with cheap Spot Secondary Workers and Enhanced Flexibility Mode (EFM) so shuffle data stays anchored on reliable primary nodes (spark.dataproc.enhanced.execution.enabled) when GCP reclaims Spot VMs.Review the production code, company interview Q&As, incident traces, and comprehension quiz inside this lesson.
from pyspark.sql import SparkSession
spark = SparkSession.builder \
.appName("DataprocBigQueryETL") \
.getOrCreate()
# Direct high-speed gRPC read from BigQuery via Storage Read API
df = spark.read.format("bigquery") \
.option("table", "enterprise-lakehouse-prod:finance.fact_transactions") \
.option("filter", "transaction_time >= '2026-03-01'") \
.load()
# Transform in Spark memory
summary_df = df.groupBy("merchant_id").agg({"amount": "sum"})
# Direct write back using intermediate GCS bucket
summary_df.write.format("bigquery") \
.option("table", "enterprise-lakehouse-prod:finance.merchant_daily_summary") \
.option("temporaryGcsBucket", "dataproc-staging-lakehouse-prod") \
.mode("overwrite") \
.save()
print("Dataproc BigQuery transformation job completed successfully.")FetchFailedException: ExecutorLostFailure: Worker preempted by Google Cloud Engine.