Skip to content

Commit d58a314

Browse files
Fix: accept default stream name (#2432)
* Fix: accept default stream name * 🦉 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>
1 parent d8a52f8 commit d58a314

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ If you are using Maven without the BOM, add this to your dependencies:
5050
If you are using Gradle 5.x or later, add this to your dependencies:
5151

5252
```Groovy
53-
implementation platform('com.google.cloud:libraries-bom:26.33.0')
53+
implementation platform('com.google.cloud:libraries-bom:26.34.0')
5454
5555
implementation 'com.google.cloud:google-cloud-bigquerystorage'
5656
```

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ private static StorageError toStorageError(com.google.rpc.Status rpcStatus) {
150150
@Nullable
151151
public static StorageException toStorageException(
152152
com.google.rpc.Status rpcStatus, Throwable exception) {
153+
if (rpcStatus == null) {
154+
return null;
155+
}
153156
StorageError error = toStorageError(rpcStatus);
154157
Status grpcStatus =
155158
Status.fromCodeValue(rpcStatus.getCode()).withDescription(rpcStatus.getMessage());

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,8 @@ private Builder(
467467

468468
if (!tableMatcher.matches() && !defaultStreamMatcher.matches()) {
469469
throw new IllegalArgumentException("Invalid name: " + streamOrTableName);
470+
} else if (!tableMatcher.matches() && defaultStreamMatcher.matches()) {
471+
this.streamName = streamOrTableName;
470472
} else {
471473
this.streamName = streamOrTableName + "/_default";
472474
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public class JsonStreamWriterTest {
7272
private static final String TEST_STREAM = "projects/p/datasets/d/tables/t/streams/_default";
7373
private static final String TEST_STREAM_2 = "projects/p/datasets/d2/tables/t2/streams/_default";
7474
private static final String TEST_TABLE = "projects/p/datasets/d/tables/t";
75+
private static final String TEST_TABLE_DEFAULT = "projects/p/datasets/d/tables/t/_default";
7576
private static LocalChannelProvider channelProvider;
7677
private FakeScheduledExecutorService fakeExecutor;
7778
private FakeBigQueryWrite testBigQueryWrite;
@@ -198,6 +199,14 @@ public void testTwoParamNewBuilder()
198199
assertEquals(TEST_STREAM, writer.getStreamName());
199200
}
200201

202+
@Test
203+
public void testConstructWriterUsingDefaultStreamName()
204+
throws DescriptorValidationException, IOException, InterruptedException {
205+
JsonStreamWriter writer =
206+
getTestJsonStreamWriterBuilder(TEST_TABLE_DEFAULT, TABLE_SCHEMA).build();
207+
assertEquals(TEST_TABLE_DEFAULT, writer.getStreamName());
208+
}
209+
201210
@Test
202211
public void testSingleAppendSimpleJson() throws Exception {
203212
FooType expectedProto = FooType.newBuilder().setFoo("allen").build();

0 commit comments

Comments
 (0)