professional-cloud-data-engineer
Prepare and test your skills
Prepare and test your skills
Worked example. The correct answer is already marked and every option is explained below, so there is nothing to select here. To answer questions yourself, start the free trial.
A data engineering team is designing a streaming pipeline using Apache Beam running on Cloud Dataflow to process financial transactions and sink transformed account balances into Google Cloud Spanner.
During disaster recovery and worker failure testing, the team observes that pipeline tasks retry and fail with com.google.cloud.spanner.SpannerException: ALREADY_EXISTS exceptions, causing the Dataflow job to crash.
Which mutation strategy should the team implement in their Apache Beam transformation logic to ensure resilient and idempotent writes to Cloud Spanner?
The Mutation.newInsertOrUpdateBuilder (in the Java SDK) and SpannerInsertOrUpdate (in the Python SDK) are mutation factory methods used in Apache Beam pipelines to perform idempotent upserts into Google Cloud Spanner. When applied, this operation checks if a row with the specified primary key exists: if it exists, Spanner updates the matching column values; if it does not exist, Spanner inserts a new row.
INSERT_OR_UPDATE prevents Spanner from throwing ALREADY_EXISTS exceptions because reapplying an upsert mutation with identical key-value data is completely idempotent.SpannerIO.write(), which batches mutations automatically for high-performance ingestion.Mutation.newInsertOrUpdateBuilder) and Python SDK (SpannerInsertOrUpdate).Cloud Spanner's native INSERT_OR_UPDATE mutation is specifically designed for high-scale batch and streaming pipelines where distributed runners like Cloud Dataflow cannot guarantee exactly-once side-effects at external storage sinks without idempotent writes.
Keep the momentum going with these hand-picked practice scenarios
Want more questions like this?
Get a free certification question every week.