public abstract static class JdbcIO.WriteWithResults<T,V extends JdbcWriteResult> extends PTransform<PCollection<T>,PCollection<V>>
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
.
name, resourceHints
Constructor and Description |
---|
WriteWithResults() |
compose, compose, getAdditionalInputs, getDefaultOutputCoder, getDefaultOutputCoder, getDefaultOutputCoder, getKindString, getName, getResourceHints, populateDisplayData, setResourceHints, toString, validate, validate
public JdbcIO.WriteWithResults<T,V> withDataSourceConfiguration(JdbcIO.DataSourceConfiguration config)
public JdbcIO.WriteWithResults<T,V> withDataSourceProviderFn(SerializableFunction<java.lang.Void,javax.sql.DataSource> dataSourceProviderFn)
public JdbcIO.WriteWithResults<T,V> withStatement(java.lang.String statement)
public JdbcIO.WriteWithResults<T,V> withStatement(ValueProvider<java.lang.String> statement)
public JdbcIO.WriteWithResults<T,V> withPreparedStatementSetter(JdbcIO.PreparedStatementSetter<T> setter)
public JdbcIO.WriteWithResults<T,V> withAutoSharding()
public JdbcIO.WriteWithResults<T,V> withRetryStrategy(JdbcIO.RetryStrategy retryStrategy)
JdbcIO.Write
uses this JdbcIO.RetryStrategy
to determine if it
will retry the statements. If JdbcIO.RetryStrategy.apply(SQLException)
returns true
,
then JdbcIO.Write
retries the statements.public JdbcIO.WriteWithResults<T,V> withRetryConfiguration(JdbcIO.RetryConfiguration retryConfiguration)
JdbcIO.Write
uses this JdbcIO.RetryConfiguration
to
exponentially back off and retry the statements based on the JdbcIO.RetryConfiguration
mentioned.
Usage of RetryConfiguration -
pipeline.apply(JdbcIO.<T>write())
.withReturningResults(...)
.withDataSourceConfiguration(...)
.withRetryStrategy(...)
.withRetryConfiguration(JdbcIO.RetryConfiguration.
create(5, Duration.standardSeconds(5), Duration.standardSeconds(1))
maxDuration and initialDuration are Nullable
pipeline.apply(JdbcIO.<T>write())
.withReturningResults(...)
.withDataSourceConfiguration(...)
.withRetryStrategy(...)
.withRetryConfiguration(JdbcIO.RetryConfiguration.
create(5, null, null)
public JdbcIO.WriteWithResults<T,V> withTable(java.lang.String table)
public JdbcIO.WriteWithResults<T,V> withRowMapper(JdbcIO.RowMapper<V> rowMapper)
public PCollection<V> expand(PCollection<T> input)
PTransform
PTransform
should be expanded on the given
InputT
.
NOTE: This method should not be called directly. Instead apply the PTransform
should
be applied to the InputT
using the apply
method.
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).
expand
in class PTransform<PCollection<T>,PCollection<V extends JdbcWriteResult>>