Skip to content

Commit c33c277

Browse files
Address comments
1 parent 1000fdc commit c33c277

File tree

8 files changed

+1239
-256
lines changed

8 files changed

+1239
-256
lines changed

google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionProperties.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -752,9 +752,8 @@ public class ConnectionProperties {
752752
static final ConnectionProperty<Long> DML_BATCH_UPDATE_COUNT =
753753
create(
754754
DML_BATCH_UPDATE_COUNT_PROPERTY_NAME,
755-
"DML statements that are executed in batch when "
756-
+ " 'start batch dml' statement is executed. This property determines"
757-
+ " the update count that is returned for these DML statements. The default is "
755+
"The update count that is returned for DML statements that are executed in an "
756+
+ "explicit DML batch. The default is "
758757
+ DEFAULT_DML_BATCH_UPDATE_COUNT,
759758
DEFAULT_DML_BATCH_UPDATE_COUNT,
760759
LongConverter.INSTANCE,

google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/DmlBatch.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ Builder setAutoBatchUpdateCountVerificationSupplier(Supplier<Boolean> verificati
8484
}
8585

8686
Builder setDmlBatchUpdateCountSupplier(Supplier<Long> dmlbatchUpdateCountSupplier) {
87+
Preconditions.checkNotNull(dmlbatchUpdateCountSupplier);
8788
this.dmlbatchUpdateCountSupplier = dmlbatchUpdateCountSupplier;
8889
return this;
8990
}

google-cloud-spanner/src/main/resources/com/google/cloud/spanner/connection/PG_ClientSideStatements.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,7 @@
976976
"exampleStatements": [
977977
"set local spanner.dml_batch_update_count = 0",
978978
"set local spanner.dml_batch_update_count = 100",
979+
"set local spanner.dml_batch_update_count to 1",
979980
"set local spanner.dml_batch_update_count to 1"
980981
],
981982
"setStatement": {

google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/ConnectionAsyncApiTest.java

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -342,45 +342,22 @@ public void testAutocommitRunBatch() {
342342
@Test
343343
public void testDmlBatchUpdateCount() {
344344
SpannerPool.closeSpannerPool();
345-
mockSpanner.putStatementResult(
346-
MockSpannerServiceImpl.StatementResult.detectDialectResult(Dialect.POSTGRESQL));
347345
try {
348346
try (Connection connection = createConnection()) {
349347
connection.execute(Statement.of("set local spanner.dml_batch_update_count = 1"));
350348
connection.execute(Statement.of("START BATCH DML"));
351349
List<Statement> statements = Arrays.asList(INSERT_STATEMENT, INSERT_STATEMENT);
352350
long[] updateCounts = connection.executeBatchUpdate(statements);
353351
assertThat(updateCounts).asList().containsExactly(1L, 1L);
354-
}
355-
try (Connection connection = createConnection()) {
356-
connection.execute(Statement.of("START BATCH DML"));
357-
List<Statement> statements = Arrays.asList(INSERT_STATEMENT, INSERT_STATEMENT);
358-
long[] updateCounts = connection.executeBatchUpdate(statements);
359-
assertThat(updateCounts).asList().containsExactly(-1L, -1L);
360-
}
361-
} finally {
362-
SpannerPool.closeSpannerPool();
363-
mockSpanner.putStatementResult(
364-
MockSpannerServiceImpl.StatementResult.detectDialectResult(Dialect.GOOGLE_STANDARD_SQL));
365-
}
366-
}
352+
connection.execute(Statement.of("RUN BATCH"));
353+
connection.commit();
367354

368-
@Test
369-
public void testDmlBatchUpdateCountGoogleSql() {
370-
SpannerPool.closeSpannerPool();
371-
try {
372-
try (Connection connection = createConnection()) {
373-
connection.execute(Statement.of("set local dml_batch_update_count = 1"));
374-
connection.execute(Statement.of("START BATCH DML"));
375-
List<Statement> statements = Arrays.asList(INSERT_STATEMENT, INSERT_STATEMENT);
376-
long[] updateCounts = connection.executeBatchUpdate(statements);
377-
assertThat(updateCounts).asList().containsExactly(1L, 1L);
378-
}
379-
try (Connection connection = createConnection()) {
380355
connection.execute(Statement.of("START BATCH DML"));
381-
List<Statement> statements = Arrays.asList(INSERT_STATEMENT, INSERT_STATEMENT);
382-
long[] updateCounts = connection.executeBatchUpdate(statements);
356+
statements = Arrays.asList(INSERT_STATEMENT, INSERT_STATEMENT);
357+
updateCounts = connection.executeBatchUpdate(statements);
383358
assertThat(updateCounts).asList().containsExactly(-1L, -1L);
359+
connection.execute(Statement.of("RUN BATCH"));
360+
connection.commit();
384361
}
385362
} finally {
386363
SpannerPool.closeSpannerPool();

0 commit comments

Comments
 (0)