From d972551e2d59b215b0cefa4e0ee756fe28c1e5c7 Mon Sep 17 00:00:00 2001 From: Alvaro Viebrantz Date: Wed, 23 Aug 2023 17:13:23 -0400 Subject: [PATCH 1/2] feat(bigquery): set PreferredMinStreamCount when creating read session --- bigquery/storage_client.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bigquery/storage_client.go b/bigquery/storage_client.go index aa04e2100883..b207527c73b1 100644 --- a/bigquery/storage_client.go +++ b/bigquery/storage_client.go @@ -135,13 +135,19 @@ type readSession struct { // Start initiates a read session func (rs *readSession) start() error { + preferredMinStreamCount := int32(0) + maxStreamCount := int32(rs.settings.maxStreamCount) + if maxStreamCount == 0 { + preferredMinStreamCount = int32(rs.settings.maxWorkerCount) + } createReadSessionRequest := &storagepb.CreateReadSessionRequest{ Parent: fmt.Sprintf("projects/%s", rs.table.ProjectID), ReadSession: &storagepb.ReadSession{ Table: rs.tableID, DataFormat: storagepb.DataFormat_ARROW, }, - MaxStreamCount: int32(rs.settings.maxStreamCount), + MaxStreamCount: maxStreamCount, + PreferredMinStreamCount: preferredMinStreamCount, } rpcOpts := gax.WithGRPCOptions( // Read API can send batches up to 128MB From f5c335ee0ce7dbd1e890af0c9cbc7fbe67e77b3d Mon Sep 17 00:00:00 2001 From: Alvaro Viebrantz Date: Tue, 29 Aug 2023 15:15:39 -0400 Subject: [PATCH 2/2] fix(bigquery): better style on declaring variable with default value --- bigquery/storage_client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bigquery/storage_client.go b/bigquery/storage_client.go index b207527c73b1..12b7702250f7 100644 --- a/bigquery/storage_client.go +++ b/bigquery/storage_client.go @@ -135,7 +135,7 @@ type readSession struct { // Start initiates a read session func (rs *readSession) start() error { - preferredMinStreamCount := int32(0) + var preferredMinStreamCount int32 maxStreamCount := int32(rs.settings.maxStreamCount) if maxStreamCount == 0 { preferredMinStreamCount = int32(rs.settings.maxWorkerCount)