Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,11 @@ private PipelineResult runRead(String tableName) {
@Test
public void testWriteWithAutosharding() throws Exception {
String firstTableName = DatabaseTestHelper.getTestTableName("JDBCIT_AUTOSHARD");
DatabaseTestHelper.createTable(dataSource, firstTableName);
// JdbcIO may replay committed writes when a bundle is retried.
DatabaseTestHelper.createTable(
dataSource,
firstTableName,
Lists.newArrayList(KV.of("id", "INT PRIMARY KEY"), KV.of("name", "VARCHAR(500)")));
try {
PCollection<TestRow> dataCollection =
pipelineWrite.apply(
Expand All @@ -282,7 +286,10 @@ public void testWriteWithAutosharding() throws Exception {
.apply(
JdbcIO.<TestRow>write()
.withDataSourceConfiguration(JdbcIO.DataSourceConfiguration.create(dataSource))
.withStatement(String.format("insert into %s values(?, ?)", firstTableName))
.withStatement(
String.format(
"insert into %s values(?, ?) on conflict (id) do nothing",
firstTableName))
.withAutoSharding()
.withPreparedStatementSetter(new JdbcTestHelper.PrepareStatementFromTestRow()));

Expand Down
Loading