Skip to content

Commit

Permalink
fix: correct AppendSerializtionError typo (#2037)
Browse files Browse the repository at this point in the history
* fix: correct AppendSerializtionError typo

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* chore: add javadoc

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
Neenu1995 and gcf-owl-bot[bot] committed Mar 22, 2023
1 parent e3156c7 commit e67e913
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 25 deletions.
Expand Up @@ -21,7 +21,7 @@
import com.google.api.gax.rpc.FixedHeaderProvider;
import com.google.auto.value.AutoValue;
import com.google.cloud.bigquery.storage.v1.AppendRowsRequest.ProtoData;
import com.google.cloud.bigquery.storage.v1.Exceptions.AppendSerializtionError;
import com.google.cloud.bigquery.storage.v1.Exceptions.AppendSerializationError;
import com.google.cloud.bigquery.storage.v1.StreamConnection.DoneCallback;
import com.google.cloud.bigquery.storage.v1.StreamConnection.RequestCallback;
import com.google.common.annotations.VisibleForTesting;
Expand Down Expand Up @@ -901,8 +901,8 @@ private void requestCallback(AppendRowsResponse response) {
rowIndexToErrorMessage.put(
Math.toIntExact(rowError.getIndex()), rowError.getMessage());
}
AppendSerializtionError exception =
new AppendSerializtionError(
AppendSerializationError exception =
new AppendSerializationError(
response.getError().getCode(),
response.getError().getMessage(),
streamName,
Expand Down
Expand Up @@ -216,10 +216,8 @@ public static StorageException toStorageException(Throwable exception) {
}

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

/**
* This exception is thrown from {@link JsonStreamWriter#append()} when the client side Json to
* Proto serializtion fails. It can also be thrown by the server in case rows contains invalid
* data. The exception contains a Map of indexes of faulty rows and the corresponding error
* message.
*/
public static class AppendSerializationError extends AppendSerializtionError {

public AppendSerializationError(
int codeValue,
String description,
String streamName,
Map<Integer, String> rowIndexToErrorMessage) {
super(codeValue, description, streamName, rowIndexToErrorMessage);
}
}

/** This exception is used internally to handle field level parsing errors. */
public static class FieldParseError extends IllegalArgumentException {
private final String fieldName;
Expand Down
Expand Up @@ -20,7 +20,7 @@
import com.google.api.gax.core.CredentialsProvider;
import com.google.api.gax.core.ExecutorProvider;
import com.google.api.gax.rpc.TransportChannelProvider;
import com.google.cloud.bigquery.storage.v1.Exceptions.AppendSerializtionError;
import com.google.cloud.bigquery.storage.v1.Exceptions.AppendSerializationError;
import com.google.common.base.Preconditions;
import com.google.protobuf.Descriptors;
import com.google.protobuf.Descriptors.Descriptor;
Expand Down Expand Up @@ -194,7 +194,8 @@ public ApiFuture<AppendRowsResponse> append(JSONArray jsonArr, long offset)
// Any error in convertJsonToProtoMessage will throw an
// IllegalArgumentException/IllegalStateException/NullPointerException.
// IllegalArgumentException will be collected into a Map of row indexes to error messages.
// After the conversion is finished an AppendSerializtionError exception that contains all the
// After the conversion is finished an AppendSerializationError exception that contains all
// the
// conversion errors will be thrown.
long currentRequestSize = 0;
Map<Integer, String> rowIndexToErrorMessage = new HashMap<>();
Expand Down Expand Up @@ -224,7 +225,7 @@ public ApiFuture<AppendRowsResponse> append(JSONArray jsonArr, long offset)
}

if (!rowIndexToErrorMessage.isEmpty()) {
throw new AppendSerializtionError(
throw new AppendSerializationError(
Code.INVALID_ARGUMENT.getNumber(),
"Append serialization failed for writer: " + streamName,
streamName,
Expand Down
Expand Up @@ -36,7 +36,7 @@
import com.google.cloud.bigquery.storage.test.Test.RepetitionType;
import com.google.cloud.bigquery.storage.test.Test.UpdatedFooType;
import com.google.cloud.bigquery.storage.v1.ConnectionWorkerPool.Settings;
import com.google.cloud.bigquery.storage.v1.Exceptions.AppendSerializtionError;
import com.google.cloud.bigquery.storage.v1.Exceptions.AppendSerializationError;
import com.google.cloud.bigquery.storage.v1.TableFieldSchema.Mode;
import com.google.protobuf.ByteString;
import com.google.protobuf.Descriptors.DescriptorValidationException;
Expand Down Expand Up @@ -1096,7 +1096,7 @@ public void testWithoutIgnoreUnknownFieldsUpdateFail() throws Exception {
try {
ApiFuture<AppendRowsResponse> appendFuture = writer.append(jsonArr);
Assert.fail("expected ExecutionException");
} catch (AppendSerializtionError ex) {
} catch (AppendSerializationError ex) {
assertEquals(
"JSONObject has fields unknown to BigQuery: root.test_unknown.",
ex.getRowIndexToErrorMessage().get(1));
Expand Down Expand Up @@ -1188,7 +1188,7 @@ public void testFlowControlSettingNoLimitBehavior() throws Exception {
}

@Test
public void testMultipleAppendSerializtionErrors()
public void testMultipleAppendSerializationErrors()
throws DescriptorValidationException, IOException, InterruptedException {
FooType expectedProto = FooType.newBuilder().setFoo("allen").build();
JSONObject foo = new JSONObject();
Expand All @@ -1213,10 +1213,10 @@ public void testMultipleAppendSerializtionErrors()
getTestJsonStreamWriterBuilder(TEST_STREAM, TABLE_SCHEMA).build()) {
try {
ApiFuture<AppendRowsResponse> appendFuture = writer.append(jsonArr);
Assert.fail("expected AppendSerializtionError");
} catch (AppendSerializtionError appendSerializtionError) {
Assert.fail("expected AppendSerializationError");
} catch (AppendSerializationError appendSerializationError) {
Map<Integer, String> rowIndexToErrorMessage =
appendSerializtionError.getRowIndexToErrorMessage();
appendSerializationError.getRowIndexToErrorMessage();
assertEquals(2, rowIndexToErrorMessage.size());
assertEquals(
"JSONObject has fields unknown to BigQuery: root.not_foo.",
Expand Down Expand Up @@ -1253,10 +1253,10 @@ public void testBadStringToNumericRowError()
getTestJsonStreamWriterBuilder(TEST_STREAM, TABLE_SCHEMA).build()) {
try {
ApiFuture<AppendRowsResponse> appendFuture = writer.append(jsonArr);
Assert.fail("expected AppendSerializtionError");
} catch (AppendSerializtionError appendSerializtionError) {
Assert.fail("expected AppendSerializationError");
} catch (AppendSerializationError appendSerializationError) {
Map<Integer, String> rowIndexToErrorMessage =
appendSerializtionError.getRowIndexToErrorMessage();
appendSerializationError.getRowIndexToErrorMessage();
assertEquals(1, rowIndexToErrorMessage.size());
assertTrue(
rowIndexToErrorMessage
Expand Down
Expand Up @@ -28,7 +28,7 @@
import com.google.cloud.bigquery.Schema;
import com.google.cloud.bigquery.storage.test.Test.*;
import com.google.cloud.bigquery.storage.v1.*;
import com.google.cloud.bigquery.storage.v1.Exceptions.AppendSerializtionError;
import com.google.cloud.bigquery.storage.v1.Exceptions.AppendSerializationError;
import com.google.cloud.bigquery.storage.v1.Exceptions.OffsetAlreadyExists;
import com.google.cloud.bigquery.storage.v1.Exceptions.OffsetOutOfRange;
import com.google.cloud.bigquery.storage.v1.Exceptions.SchemaMismatchedException;
Expand Down Expand Up @@ -372,8 +372,8 @@ public void testRowErrors()
} catch (Throwable t) {
assertTrue(t instanceof ExecutionException);
t = t.getCause();
assertTrue(t instanceof AppendSerializtionError);
AppendSerializtionError e = (AppendSerializtionError) t;
assertTrue(t instanceof AppendSerializationError);
AppendSerializationError e = (AppendSerializationError) t;
LOG.info("Found row errors on stream: " + e.getStreamName());
assertEquals(
"Field foo: STRING(10) has maximum length 10 but got a value with length 12 on field foo.",
Expand Down
Expand Up @@ -28,7 +28,7 @@
import com.google.cloud.bigquery.storage.v1.AppendRowsResponse;
import com.google.cloud.bigquery.storage.v1.BigQueryWriteClient;
import com.google.cloud.bigquery.storage.v1.Exceptions;
import com.google.cloud.bigquery.storage.v1.Exceptions.AppendSerializtionError;
import com.google.cloud.bigquery.storage.v1.Exceptions.AppendSerializationError;
import com.google.cloud.bigquery.storage.v1.Exceptions.StorageException;
import com.google.cloud.bigquery.storage.v1.JsonStreamWriter;
import com.google.cloud.bigquery.storage.v1.TableName;
Expand Down Expand Up @@ -218,8 +218,8 @@ public void onFailure(Throwable throwable) {
}
}

if (throwable instanceof AppendSerializtionError) {
AppendSerializtionError ase = (AppendSerializtionError) throwable;
if (throwable instanceof AppendSerializationError) {
AppendSerializationError ase = (AppendSerializationError) throwable;
Map<Integer, String> rowIndexToErrorMessage = ase.getRowIndexToErrorMessage();
if (rowIndexToErrorMessage.size() > 0) {
// Omit the faulty rows
Expand Down

0 comments on commit e67e913

Please sign in to comment.