public class UpdateSchemaDestination<DestinationT> extends DoFn<java.lang.Iterable<KV<DestinationT,org.apache.beam.sdk.io.gcp.bigquery.WriteTables.Result>>,java.lang.Iterable<KV<TableDestination,org.apache.beam.sdk.io.gcp.bigquery.WriteTables.Result>>>
Unlike load and query jobs, BigQuery copy jobs do not support schema field addition or relaxation on the destination table. This DoFn fills that gap by updating the destination table schemas to be compatible with the data coming from the source table so that schemaUpdateOptions are respected regardless of whether data is loaded directly to the destination table or loaded into temporary tables before being copied into the destination.
This transform takes as input a list of KV(destination, WriteTables.Result) and emits a list of KV(TableDestination, WriteTables.Result) where the destination label is parsed and replaced to TableDestination objects.
DoFn.AlwaysFetched, DoFn.BoundedPerElement, DoFn.BundleFinalizer, DoFn.Element, DoFn.FieldAccess, DoFn.FinishBundle, DoFn.FinishBundleContext, DoFn.GetInitialRestriction, DoFn.GetInitialWatermarkEstimatorState, DoFn.GetRestrictionCoder, DoFn.GetSize, DoFn.GetWatermarkEstimatorStateCoder, DoFn.Key, DoFn.MultiOutputReceiver, DoFn.NewTracker, DoFn.NewWatermarkEstimator, DoFn.OnTimer, DoFn.OnTimerContext, DoFn.OnTimerFamily, DoFn.OnWindowExpiration, DoFn.OnWindowExpirationContext, DoFn.OutputReceiver<T>, DoFn.ProcessContext, DoFn.ProcessContinuation, DoFn.ProcessElement, DoFn.RequiresStableInput, DoFn.RequiresTimeSortedInput, DoFn.Restriction, DoFn.Setup, DoFn.SideInput, DoFn.SplitRestriction, DoFn.StartBundle, DoFn.StartBundleContext, DoFn.StateId, DoFn.Teardown, DoFn.TimerFamily, DoFn.TimerId, DoFn.Timestamp, DoFn.TruncateRestriction, DoFn.UnboundedPerElement, DoFn.WatermarkEstimatorState, DoFn.WindowedContext
Constructor and Description |
---|
UpdateSchemaDestination(BigQueryServices bqServices,
PCollectionView<java.lang.String> zeroLoadJobIdPrefixView,
ValueProvider<java.lang.String> loadJobProjectId,
BigQueryIO.Write.WriteDisposition writeDisposition,
BigQueryIO.Write.CreateDisposition createDisposition,
int maxRetryJobs,
java.lang.String kmsKey,
java.util.Set<BigQueryIO.Write.SchemaUpdateOption> schemaUpdateOptions,
DynamicDestinations<?,DestinationT> dynamicDestinations) |
Modifier and Type | Method and Description |
---|---|
void |
finishBundle(DoFn.FinishBundleContext context) |
void |
onTeardown() |
void |
processElement(java.lang.Iterable<KV<DestinationT,org.apache.beam.sdk.io.gcp.bigquery.WriteTables.Result>> element,
DoFn.ProcessContext context,
BoundedWindow window) |
void |
startBundle(DoFn.StartBundleContext c) |
getAllowedTimestampSkew, getInputTypeDescriptor, getOutputTypeDescriptor, populateDisplayData, prepareForProcessing
public UpdateSchemaDestination(BigQueryServices bqServices, PCollectionView<java.lang.String> zeroLoadJobIdPrefixView, @Nullable ValueProvider<java.lang.String> loadJobProjectId, BigQueryIO.Write.WriteDisposition writeDisposition, BigQueryIO.Write.CreateDisposition createDisposition, int maxRetryJobs, @Nullable java.lang.String kmsKey, java.util.Set<BigQueryIO.Write.SchemaUpdateOption> schemaUpdateOptions, DynamicDestinations<?,DestinationT> dynamicDestinations)
@DoFn.StartBundle public void startBundle(DoFn.StartBundleContext c)
@DoFn.ProcessElement public void processElement(@DoFn.Element java.lang.Iterable<KV<DestinationT,org.apache.beam.sdk.io.gcp.bigquery.WriteTables.Result>> element, DoFn.ProcessContext context, BoundedWindow window) throws java.io.IOException
java.io.IOException
@DoFn.Teardown public void onTeardown()
@DoFn.FinishBundle public void finishBundle(DoFn.FinishBundleContext context) throws java.lang.Exception
java.lang.Exception