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: implement query options versioning support #30
Conversation
|
||
@mock.patch("google.cloud.spanner_v1.client.os.getenv") | ||
@mock.patch("google.cloud.spanner_v1.client._get_spanner_emulator_host") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why there's a diff for _get_spanner_emulator_host
in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both emulator support and query options support rely on calling os.getenv
which means it's more difficult to set up the mock. The os.getenv
call for emulator is made in _get_spanner_emulator_host
which means mocking that function instead is much more clear and avoids setting up theos.getenv
mock.
google/cloud/spanner_v1/client.py
Outdated
@@ -62,6 +63,7 @@ | |||
"without a scheme: ex %s=localhost:8080." | |||
) % ((EMULATOR_ENV_VAR,) * 3) | |||
SPANNER_ADMIN_SCOPE = "https://www.googleapis.com/auth/spanner.admin" | |||
OPTIMIZER_VERSION_VAR = "SPANNER_OPTIMIZER_VERSION" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably use OPTIMIZER_VERSION_ENV_VAR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Major concerns:
- Does
query_options
support bothExecuteSqlRequest.QueryOptions
anddict
everywhere? It needs to be clear in the doc comment. - Does
partition_query
supportquery_options
as well? - Nits: the merge function can be more generic for future extension. This can be done in the future when we add new fields in
query_options
.
For the rest, LGTM, 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to confirm that we're going with SPANNER_OPTIMIZER_VERSION to be consistent with the query hint name. I think your implementation already uses this name but just wanted to make sure.
@hengfengli |
Actually, I mean this method |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
49a422f
to
4e16212
Compare
Adds support for QueryOptions.
The QueryOptions are set in one of three ways (in ascending order of precedence):
If the backend implements query hints, for example, to instruct the backend which query optimizer version to use, these query hints will also automatically be supported.