Skip to content

Commit fe9c3ae

Browse files
authored
feat: provide the default stream name (#2444)
1 parent 6e267fb commit fe9c3ae

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,11 @@ public static void setMaxRequestCallbackWaitTime(Duration waitTime) {
561561
ConnectionWorker.MAXIMUM_REQUEST_CALLBACK_WAIT_TIME = waitTime;
562562
}
563563

564+
/** @return the default stream name associated with tableName */
565+
public static String getDefaultStreamName(TableName tableName) {
566+
return tableName + defaultStreamMatching;
567+
}
568+
564569
long getCreationTimestamp() {
565570
return creationTimestamp;
566571
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2224,4 +2224,14 @@ public void testExclusiveAppendSuccessAndNonRetryableError() throws Exception {
22242224
Status.Code.INVALID_ARGUMENT,
22252225
((StatusRuntimeException) ex.getCause()).getStatus().getCode());
22262226
}
2227+
2228+
@Test
2229+
public void testGetDefaultStreamName() {
2230+
TableName tableName = TableName.of("projectId", "datasetId", "tableId");
2231+
2232+
String actualDefaultName = StreamWriter.getDefaultStreamName(tableName);
2233+
2234+
assertEquals(
2235+
"projects/projectId/datasets/datasetId/tables/tableId/_default", actualDefaultName);
2236+
}
22272237
}

0 commit comments

Comments
 (0)