Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add trace_id for Read API #396

Merged
merged 4 commits into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions google/cloud/bigquery_storage_v1/types/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@ class ReadSession(proto.Message):
are completely consumed. This estimate is based
on metadata from the table which might be
incomplete or stale.
trace_id (str):
Optional. ID set by client to annotate a
session identity. This does not need to be
strictly unique, but instead the same ID should
be used to group logically connected sessions
(e.g. All using the same ID for all sessions
needed to complete a Spark SQL query is
reasonable).
Maximum length is 256 bytes.
"""

class TableModifiers(proto.Message):
Expand Down Expand Up @@ -154,6 +163,7 @@ class TableReadOptions(proto.Message):
read_options = proto.Field(proto.MESSAGE, number=8, message=TableReadOptions,)
streams = proto.RepeatedField(proto.MESSAGE, number=10, message="ReadStream",)
estimated_total_bytes_scanned = proto.Field(proto.INT64, number=12,)
trace_id = proto.Field(proto.STRING, number=13,)


class ReadStream(proto.Message):
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/gapic/bigquery_storage_v1/test_big_query_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,7 @@ def test_create_read_session(request_type, transport: str = "grpc"):
data_format=stream.DataFormat.AVRO,
table="table_value",
estimated_total_bytes_scanned=3076,
trace_id="trace_id_value",
avro_schema=avro.AvroSchema(schema="schema_value"),
)
response = client.create_read_session(request)
Expand All @@ -657,6 +658,7 @@ def test_create_read_session(request_type, transport: str = "grpc"):
assert response.data_format == stream.DataFormat.AVRO
assert response.table == "table_value"
assert response.estimated_total_bytes_scanned == 3076
assert response.trace_id == "trace_id_value"


def test_create_read_session_empty_call():
Expand Down Expand Up @@ -699,6 +701,7 @@ async def test_create_read_session_async(
data_format=stream.DataFormat.AVRO,
table="table_value",
estimated_total_bytes_scanned=3076,
trace_id="trace_id_value",
)
)
response = await client.create_read_session(request)
Expand All @@ -714,6 +717,7 @@ async def test_create_read_session_async(
assert response.data_format == stream.DataFormat.AVRO
assert response.table == "table_value"
assert response.estimated_total_bytes_scanned == 3076
assert response.trace_id == "trace_id_value"


@pytest.mark.asyncio
Expand Down