Skip to content

Commit e67e913

Browse files
1 parent e3156c7 commit e67e913

6 files changed

Lines changed: 41 additions & 25 deletions

File tree

google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/ConnectionWorker.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import com.google.api.gax.rpc.FixedHeaderProvider;
2222
import com.google.auto.value.AutoValue;
2323
import com.google.cloud.bigquery.storage.v1.AppendRowsRequest.ProtoData;
24-
import com.google.cloud.bigquery.storage.v1.Exceptions.AppendSerializtionError;
24+
import com.google.cloud.bigquery.storage.v1.Exceptions.AppendSerializationError;
2525
import com.google.cloud.bigquery.storage.v1.StreamConnection.DoneCallback;
2626
import com.google.cloud.bigquery.storage.v1.StreamConnection.RequestCallback;
2727
import com.google.common.annotations.VisibleForTesting;
@@ -901,8 +901,8 @@ private void requestCallback(AppendRowsResponse response) {
901901
rowIndexToErrorMessage.put(
902902
Math.toIntExact(rowError.getIndex()), rowError.getMessage());
903903
}
904-
AppendSerializtionError exception =
905-
new AppendSerializtionError(
904+
AppendSerializationError exception =
905+
new AppendSerializationError(
906906
response.getError().getCode(),
907907
response.getError().getMessage(),
908908
streamName,

google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/Exceptions.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,8 @@ public static StorageException toStorageException(Throwable exception) {
216216
}
217217

218218
/**
219-
* This exception is thrown from {@link JsonStreamWriter#append()} when the client side Json to
220-
* Proto serializtion fails. It can also be thrown by the server in case rows contains invalid
221-
* data. The exception contains a Map of indexes of faulty rows and the corresponding error
222-
* message.
219+
* This class has a typo in the name. It will be removed soon. Please use {@link
220+
* AppendSerializationError}
223221
*/
224222
public static class AppendSerializtionError extends StatusRuntimeException {
225223
private final Map<Integer, String> rowIndexToErrorMessage;
@@ -244,6 +242,23 @@ public String getStreamName() {
244242
}
245243
}
246244

245+
/**
246+
* This exception is thrown from {@link JsonStreamWriter#append()} when the client side Json to
247+
* Proto serializtion fails. It can also be thrown by the server in case rows contains invalid
248+
* data. The exception contains a Map of indexes of faulty rows and the corresponding error
249+
* message.
250+
*/
251+
public static class AppendSerializationError extends AppendSerializtionError {
252+
253+
public AppendSerializationError(
254+
int codeValue,
255+
String description,
256+
String streamName,
257+
Map<Integer, String> rowIndexToErrorMessage) {
258+
super(codeValue, description, streamName, rowIndexToErrorMessage);
259+
}
260+
}
261+
247262
/** This exception is used internally to handle field level parsing errors. */
248263
public static class FieldParseError extends IllegalArgumentException {
249264
private final String fieldName;

google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/JsonStreamWriter.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import com.google.api.gax.core.CredentialsProvider;
2121
import com.google.api.gax.core.ExecutorProvider;
2222
import com.google.api.gax.rpc.TransportChannelProvider;
23-
import com.google.cloud.bigquery.storage.v1.Exceptions.AppendSerializtionError;
23+
import com.google.cloud.bigquery.storage.v1.Exceptions.AppendSerializationError;
2424
import com.google.common.base.Preconditions;
2525
import com.google.protobuf.Descriptors;
2626
import com.google.protobuf.Descriptors.Descriptor;
@@ -194,7 +194,8 @@ public ApiFuture<AppendRowsResponse> append(JSONArray jsonArr, long offset)
194194
// Any error in convertJsonToProtoMessage will throw an
195195
// IllegalArgumentException/IllegalStateException/NullPointerException.
196196
// IllegalArgumentException will be collected into a Map of row indexes to error messages.
197-
// After the conversion is finished an AppendSerializtionError exception that contains all the
197+
// After the conversion is finished an AppendSerializationError exception that contains all
198+
// the
198199
// conversion errors will be thrown.
199200
long currentRequestSize = 0;
200201
Map<Integer, String> rowIndexToErrorMessage = new HashMap<>();
@@ -224,7 +225,7 @@ public ApiFuture<AppendRowsResponse> append(JSONArray jsonArr, long offset)
224225
}
225226

226227
if (!rowIndexToErrorMessage.isEmpty()) {
227-
throw new AppendSerializtionError(
228+
throw new AppendSerializationError(
228229
Code.INVALID_ARGUMENT.getNumber(),
229230
"Append serialization failed for writer: " + streamName,
230231
streamName,

google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/JsonStreamWriterTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
import com.google.cloud.bigquery.storage.test.Test.RepetitionType;
3737
import com.google.cloud.bigquery.storage.test.Test.UpdatedFooType;
3838
import com.google.cloud.bigquery.storage.v1.ConnectionWorkerPool.Settings;
39-
import com.google.cloud.bigquery.storage.v1.Exceptions.AppendSerializtionError;
39+
import com.google.cloud.bigquery.storage.v1.Exceptions.AppendSerializationError;
4040
import com.google.cloud.bigquery.storage.v1.TableFieldSchema.Mode;
4141
import com.google.protobuf.ByteString;
4242
import com.google.protobuf.Descriptors.DescriptorValidationException;
@@ -1096,7 +1096,7 @@ public void testWithoutIgnoreUnknownFieldsUpdateFail() throws Exception {
10961096
try {
10971097
ApiFuture<AppendRowsResponse> appendFuture = writer.append(jsonArr);
10981098
Assert.fail("expected ExecutionException");
1099-
} catch (AppendSerializtionError ex) {
1099+
} catch (AppendSerializationError ex) {
11001100
assertEquals(
11011101
"JSONObject has fields unknown to BigQuery: root.test_unknown.",
11021102
ex.getRowIndexToErrorMessage().get(1));
@@ -1188,7 +1188,7 @@ public void testFlowControlSettingNoLimitBehavior() throws Exception {
11881188
}
11891189

11901190
@Test
1191-
public void testMultipleAppendSerializtionErrors()
1191+
public void testMultipleAppendSerializationErrors()
11921192
throws DescriptorValidationException, IOException, InterruptedException {
11931193
FooType expectedProto = FooType.newBuilder().setFoo("allen").build();
11941194
JSONObject foo = new JSONObject();
@@ -1213,10 +1213,10 @@ public void testMultipleAppendSerializtionErrors()
12131213
getTestJsonStreamWriterBuilder(TEST_STREAM, TABLE_SCHEMA).build()) {
12141214
try {
12151215
ApiFuture<AppendRowsResponse> appendFuture = writer.append(jsonArr);
1216-
Assert.fail("expected AppendSerializtionError");
1217-
} catch (AppendSerializtionError appendSerializtionError) {
1216+
Assert.fail("expected AppendSerializationError");
1217+
} catch (AppendSerializationError appendSerializationError) {
12181218
Map<Integer, String> rowIndexToErrorMessage =
1219-
appendSerializtionError.getRowIndexToErrorMessage();
1219+
appendSerializationError.getRowIndexToErrorMessage();
12201220
assertEquals(2, rowIndexToErrorMessage.size());
12211221
assertEquals(
12221222
"JSONObject has fields unknown to BigQuery: root.not_foo.",
@@ -1253,10 +1253,10 @@ public void testBadStringToNumericRowError()
12531253
getTestJsonStreamWriterBuilder(TEST_STREAM, TABLE_SCHEMA).build()) {
12541254
try {
12551255
ApiFuture<AppendRowsResponse> appendFuture = writer.append(jsonArr);
1256-
Assert.fail("expected AppendSerializtionError");
1257-
} catch (AppendSerializtionError appendSerializtionError) {
1256+
Assert.fail("expected AppendSerializationError");
1257+
} catch (AppendSerializationError appendSerializationError) {
12581258
Map<Integer, String> rowIndexToErrorMessage =
1259-
appendSerializtionError.getRowIndexToErrorMessage();
1259+
appendSerializationError.getRowIndexToErrorMessage();
12601260
assertEquals(1, rowIndexToErrorMessage.size());
12611261
assertTrue(
12621262
rowIndexToErrorMessage

google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/it/ITBigQueryWriteManualClientTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import com.google.cloud.bigquery.Schema;
2929
import com.google.cloud.bigquery.storage.test.Test.*;
3030
import com.google.cloud.bigquery.storage.v1.*;
31-
import com.google.cloud.bigquery.storage.v1.Exceptions.AppendSerializtionError;
31+
import com.google.cloud.bigquery.storage.v1.Exceptions.AppendSerializationError;
3232
import com.google.cloud.bigquery.storage.v1.Exceptions.OffsetAlreadyExists;
3333
import com.google.cloud.bigquery.storage.v1.Exceptions.OffsetOutOfRange;
3434
import com.google.cloud.bigquery.storage.v1.Exceptions.SchemaMismatchedException;
@@ -372,8 +372,8 @@ public void testRowErrors()
372372
} catch (Throwable t) {
373373
assertTrue(t instanceof ExecutionException);
374374
t = t.getCause();
375-
assertTrue(t instanceof AppendSerializtionError);
376-
AppendSerializtionError e = (AppendSerializtionError) t;
375+
assertTrue(t instanceof AppendSerializationError);
376+
AppendSerializationError e = (AppendSerializationError) t;
377377
LOG.info("Found row errors on stream: " + e.getStreamName());
378378
assertEquals(
379379
"Field foo: STRING(10) has maximum length 10 but got a value with length 12 on field foo.",

samples/snippets/src/main/java/com/example/bigquerystorage/WriteToDefaultStream.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import com.google.cloud.bigquery.storage.v1.AppendRowsResponse;
2929
import com.google.cloud.bigquery.storage.v1.BigQueryWriteClient;
3030
import com.google.cloud.bigquery.storage.v1.Exceptions;
31-
import com.google.cloud.bigquery.storage.v1.Exceptions.AppendSerializtionError;
31+
import com.google.cloud.bigquery.storage.v1.Exceptions.AppendSerializationError;
3232
import com.google.cloud.bigquery.storage.v1.Exceptions.StorageException;
3333
import com.google.cloud.bigquery.storage.v1.JsonStreamWriter;
3434
import com.google.cloud.bigquery.storage.v1.TableName;
@@ -218,8 +218,8 @@ public void onFailure(Throwable throwable) {
218218
}
219219
}
220220

221-
if (throwable instanceof AppendSerializtionError) {
222-
AppendSerializtionError ase = (AppendSerializtionError) throwable;
221+
if (throwable instanceof AppendSerializationError) {
222+
AppendSerializationError ase = (AppendSerializationError) throwable;
223223
Map<Integer, String> rowIndexToErrorMessage = ase.getRowIndexToErrorMessage();
224224
if (rowIndexToErrorMessage.size() > 0) {
225225
// Omit the faulty rows

0 commit comments

Comments
 (0)