Skip to content

feat: BigQuery Storage v1beta1 API migration guide#3338

Open
benhxy wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
benhxy:v1beta1
Open

feat: BigQuery Storage v1beta1 API migration guide#3338
benhxy wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
benhxy:v1beta1

Conversation

@benhxy

@benhxy benhxy commented Jun 22, 2026

Copy link
Copy Markdown

Fixes b/505001153. BigQuery Storage team is planning to deprecate v1beta1 API. This PR adds a migration guide from v1beta1 to v1.

@benhxy benhxy requested review from a team as code owners June 22, 2026 17:07
@product-auto-label product-auto-label Bot added the samples Issues that are directly related to samples. label Jun 22, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a migration guide for transitioning the BigQuery Storage API from v1beta1 to v1 in C#. The feedback focuses on making the C# code examples more idiomatic and robust. Key suggestions include using the strongly-typed TableName class instead of a raw string path, clarifying how ReadRowsStream relates to IAsyncEnumerable, and using var to avoid type ambiguity with System.IO.Stream.

Comment on lines +83 to +96
// Table path is now a string: projects/{project}/datasets/{dataset}/tables/{table}
string tablePath = "projects/bigquery-public-data/datasets/usa_names/tables/usa_1910_current";

ReadSession.Types.TableReadOptions readOptions = new ReadSession.Types.TableReadOptions();
readOptions.SelectedFields.Add("name");
readOptions.RowRestriction = "state = 'WA'";

// ReadSession holds the session configuration
ReadSession readSession = new ReadSession
{
Table = tablePath,
DataFormat = DataFormat.Avro, // Format renamed to DataFormat
ReadOptions = readOptions
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While you can use a string path for Table, Google Cloud .NET libraries provide a strongly-typed TableName class and a TableAsTableName property on ReadSession. This is more idiomatic, less error-prone, and matches the quickstart sample in this repository.

Suggested change
// Table path is now a string: projects/{project}/datasets/{dataset}/tables/{table}
string tablePath = "projects/bigquery-public-data/datasets/usa_names/tables/usa_1910_current";
ReadSession.Types.TableReadOptions readOptions = new ReadSession.Types.TableReadOptions();
readOptions.SelectedFields.Add("name");
readOptions.RowRestriction = "state = 'WA'";
// ReadSession holds the session configuration
ReadSession readSession = new ReadSession
{
Table = tablePath,
DataFormat = DataFormat.Avro, // Format renamed to DataFormat
ReadOptions = readOptions
};
// Table path can be a string or a strongly-typed TableName
var tableName = new Google.Api.Gax.ResourceNames.TableName("bigquery-public-data", "usa_names", "usa_1910_current");
ReadSession.Types.TableReadOptions readOptions = new ReadSession.Types.TableReadOptions();
readOptions.SelectedFields.Add("name");
readOptions.RowRestriction = "state = 'WA'";
// ReadSession holds the session configuration
ReadSession readSession = new ReadSession
{
TableAsTableName = tableName,
DataFormat = DataFormat.Avro, // Format renamed to DataFormat
ReadOptions = readOptions
};

Comment on lines +110 to +111
In C#, `ReadRows` returns a `ReadRowsStream` which implements `IAsyncEnumerable`
or similar, allowing async iteration.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

In C#, ReadRowsStream does not implement IAsyncEnumerable<T> directly. Instead, you call GetResponseStream() on it, which returns an AsyncResponseStream<T> that implements IAsyncEnumerable<T>. We should clarify this to avoid confusion.

Suggested change
In C#, `ReadRows` returns a `ReadRowsStream` which implements `IAsyncEnumerable`
or similar, allowing async iteration.
In C#, ReadRows returns a ReadRowsStream. Calling GetResponseStream() on it returns an AsyncResponseStream which implements IAsyncEnumerable, allowing async iteration.

using Google.Cloud.BigQuery.Storage.V1Beta1;
using System.Threading.Tasks;

Stream stream = session.Streams[0];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using Stream as an explicit type name can cause ambiguity with System.IO.Stream, which is very commonly imported in C# files dealing with data streams. Using var is more idiomatic and avoids namespace collisions.

Suggested change
Stream stream = session.Streams[0];
var stream = session.Streams[0];

using Google.Cloud.BigQuery.Storage.V1;
using System.Threading.Tasks;

ReadStream stream = session.Streams[0];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Similarly, using var here is more idiomatic and consistent with modern C# style guidelines, while also avoiding any potential namespace collisions.

Suggested change
ReadStream stream = session.Streams[0];
var stream = session.Streams[0];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant