@@ -107,8 +107,7 @@ public void executeQuery() {
107107
108108 @ Test
109109 public void executeUpdate () {
110- // Query optimizer version is ignored for DML statements by the backend, but setting it does not
111- // cause an error.
110+ // Optimizer version 1 should work.
112111 assertThat (
113112 client
114113 .readWriteTransaction ()
@@ -150,35 +149,38 @@ public Long run(TransactionContext transaction) throws Exception {
150149 }))
151150 .isEqualTo (1L );
152151
153- // Version '100000' is an invalid value, but is ignored by the backend.
154- assertThat (
155- client
156- .readWriteTransaction ()
157- .run (
158- new TransactionCallable <Long >() {
159- @ Override
160- public Long run (TransactionContext transaction ) throws Exception {
161- return transaction .executeUpdate (
162- Statement .newBuilder ("INSERT INTO TEST (ID, NAME) VALUES (@id, @name)" )
163- .bind ("id" )
164- .to (3L )
165- .bind ("name" )
166- .to ("Three" )
167- .withQueryOptions (
168- QueryOptions .newBuilder ().setOptimizerVersion ("10000" ).build ())
169- .build ());
170- }
171- }))
172- .isEqualTo (1L );
152+ // Version '100000' is an invalid value and should cause an error.
153+ try {
154+ client
155+ .readWriteTransaction ()
156+ .run (
157+ new TransactionCallable <Long >() {
158+ @ Override
159+ public Long run (TransactionContext transaction ) throws Exception {
160+ return transaction .executeUpdate (
161+ Statement .newBuilder ("INSERT INTO TEST (ID, NAME) VALUES (@id, @name)" )
162+ .bind ("id" )
163+ .to (3L )
164+ .bind ("name" )
165+ .to ("Three" )
166+ .withQueryOptions (
167+ QueryOptions .newBuilder ().setOptimizerVersion ("100000" ).build ())
168+ .build ());
169+ }
170+ });
171+ fail ("missing expected exception" );
172+ } catch (SpannerException e ) {
173+ assertThat (e .getErrorCode ()).isEqualTo (ErrorCode .INVALID_ARGUMENT );
174+ assertThat (e .getMessage ()).contains ("Query optimizer version: 100000 is not supported" );
175+ }
173176
174- // Verify that query options are ignored with Partitioned DML as well, and that all the above
175- // DML INSERT statements succeeded.
177+ // Setting an optimizer version for PDML should also be allowed.
176178 assertThat (
177179 client .executePartitionedUpdate (
178180 Statement .newBuilder ("UPDATE TEST SET NAME='updated' WHERE 1=1" )
179181 .withQueryOptions (QueryOptions .newBuilder ().setOptimizerVersion ("1" ).build ())
180182 .build ()))
181- .isEqualTo (3L );
183+ .isEqualTo (2L );
182184 }
183185
184186 @ Test
0 commit comments