feat: async execute query client#1011
Conversation
Co-authored-by: Mateusz Walkiewicz <mwalkiewicz@unoperate.com>
|
Here is the summary of changes. You are about to add 1 region tag.
This comment is generated by snippet-bot.
|
|
|
||
|
|
||
| class ParameterTypeInferenceFailed(ValueError): | ||
| pass |
There was a problem hiding this comment.
nit: it would be good to have a docstring here
| ) | ||
|
|
||
|
|
||
| class ExecuteQueryIteratorAsync: |
| def __aiter__(self): | ||
| return self | ||
|
|
||
| async def metadata(self) -> Optional[Metadata]: |
There was a problem hiding this comment.
please add docstrings on all of these methods
| params: Optional[Dict[str, ExecuteQueryValueType]], | ||
| parameter_types: Optional[Dict[str, SqlType.Type]], | ||
| ): | ||
| if not params: |
There was a problem hiding this comment.
docstrings on these would also be helpful for future maintenance
It doesn't need to be too complex for the internal functions, but some context would be useful
|
|
||
|
|
||
| def _parse_array_type(value: PBValue, metadata_type: SqlType.Array) -> list: | ||
| return list( |
google/cloud/bigtable_v2/__init__.py
Outdated
| "SampleRowKeysRequest", | ||
| "SampleRowKeysResponse", | ||
| "ExecuteQueryRequest", | ||
| "ExecuteQueryResponse", |
There was a problem hiding this comment.
This file is autogenerated and doesn't need to be touched (These are already included in lines 87/88)
| @@ -0,0 +1,149 @@ | |||
| # Copyright 2024 Google LLC | |||
There was a problem hiding this comment.
Previously, the test files mirrored the structure of the source files. It might make sense to throw these into an execute_query directory?
|
FYI, you can ignore the failing samples tests. There's a quota issue in the samples project we're looking in to |
| ) | ||
|
|
||
| def _to_value_pb_dict(self, value: Any) -> dict: | ||
| def _to_value_pb_dict(self, value: Any) -> Any: |
There was a problem hiding this comment.
It's not too important, but do we have to use Any for these? Does dict[str, Any] not work?
| query = ( | ||
| "SELECT _key, os_build, connected_cell, connected_wifi " | ||
| f"from {table_id} WHERE _key=@row_key" | ||
| ) |
There was a problem hiding this comment.
I know I said to ignore the samples tests, but it looks like there's actually an issue here:
google.api_core.exceptions.InvalidArgument: 400 Syntax error: Missing whitespace between literal and alias [at 1:87]
There was a problem hiding this comment.
Also, there's a snippet lint issue that can be addressed using
cd samples/snippets/data_client
nox -s blacken
There was a problem hiding this comment.
To fix the invalid argument do: f"from `{table_id}` WHERE _key=@row_key" (wraps the table name in backticks)
There was a problem hiding this comment.
Daniel pointed out the column names here aren't working either. All of those are qualifiers.
We should update the first line of the query to SELECT _key, stats_summary['os_build'], stats_summary['connected_cell'], stats_summary['connected_wifi']
daniel-sanche
left a comment
There was a problem hiding this comment.
blocking until sample is addressed
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Description
This PR introduces support for the newly added
executeQueryRPC in the Bigtable async client.It handles executing parameterized queries and receiving streaming responses through an asynchronous iterator.
Most of the logic is located in
google.cloud.bigtable.data.execute_query.Example usage is in
samples/snippets/data_client/data_client_snippets_async.py