Skip to content

Commit c321756

Browse files
Merge branch 'main' into authorized_views
2 parents 7ba0f50 + 89b8da8 commit c321756

File tree

21 files changed

+444
-50
lines changed

21 files changed

+444
-50
lines changed

.github/.OwlBot.lock.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
# limitations under the License.
1414
docker:
1515
image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest
16-
digest: sha256:a1c5112b81d645f5bbc4d4bbc99d7dcb5089a52216c0e3fb1203a0eeabadd7d5
17-
# created: 2025-01-02T23:09:36.975468657Z
16+
digest: sha256:8ff1efe878e18bd82a0fb7b70bb86f77e7ab6901fed394440b6135db0ba8d84a
17+
# created: 2025-01-09T12:01:16.422459506Z

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "2.28.0"
2+
".": "2.28.1"
33
}

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44

55
[1]: https://pypi.org/project/google-cloud-bigtable/#history
66

7+
## [2.28.1](https://github.com/googleapis/python-bigtable/compare/v2.28.0...v2.28.1) (2025-01-17)
8+
9+
10+
### Bug Fixes
11+
12+
* Allow empty headers for btql routing ([#1072](https://github.com/googleapis/python-bigtable/issues/1072)) ([e7ecfeb](https://github.com/googleapis/python-bigtable/commit/e7ecfeb8984a45c880d9483305964fff347eb4b8))
13+
714
## [2.28.0](https://github.com/googleapis/python-bigtable/compare/v2.27.0...v2.28.0) (2025-01-08)
815

916

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,8 @@ async def execute_query(
645645
will be chained with a RetryExceptionGroup containing GoogleAPIError exceptions
646646
from any retries that failed
647647
google.api_core.exceptions.GoogleAPIError: raised if the request encounters an unrecoverable error
648+
google.cloud.bigtable.data.exceptions.ParameterTypeInferenceFailed: Raised if
649+
a parameter is passed without an explicit type, and the type cannot be infered
648650
"""
649651
warnings.warn(
650652
"ExecuteQuery is in preview and may change in the future.",

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,8 @@ def execute_query(
489489
will be chained with a RetryExceptionGroup containing GoogleAPIError exceptions
490490
from any retries that failed
491491
google.api_core.exceptions.GoogleAPIError: raised if the request encounters an unrecoverable error
492+
google.cloud.bigtable.data.exceptions.ParameterTypeInferenceFailed: Raised if
493+
a parameter is passed without an explicit type, and the type cannot be infered
492494
"""
493495
warnings.warn(
494496
"ExecuteQuery is in preview and may change in the future.",

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
Tuple,
2323
TYPE_CHECKING,
2424
)
25-
2625
from google.api_core import retry as retries
2726

2827
from google.cloud.bigtable.data.execute_query._byte_cursor import _ByteCursor
@@ -116,7 +115,6 @@ def __init__(
116115
exception_factory=_retry_exception_factory,
117116
)
118117
self._req_metadata = req_metadata
119-
120118
try:
121119
self._register_instance_task = CrossSync.create_task(
122120
self._client._register_instance,

google/cloud/bigtable/data/execute_query/_parameters_formatting.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from typing import Any, Dict, Optional
1615
import datetime
16+
from typing import Any, Dict, Optional
17+
1718
from google.api_core.datetime_helpers import DatetimeWithNanoseconds
19+
1820
from google.cloud.bigtable.data.exceptions import ParameterTypeInferenceFailed
19-
from google.cloud.bigtable.data.execute_query.values import ExecuteQueryValueType
2021
from google.cloud.bigtable.data.execute_query.metadata import SqlType
22+
from google.cloud.bigtable.data.execute_query.values import ExecuteQueryValueType
2123

2224

2325
def _format_execute_query_params(
@@ -48,7 +50,6 @@ def _format_execute_query_params(
4850
parameter_types = parameter_types or {}
4951

5052
result_values = {}
51-
5253
for key, value in params.items():
5354
user_provided_type = parameter_types.get(key)
5455
try:
@@ -109,6 +110,16 @@ def _detect_type(value: ExecuteQueryValueType) -> SqlType.Type:
109110
"Cannot infer type of None, please provide the type manually."
110111
)
111112

113+
if isinstance(value, list):
114+
raise ParameterTypeInferenceFailed(
115+
"Cannot infer type of ARRAY parameters, please provide the type manually."
116+
)
117+
118+
if isinstance(value, float):
119+
raise ParameterTypeInferenceFailed(
120+
"Cannot infer type of float, must specify either FLOAT32 or FLOAT64 type manually."
121+
)
122+
112123
for field_type, type_dict in _TYPES_TO_TYPE_DICTS:
113124
if isinstance(value, field_type):
114125
return type_dict

google/cloud/bigtable/data/execute_query/_query_result_parsing_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
SqlType.Bytes: "bytes_value",
2323
SqlType.String: "string_value",
2424
SqlType.Int64: "int_value",
25+
SqlType.Float32: "float_value",
2526
SqlType.Float64: "float_value",
2627
SqlType.Bool: "bool_value",
2728
SqlType.Timestamp: "timestamp_value",

google/cloud/bigtable/data/execute_query/metadata.py

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,16 @@
2121
"""
2222

2323
from collections import defaultdict
24-
from typing import (
25-
Optional,
26-
List,
27-
Dict,
28-
Set,
29-
Type,
30-
Union,
31-
Tuple,
32-
Any,
33-
)
24+
import datetime
25+
from typing import Any, Dict, List, Optional, Set, Tuple, Type, Union
26+
27+
from google.api_core.datetime_helpers import DatetimeWithNanoseconds
28+
from google.protobuf import timestamp_pb2 # type: ignore
29+
from google.type import date_pb2 # type: ignore
30+
3431
from google.cloud.bigtable.data.execute_query.values import _NamedList
3532
from google.cloud.bigtable_v2 import ResultSetMetadata
3633
from google.cloud.bigtable_v2 import Type as PBType
37-
from google.type import date_pb2 # type: ignore
38-
from google.protobuf import timestamp_pb2 # type: ignore
39-
from google.api_core.datetime_helpers import DatetimeWithNanoseconds
40-
import datetime
4134

4235

4336
class SqlType:
@@ -127,6 +120,8 @@ class Array(Type):
127120
def __init__(self, element_type: "SqlType.Type"):
128121
if isinstance(element_type, SqlType.Array):
129122
raise ValueError("Arrays of arrays are not supported.")
123+
if isinstance(element_type, SqlType.Map):
124+
raise ValueError("Arrays of Maps are not supported.")
130125
self._element_type = element_type
131126

132127
@property
@@ -140,10 +135,21 @@ def from_pb_type(cls, type_pb: Optional[PBType] = None) -> "SqlType.Array":
140135
return cls(_pb_type_to_metadata_type(type_pb.array_type.element_type))
141136

142137
def _to_value_pb_dict(self, value: Any):
143-
raise NotImplementedError("Array is not supported as a query parameter")
138+
if value is None:
139+
return {}
140+
141+
return {
142+
"array_value": {
143+
"values": [
144+
self.element_type._to_value_pb_dict(entry) for entry in value
145+
]
146+
}
147+
}
144148

145149
def _to_type_pb_dict(self) -> Dict[str, Any]:
146-
raise NotImplementedError("Array is not supported as a query parameter")
150+
return {
151+
"array_type": {"element_type": self.element_type._to_type_pb_dict()}
152+
}
147153

148154
def __eq__(self, other):
149155
return super().__eq__(other) and self.element_type == other.element_type
@@ -222,6 +228,13 @@ class Float64(Type):
222228
value_pb_dict_field_name = "float_value"
223229
type_field_name = "float64_type"
224230

231+
class Float32(Type):
232+
"""Float32 SQL type."""
233+
234+
expected_type = float
235+
value_pb_dict_field_name = "float_value"
236+
type_field_name = "float32_type"
237+
225238
class Bool(Type):
226239
"""Bool SQL type."""
227240

@@ -376,6 +389,7 @@ def _pb_metadata_to_metadata_types(
376389
"bytes_type": SqlType.Bytes,
377390
"string_type": SqlType.String,
378391
"int64_type": SqlType.Int64,
392+
"float32_type": SqlType.Float32,
379393
"float64_type": SqlType.Float64,
380394
"bool_type": SqlType.Bool,
381395
"timestamp_type": SqlType.Timestamp,

google/cloud/bigtable/gapic_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
__version__ = "2.28.0" # {x-release-please-version}
16+
__version__ = "2.28.1" # {x-release-please-version}

0 commit comments

Comments
 (0)