Skip to content

Commit e1fac0c

Browse files
committed
Update docstring
1 parent f65d45a commit e1fac0c

File tree

3 files changed

+74
-21
lines changed

3 files changed

+74
-21
lines changed

google/cloud/bigtable/data/_async/client.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -708,38 +708,42 @@ async def execute_query(
708708
If None, defaults to prepare_operation_timeout.
709709
prepare_retryable_errors: a list of errors that will be retried if encountered during prepareQuery.
710710
Defaults to 4 (DeadlineExceeded) and 14 (ServiceUnavailable)
711-
column_info:
712-
(Optional) A dictionary mapping column names to Protobuf message classes or EnumTypeWrapper objects.
711+
column_info: (Optional) A dictionary mapping column names to Protobuf message classes or EnumTypeWrapper objects.
713712
This dictionary provides the necessary type information for deserializing PROTO and
714713
ENUM column values from the query results. When an entry is provided
715714
for a PROTO or ENUM column, the client library will attempt to deserialize the raw data.
716715
717-
- For PROTO columns: The value in the dictionary should be the
718-
Protobuf Message class (e.g., `my_pb2.MyMessage`).
719-
- For ENUM columns: The value should be the Protobuf EnumTypeWrapper
720-
object (e.g., `my_pb2.MyEnum`).
716+
- For PROTO columns: The value in the dictionary should be the
717+
Protobuf Message class (e.g., ``my_pb2.MyMessage``).
718+
- For ENUM columns: The value should be the Protobuf EnumTypeWrapper
719+
object (e.g., ``my_pb2.MyEnum``).
720+
721+
Example::
721722
722-
Example:
723723
import my_pb2
724724
725725
column_info = {
726726
"my_proto_column": my_pb2.MyMessage,
727727
"my_enum_column": my_pb2.MyEnum
728728
}
729729
730-
If `column_info` is not provided, or if a specific column name is not found
730+
If ``column_info`` is not provided, or if a specific column name is not found
731731
in the dictionary, or if deserialization fails:
732+
732733
- PROTO columns will be returned as raw bytes.
733734
- ENUM columns will be returned as integers.
734735
735736
Note for Nested PROTO or ENUM Fields:
737+
736738
To specify types for PROTO or ENUM fields within STRUCTs or MAPs, use a dot-separated
737739
path from the top-level column name.
738-
- For STRUCTs: `struct_column_name.field_name`
739-
- For MAPs: `map_column_name.key` or `map_column_name.value` to specify types
740-
for the map keys or values, respectively.
741740
742-
Examples:
741+
- For STRUCTs: ``struct_column_name.field_name``
742+
- For MAPs: ``map_column_name.key`` or ``map_column_name.value`` to specify types
743+
for the map keys or values, respectively.
744+
745+
Example::
746+
743747
import my_pb2
744748
745749
column_info = {

google/cloud/bigtable/data/_sync_autogen/client.py

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
from google.api_core.exceptions import DeadlineExceeded
5050
from google.api_core.exceptions import ServiceUnavailable
5151
from google.api_core.exceptions import Aborted
52+
from google.protobuf.message import Message
53+
from google.protobuf.internal.enum_type_wrapper import EnumTypeWrapper
5254
import google.auth.credentials
5355
import google.auth._default
5456
from google.api_core import client_options as client_options_lib
@@ -485,7 +487,7 @@ def execute_query(
485487
DeadlineExceeded,
486488
ServiceUnavailable,
487489
),
488-
column_info: dict[str, Any] | None = None,
490+
column_info: dict[str, Message | EnumTypeWrapper] | None = None,
489491
) -> "ExecuteQueryIterator":
490492
"""Executes an SQL query on an instance.
491493
Returns an iterator to asynchronously stream back columns from selected rows.
@@ -533,13 +535,58 @@ def execute_query(
533535
If None, defaults to prepare_operation_timeout.
534536
prepare_retryable_errors: a list of errors that will be retried if encountered during prepareQuery.
535537
Defaults to 4 (DeadlineExceeded) and 14 (ServiceUnavailable)
536-
column_info: Dictionary with mappings between column names and additional column information.
537-
An object where column names as keys and custom objects as corresponding
538-
values for deserialization. It's specifically useful for data types like
539-
protobuf where deserialization logic is on user-specific code. When provided,
540-
the custom object enables deserialization of backend-received column data.
541-
If not provided, data remains serialized as bytes for Proto Messages and
542-
integer for Proto Enums.
538+
column_info: (Optional) A dictionary mapping column names to Protobuf message classes or EnumTypeWrapper objects.
539+
This dictionary provides the necessary type information for deserializing PROTO and
540+
ENUM column values from the query results. When an entry is provided
541+
for a PROTO or ENUM column, the client library will attempt to deserialize the raw data.
542+
543+
- For PROTO columns: The value in the dictionary should be the
544+
Protobuf Message class (e.g., ``my_pb2.MyMessage``).
545+
- For ENUM columns: The value should be the Protobuf EnumTypeWrapper
546+
object (e.g., ``my_pb2.MyEnum``).
547+
548+
Example::
549+
550+
import my_pb2
551+
552+
column_info = {
553+
"my_proto_column": my_pb2.MyMessage,
554+
"my_enum_column": my_pb2.MyEnum
555+
}
556+
557+
If ``column_info`` is not provided, or if a specific column name is not found
558+
in the dictionary, or if deserialization fails:
559+
560+
- PROTO columns will be returned as raw bytes.
561+
- ENUM columns will be returned as integers.
562+
563+
Note for Nested PROTO or ENUM Fields:
564+
565+
To specify types for PROTO or ENUM fields within STRUCTs or MAPs, use a dot-separated
566+
path from the top-level column name.
567+
568+
- For STRUCTs: ``struct_column_name.field_name``
569+
- For MAPs: ``map_column_name.key`` or ``map_column_name.value`` to specify types
570+
for the map keys or values, respectively.
571+
572+
Example::
573+
574+
import my_pb2
575+
576+
column_info = {
577+
# Top-level column
578+
"my_proto_column": my_pb2.MyMessage,
579+
"my_enum_column": my_pb2.MyEnum,
580+
581+
# Nested field in a STRUCT column named 'my_struct'
582+
"my_struct.nested_proto_field": my_pb2.OtherMessage,
583+
"my_struct.nested_enum_field": my_pb2.AnotherEnum,
584+
585+
# Nested field in a MAP column named 'my_map'
586+
"my_map.key": my_pb2.MapKeyEnum, # If map keys were enums
587+
"my_map.value": my_pb2.MapValueMessage,
588+
}
589+
543590
Returns:
544591
ExecuteQueryIterator: an asynchronous iterator that yields rows returned by the query
545592
Raises:

google/cloud/bigtable/data/execute_query/_sync_autogen/execute_query_iterator.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
from __future__ import annotations
1919
from typing import Any, Dict, Optional, Sequence, Tuple, TYPE_CHECKING
2020
from google.api_core import retry as retries
21+
from google.protobuf.message import Message
22+
from google.protobuf.internal.enum_type_wrapper import EnumTypeWrapper
2123
from google.cloud.bigtable.data.execute_query._byte_cursor import _ByteCursor
2224
from google.cloud.bigtable.data._helpers import (
2325
_attempt_timeout_generator,
@@ -63,7 +65,7 @@ def __init__(
6365
operation_timeout: float,
6466
req_metadata: Sequence[Tuple[str, str]] = (),
6567
retryable_excs: Sequence[type[Exception]] = (),
66-
column_info: Dict[str, Any] | None = None,
68+
column_info: dict[str, Message | EnumTypeWrapper] | None = None,
6769
) -> None:
6870
"""Collects responses from ExecuteQuery requests and parses them into QueryResultRows.
6971

0 commit comments

Comments
 (0)