Skip to content

Commit ee74230

Browse files
committed
feat: provide the default stream name
1 parent 4b1ff23 commit ee74230

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

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

+7
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,13 @@ public static void setMaxRequestCallbackWaitTime(Duration waitTime) {
560560
ConnectionWorker.MAXIMUM_REQUEST_CALLBACK_WAIT_TIME = waitTime;
561561
}
562562

563+
/**
564+
* @return the default stream name associated with tableName
565+
*/
566+
public static String getDefaultStreamName(TableName tableName) {
567+
return tableName + defaultStreamMatching;
568+
}
569+
563570
long getCreationTimestamp() {
564571
return creationTimestamp;
565572
}

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

+9
Original file line numberDiff line numberDiff line change
@@ -2224,4 +2224,13 @@ 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("projects/projectId/datasets/datasetId/tables/tableId/_default", actualDefaultName);
2235+
}
22272236
}

0 commit comments

Comments
 (0)