Skip to content

Commit

Permalink
feat!: use table name create default write stream issue fix (#2119)
Browse files Browse the repository at this point in the history
* no block table default stream name

* 🦉 Updates from OwlBot post-processor

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

* change 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>
  • Loading branch information
Le-Dai and gcf-owl-bot[bot] committed Jan 2, 2024
1 parent f150780 commit 91a2bec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Expand Up @@ -449,9 +449,11 @@ public static final class Builder<T> {
private static final String streamPatternString =
"(projects/[^/]+/datasets/[^/]+/tables/[^/]+)/streams/[^/]+";
private static final String tablePatternString = "(projects/[^/]+/datasets/[^/]+/tables/[^/]+)";
private static final String defaultStreamPatternString = tablePatternString + "/_default";

private static final Pattern streamPattern = Pattern.compile(streamPatternString);
private static final Pattern tablePattern = Pattern.compile(tablePatternString);
private static final Pattern defaultStreamPattern = Pattern.compile(defaultStreamPatternString);

/**
* Constructor for SchemaAwareStreamWriter's Builder
Expand All @@ -471,7 +473,9 @@ private Builder(
Matcher streamMatcher = streamPattern.matcher(streamOrTableName);
if (!streamMatcher.matches()) {
Matcher tableMatcher = tablePattern.matcher(streamOrTableName);
if (!tableMatcher.matches()) {
Matcher defaultStreamMatcher = defaultStreamPattern.matcher(streamOrTableName);

if (!tableMatcher.matches() && !defaultStreamMatcher.matches()) {
throw new IllegalArgumentException("Invalid name: " + streamOrTableName);
} else {
this.streamName = streamOrTableName + "/_default";
Expand Down
Expand Up @@ -641,6 +641,14 @@ public void testCreateDefaultStream_withNoClientPassedIn() throws Exception {
.build()) {
assertEquals("projects/p/datasets/d/tables/t/_default", writer.getStreamName());
assertEquals("aa", writer.getLocation());

JsonStreamWriter recreate =
JsonStreamWriter.newBuilder(writer.getStreamName(), tableSchema)
.setChannelProvider(channelProvider)
.setCredentialsProvider(NoCredentialsProvider.create())
.setExecutorProvider(InstantiatingExecutorProvider.newBuilder().build())
.setEnableConnectionPool(true)
.build();
}
}

Expand Down

0 comments on commit 91a2bec

Please sign in to comment.