Skip to content

Commit ec560b1

Browse files
tswastparthea
authored andcommitted
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 8b77737 commit ec560b1

File tree

8 files changed

+604
-9
lines changed

8 files changed

+604
-9
lines changed

packages/google-cloud-bigquery-storage/google/cloud/bigquery_storage_v1/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ class BigQueryReadClient(client.BigQueryReadClient):
3030
__doc__ = client.BigQueryReadClient.__doc__
3131

3232

33+
class BigQueryWriteClient(client.BigQueryWriteClient):
34+
__doc__ = client.BigQueryWriteClient.__doc__
35+
36+
3337
__all__ = (
3438
# google.cloud.bigquery_storage_v1
3539
"__version__",

packages/google-cloud-bigquery-storage/google/cloud/bigquery_storage_v1/client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
from google.cloud.bigquery_storage_v1 import reader
2727
from google.cloud.bigquery_storage_v1.services import big_query_read
28+
from google.cloud.bigquery_storage_v1.services import big_query_write
2829

2930

3031
_SCOPES = (
@@ -135,3 +136,7 @@ def read_rows(
135136
offset,
136137
{"retry": retry, "timeout": timeout, "metadata": metadata},
137138
)
139+
140+
141+
class BigQueryWriteClient(big_query_write.BigQueryWriteClient):
142+
__doc__ = big_query_write.BigQueryWriteClient.__doc__
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
16+
class StreamClosedError(Exception):
17+
"""Operation not supported while stream is closed."""

0 commit comments

Comments
 (0)