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

ReadOptions support for 'Connection.lookup', 'Connection.run_query' #305

Closed
tseaver opened this issue Oct 28, 2014 · 5 comments · Fixed by #449
Closed

ReadOptions support for 'Connection.lookup', 'Connection.run_query' #305

tseaver opened this issue Oct 28, 2014 · 5 comments · Fixed by #449
Assignees
Labels
api: datastore Issues related to the Datastore API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@tseaver
Copy link
Contributor

tseaver commented Oct 28, 2014

The protobuf specs for the lookup RPC and the runQuery RPC show an optional 'read_options' field, which denominate the consistency level and optional transaction to be used. Do we need to support this field?

@tseaver tseaver added type: question Request for information or clarification. Not an issue. api: datastore Issues related to the Datastore API. labels Oct 28, 2014
@tseaver
Copy link
Contributor Author

tseaver commented Oct 28, 2014

FWIW, the protobuf spec for the ReadOptions message says:

// The read consistency to use.
// Cannot be set when transaction is set.
// Lookup and ancestor queries default to STRONG, global queries default to
// EVENTUAL and cannot be set to STRONG.

Connection.lookup() would thus resemble:

def lookup(self, dataset_id, key_pbs, transaction=None, eventual=False):
    ...
  • If transaction was passed, we would copy it onto the ReadOpttions.transaction field.
  • Otherwise, if eventual were True, we would set the enum value onto the ReadOptions.read_consistency field.

We would need to update Dataset.get_entities to allow passing transaction and eventual through to Connection.lookup.

Likewise, Connection.run_query would resemble:

def run_query(self, dataset_id, query_pb, namespace=None,
              transaction=None, read_consistency=None):
    ...
  • If transaction was passed, we would copy it onto the ReadOpttions.transaction field.
  • Otherwise, if read_consistency were not-none (one of "STRONG" or "EVENTUAL"), we would set the corresponding enum value onto the ReadOptions.read_consistency field. We would not try to pre-enforce the semantics described in the protobuf spec.

We would need to update Query.fetch to allow passing transaction and read_consistency through to Connection.run_query.

@silvolu
Copy link
Contributor

silvolu commented Oct 28, 2014

Sounds good to me. 2 questions:

  • In Connection.lookup and Connection.run_query, should the default value for transaction be the value of the Connection's object transaction, so that if we are already inside a transaction, it's automatically applied ?
  • In Dataset.get_entities and Query.fetch, should we raise an error if a transaction and eventual=True are passed, or silently ignore it and favor one of the two options?

@tseaver
Copy link
Contributor Author

tseaver commented Oct 28, 2014

IRT the first question, that sounds sensible to me (and most like what a user would expect).

For the second, we might need to rely on having the Connection methods raise an exception (since the allowed values would depend on whether a transaction was active).

@silvolu
Copy link
Contributor

silvolu commented Oct 28, 2014

Cool, SGTM.

@tseaver tseaver removed the type: question Request for information or clarification. Not an issue. label Dec 17, 2014
@tseaver tseaver self-assigned this Dec 17, 2014
@tseaver
Copy link
Contributor Author

tseaver commented Dec 17, 2014

I think maybe we leave transaction out of the signature of Connection.lookup and Query.fetch: if the connection already has a transaction, then we just use it (and raise an error if eventual is passed). Otherwise, if eventual is passed we set the flag on the request.

I don't know if we should be trying to pre-enforce that STRONG is incompatible with queries that are not ancestor-based. I'm assuming that the back-end returns an error if the QueryRequest protobuf contains it with a non-ancestor filter.

@tseaver tseaver added the type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. label Dec 19, 2014
@jgeewax jgeewax modified the milestone: Datastore Stable Jan 30, 2015
parthea pushed a commit that referenced this issue Jun 4, 2023
Source-Link: https://togithub.com/googleapis/synthtool/commit/30bd01b4ab78bf1b2a425816e15b3e7e090993dd
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:9bc5fa3b62b091f60614c08a7fb4fd1d3e1678e326f34dd66ce1eefb5dc3267b
parthea pushed a commit that referenced this issue Jun 4, 2023
Source-Link: googleapis/synthtool@993985f
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:1894490910e891a385484514b22eb5133578897eb5b3c380e6d8ad475c6647cd
parthea added a commit that referenced this issue Jun 4, 2023
parthea pushed a commit that referenced this issue Jun 4, 2023
Source-Link: googleapis/synthtool@571ee2c
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:660abdf857d3ab9aabcd967c163c70e657fcc5653595c709263af5f3fa23ef67
parthea added a commit that referenced this issue Jun 4, 2023
* fix(deps): allow protobuf 3.19.5

* explicitly exclude protobuf 4.21.0
parthea pushed a commit that referenced this issue Jun 4, 2023
Source-Link: https://togithub.com/googleapis/synthtool/commit/26c7505b2f76981ec1707b851e1595c8c06e90fc
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:f946c75373c2b0040e8e318c5e85d0cf46bc6e61d0a01f3ef94d8de974ac6790
parthea pushed a commit that referenced this issue Jun 4, 2023
Follow-up on #305 — send cl/520747639 to address sample includes, so do not merge until snippetbot is happy. Thanks!
parthea pushed a commit that referenced this issue Jun 4, 2023
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
parthea added a commit that referenced this issue Jul 6, 2023
* chore(python): add nox session to sort python imports

Source-Link: googleapis/synthtool@1b71c10
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:00c9d764fd1cd56265f12a5ef4b99a0c9e87cf261018099141e2ca5158890416

* revert change to region tag

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <[email protected]>
parthea added a commit that referenced this issue Sep 20, 2023
vchudnov-g pushed a commit that referenced this issue Sep 20, 2023
parthea pushed a commit that referenced this issue Sep 22, 2023
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this issue Sep 22, 2023
- [ ] Regenerate this pull request now.

PiperOrigin-RevId: 472561635

Source-Link: googleapis/googleapis@332ecf5

Source-Link: googleapis/googleapis-gen@4313d68
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDMxM2Q2ODI4ODBmZDlkNzI0NzI5MTE2NGQ0ZTlkM2Q1YmQ5ZjE3NyJ9
parthea added a commit that referenced this issue Sep 22, 2023
* fix(deps): allow protobuf 3.19.5

* explicitly exclude protobuf 4.21.0
parthea pushed a commit that referenced this issue Sep 22, 2023
* chore: use gapic-generator-python 0.58.4

fix: provide appropriate mock values for message body fields

committer: dovs
PiperOrigin-RevId: 419025932

Source-Link: googleapis/googleapis@73da669

Source-Link: googleapis/googleapis-gen@46df624
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDZkZjYyNGE1NGI5ZWQ0N2MxYTdlZWZiN2E0OTQxM2NmN2I4MmY5OCJ9

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this issue Oct 21, 2023
Source-Link: googleapis/synthtool@1b9ad76
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:9db98b055a7f8bd82351238ccaacfd3cda58cdf73012ab58b8da146368330021
parthea added a commit that referenced this issue Oct 21, 2023
parthea pushed a commit that referenced this issue Oct 21, 2023
Source-Link: googleapis/synthtool@d2871d9
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:b2dc5f80edcf5d4486c39068c9fa11f7f851d9568eea4dcba130f994ea9b5e97

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the Datastore API. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants