Oscar Korz created BEAM-3569:
--------------------------------

             Summary: SpannerIO.write throws on delete mutations
                 Key: BEAM-3569
                 URL: https://issues.apache.org/jira/browse/BEAM-3569
             Project: Beam
          Issue Type: Bug
          Components: runner-core
    Affects Versions: 2.2.0
            Reporter: Oscar Korz
            Assignee: Kenneth Knowles


It is currently impossible to delete a Spanner row in Beam with SpannerIO. The 
exception is generated by trying to guess the size of a delete mutation which 
cannot contain any values (deletes are simply by key).

The root exception stack trace:
{code:java}
 Caused by: java.lang.IllegalStateException: values() cannot be called for a 
DELETE mutation
  at com.google.common.base.Preconditions.checkState(Preconditions.java:456)
  at com.google.cloud.spanner.Mutation.getValues(Mutation.java:233)
  at 
org.apache.beam.sdk.io.gcp.spanner.MutationSizeEstimator.sizeOf(MutationSizeEstimator.java:33)
  at 
org.apache.beam.sdk.io.gcp.spanner.MutationSizeEstimator.sizeOf(MutationSizeEstimator.java:51)
{code}

I believe this can be fixed by special casing MutationSizeEstimator.sizeOf to 
either 0 or 1 for Mutations with getOperation() = Op.DELETE.

The workaround is to avoid using SpannerIO and use Spanner client API directly 
in a custom DoFn, but this forces users to either reimplement all the 
intelligent batching that SpannerIO does or suffer poor performance.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to