Class JdbcIO.WriteWithResults<T,V extends JdbcWriteResult>
- All Implemented Interfaces:
Serializable,HasDisplayData
- Enclosing class:
JdbcIO
PTransform to write to a JDBC datasource. Executes statements one by one.
The INSERT, UPDATE, and DELETE commands sometimes have an optional RETURNING clause that
supports obtaining data from modified rows while they are being manipulated. Output PCollection of this transform is a collection of such returning results mapped by JdbcIO.RowMapper.
- See Also:
-
Field Summary
Fields inherited from class org.apache.beam.sdk.transforms.PTransform
annotations, displayData, name, resourceHints -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionexpand(PCollection<T> input) Override this method to specify how thisPTransformshould be expanded on the givenInputT.If true, enables using a dynamically determined number of shards to write.withBatchSize(long batchSize) withDataSourceProviderFn(SerializableFunction<Void, DataSource> dataSourceProviderFn) withMaxBatchBufferingDuration(long maxBatchBufferingDuration) withRetryConfiguration(JdbcIO.RetryConfiguration retryConfiguration) When a SQL exception occurs,JdbcIO.Writeuses thisJdbcIO.RetryConfigurationto exponentially back off and retry the statements based on theJdbcIO.RetryConfigurationmentioned.withRetryStrategy(JdbcIO.RetryStrategy retryStrategy) When a SQL exception occurs,JdbcIO.Writeuses thisJdbcIO.RetryStrategyto determine if it will retry the statements.withRowMapper(JdbcIO.RowMapper<V> rowMapper) withStatement(String statement) withStatement(ValueProvider<String> statement) Methods inherited from class org.apache.beam.sdk.transforms.PTransform
addAnnotation, compose, compose, getAdditionalInputs, getAnnotations, getDefaultOutputCoder, getDefaultOutputCoder, getDefaultOutputCoder, getKindString, getName, getResourceHints, populateDisplayData, setDisplayData, setResourceHints, toString, validate, validate
-
Constructor Details
-
WriteWithResults
public WriteWithResults()
-
-
Method Details
-
withBatchSize
-
withMaxBatchBufferingDuration
-
withDataSourceConfiguration
public JdbcIO.WriteWithResults<T,V> withDataSourceConfiguration(JdbcIO.DataSourceConfiguration config) -
withDataSourceProviderFn
public JdbcIO.WriteWithResults<T,V> withDataSourceProviderFn(SerializableFunction<Void, DataSource> dataSourceProviderFn) -
withStatement
-
withStatement
-
withPreparedStatementSetter
public JdbcIO.WriteWithResults<T,V> withPreparedStatementSetter(JdbcIO.PreparedStatementSetter<T> setter) -
withAutoSharding
If true, enables using a dynamically determined number of shards to write. -
withRetryStrategy
When a SQL exception occurs,JdbcIO.Writeuses thisJdbcIO.RetryStrategyto determine if it will retry the statements. IfJdbcIO.RetryStrategy.apply(SQLException)returnstrue, thenJdbcIO.Writeretries the statements. -
withRetryConfiguration
public JdbcIO.WriteWithResults<T,V> withRetryConfiguration(JdbcIO.RetryConfiguration retryConfiguration) When a SQL exception occurs,JdbcIO.Writeuses thisJdbcIO.RetryConfigurationto exponentially back off and retry the statements based on theJdbcIO.RetryConfigurationmentioned.Usage of RetryConfiguration -
maxDuration and initialDuration are Nullablepipeline.apply(JdbcIO.<T>write()) .withReturningResults(...) .withDataSourceConfiguration(...) .withRetryStrategy(...) .withRetryConfiguration(JdbcIO.RetryConfiguration. create(5, Duration.standardSeconds(5), Duration.standardSeconds(1))pipeline.apply(JdbcIO.<T>write()) .withReturningResults(...) .withDataSourceConfiguration(...) .withRetryStrategy(...) .withRetryConfiguration(JdbcIO.RetryConfiguration. create(5, null, null) -
withTable
-
withRowMapper
-
expand
Description copied from class:PTransformOverride this method to specify how thisPTransformshould be expanded on the givenInputT.NOTE: This method should not be called directly. Instead apply the
PTransformshould be applied to theInputTusing theapplymethod.Composite transforms, which are defined in terms of other transforms, should return the output of one of the composed transforms. Non-composite transforms, which do not apply any transforms internally, should return a new unbound output and register evaluators (via backend-specific registration methods).
- Specified by:
expandin classPTransform<PCollection<T>,PCollection<V extends JdbcWriteResult>>
-