Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: accept default stream name #2432

Merged
merged 2 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,20 @@ If you are using Maven without the BOM, add this to your dependencies:
If you are using Gradle 5.x or later, add this to your dependencies:

```Groovy
implementation platform('com.google.cloud:libraries-bom:26.33.0')
implementation platform('com.google.cloud:libraries-bom:26.34.0')

implementation 'com.google.cloud:google-cloud-bigquerystorage'
```
If you are using Gradle without BOM, add this to your dependencies:

```Groovy
implementation 'com.google.cloud:google-cloud-bigquerystorage:3.3.0'
implementation 'com.google.cloud:google-cloud-bigquerystorage:3.3.1'
```

If you are using SBT, add this to your dependencies:

```Scala
libraryDependencies += "com.google.cloud" % "google-cloud-bigquerystorage" % "3.3.0"
libraryDependencies += "com.google.cloud" % "google-cloud-bigquerystorage" % "3.3.1"
```
<!-- {x-version-update-end} -->

Expand Down Expand Up @@ -221,7 +221,7 @@ Java is a registered trademark of Oracle and/or its affiliates.
[kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-bigquerystorage/java11.html
[stability-image]: https://img.shields.io/badge/stability-stable-green
[maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-bigquerystorage.svg
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-bigquerystorage/3.3.0
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-bigquerystorage/3.3.1
[authentication]: https://github.com/googleapis/google-cloud-java#authentication
[auth-scopes]: https://developers.google.com/identity/protocols/oauth2/scopes
[predefined-iam-roles]: https://cloud.google.com/iam/docs/understanding-roles#predefined_roles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ private static StorageError toStorageError(com.google.rpc.Status rpcStatus) {
@Nullable
public static StorageException toStorageException(
com.google.rpc.Status rpcStatus, Throwable exception) {
if (rpcStatus == null) {
return null;
}
StorageError error = toStorageError(rpcStatus);
Status grpcStatus =
Status.fromCodeValue(rpcStatus.getCode()).withDescription(rpcStatus.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,8 @@ private Builder(

if (!tableMatcher.matches() && !defaultStreamMatcher.matches()) {
throw new IllegalArgumentException("Invalid name: " + streamOrTableName);
} else if (!tableMatcher.matches() && defaultStreamMatcher.matches()) {
this.streamName = streamOrTableName;
} else {
this.streamName = streamOrTableName + "/_default";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public class JsonStreamWriterTest {
private static final String TEST_STREAM = "projects/p/datasets/d/tables/t/streams/_default";
private static final String TEST_STREAM_2 = "projects/p/datasets/d2/tables/t2/streams/_default";
private static final String TEST_TABLE = "projects/p/datasets/d/tables/t";
private static final String TEST_TABLE_DEFAULT = "projects/p/datasets/d/tables/t/_default";
private static LocalChannelProvider channelProvider;
private FakeScheduledExecutorService fakeExecutor;
private FakeBigQueryWrite testBigQueryWrite;
Expand Down Expand Up @@ -198,6 +199,14 @@ public void testTwoParamNewBuilder()
assertEquals(TEST_STREAM, writer.getStreamName());
}

@Test
public void testConstructWriterUsingDefaultStreamName()
throws DescriptorValidationException, IOException, InterruptedException {
JsonStreamWriter writer =
agrawal-siddharth marked this conversation as resolved.
Show resolved Hide resolved
getTestJsonStreamWriterBuilder(TEST_TABLE_DEFAULT, TABLE_SCHEMA).build();
assertEquals(TEST_TABLE_DEFAULT, writer.getStreamName());
}

@Test
public void testSingleAppendSimpleJson() throws Exception {
FooType expectedProto = FooType.newBuilder().setFoo("allen").build();
Expand Down
Loading