Skip to content

Commit 97ed04b

Browse files
authored
feat: add AppendRowsStream to use write API from v1 endpoint (#309)
This is just a duplicate of the class in the v1beta2 endpoint. I see for reads we tried to be clever by using the v1 version from the v1beta2 endpoint, but it would be harder to do with the write API. The `initial_request_template` parameter means that we need to make sure for certain that we are using the generated types for the correct endpoint. Since "beta" is clearly in the endpoint and import name, I think leaving the v1beta2 writer module as-is, with additional features and fixes only added to v1 makes some sense. Alternatively, we could add some tests to ensure these classes stay in sync?
1 parent f3e84e7 commit 97ed04b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

bigquery_storage/snippets/append_rows_proto2.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
import datetime
2121
import decimal
2222

23-
from google.cloud import bigquery_storage_v1beta2
24-
from google.cloud.bigquery_storage_v1beta2 import types
25-
from google.cloud.bigquery_storage_v1beta2 import writer
23+
from google.cloud import bigquery_storage_v1
24+
from google.cloud.bigquery_storage_v1 import types
25+
from google.cloud.bigquery_storage_v1 import writer
2626
from google.protobuf import descriptor_pb2
2727

2828
# If you make updates to the sample_data.proto protocol buffers definition,
@@ -36,13 +36,13 @@
3636

3737
def append_rows_proto2(project_id: str, dataset_id: str, table_id: str):
3838
"""Create a write stream, write some sample data, and commit the stream."""
39-
write_client = bigquery_storage_v1beta2.BigQueryWriteClient()
39+
write_client = bigquery_storage_v1.BigQueryWriteClient()
4040
parent = write_client.table_path(project_id, dataset_id, table_id)
4141
write_stream = types.WriteStream()
4242

4343
# When creating the stream, choose the type. Use the PENDING type to wait
4444
# until the stream is committed before it is visible. See:
45-
# https://cloud.google.com/bigquery/docs/reference/storage/rpc/google.cloud.bigquery.storage.v1beta2#google.cloud.bigquery.storage.v1beta2.WriteStream.Type
45+
# https://cloud.google.com/bigquery/docs/reference/storage/rpc/google.cloud.bigquery.storage.v1#google.cloud.bigquery.storage.v1.WriteStream.Type
4646
write_stream.type_ = types.WriteStream.Type.PENDING
4747
write_stream = write_client.create_write_stream(
4848
parent=parent, write_stream=write_stream

0 commit comments

Comments
 (0)