-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Implements group_by, projection and offset on datastore Query. #282
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
Implements group_by, projection and offset on datastore Query. #282
Conversation
|
How is this PR different from #281? |
|
From #281:
This PR has only the new features and none of the regression tests. |
8dcf9f4 to
104345a
Compare
|
Rebased after the Travis fix. @tseaver PTAL |
104345a to
8df6f41
Compare
|
Implementation LGTM, although I don't know these bits of the API at all. Does 'offset()' conflict with the cursor stuff? |
|
No, they are complimentary. We can get final sign-off from one of the datastore folks if you like? |
8df6f41 to
3d4ce5d
Compare
|
I still don't see why two keys, each with 'dataset_id == None' but having the same path, should be unequal (they are both in the "default" dataset for the application's connection). Likewise for when both keys have 'namespace == None' but the same path. |
|
They would both be equal. See The failures happen if (dataset as an example) if not (self._dataset_id == other._dataset_id or
self._dataset_id is None or other._dataset_id is None):which is equivalent to if (self._dataset_id != other._dataset_id and
self._dataset_id is not None and other._dataset_id is not None):In other words, failure only occurs if the values don't match AND both values are non-null. |
|
I don't understand why it isn't just: If they are both None, they will be equal; if either is not None but the other is, they won't be equal. None compares for equality fine with arbitrary objects. |
To give a simplified idea of what is happening in >>> import regression.regression_utils
>>> dataset = regression.regression_utils.get_dataset()
>>> entity = dataset.entity(kind='SomeKind')
>>> entity['key'] = 'value'
>>> key = entity.key().name('some_name') # Same for partial key or key id.
>>> entity = entity.key(key)
>>> entity.save()
<Entity[{'kind': 'SomeKind', 'name': 'some_name'}] {'key': 'value'}>
>>> retrieved_entity = dataset.get_entity(entity.key())then we'll have >>> entity.key().path()
[{'kind': 'SomeKind', 'name': 'some_name'}]
>>> retrieved_entity.key().path()
[{'kind': u'SomeKind', 'name': u'some_name'}]
>>>
>>> print entity.key()._dataset_id
None
>>> retrieved_entity.key()._dataset_id
u's~redacted-dataset-id'
>>>
>>> print entity.key()._namespace
None
>>> retrieved_entity.key()._namespace
u'' |
b61ba2e to
c27a8d5
Compare
c27a8d5 to
330ffc5
Compare
|
Rebased after #289. @tseaver does the explanation above make sense for allowing null values in
|
|
Yes, I see what you are trying to accomplish now. WRT the key's _datset_id, I'm not positive we want None to compare equal to one with an ID set by the back-end: it is sort of like comparing a naive datetime to a zoned one: they will be the same now, but later (if multi-dataset access comes into play) they might not be. WRT namespace: we could switch the default value from None to '', and then just compare them naturally. |
330ffc5 to
95528d2
Compare
This issue surfaced during review for googleapis#282.
|
@tseaver it turns out we weren't handling namespaces quite perfectly. See #292. As for dataset ID, the comment I added in To fully support this, we'd (at least) need to change A simple solution to this could be changing for entity_pb in entity_pbs:
entities.append(helpers.entity_from_protobuf(
entity_pb, dataset=self))to |
🤖 I have created a release \*beep\* \*boop\* --- ### [3.3.1](https://www.github.com/googleapis/python-dlp/compare/v3.3.0...v3.3.1) (2021-11-05) ### Bug Fixes * **deps:** drop packaging dependency ([84181e9](https://www.github.com/googleapis/python-dlp/commit/84181e971ee04b46a603119d44410816fd7f04be)) * **deps:** require google-api-core >= 1.28.0 ([84181e9](https://www.github.com/googleapis/python-dlp/commit/84181e971ee04b46a603119d44410816fd7f04be)) * fix extras_require typo in setup.py ([84181e9](https://www.github.com/googleapis/python-dlp/commit/84181e971ee04b46a603119d44410816fd7f04be)) ### Documentation * list oneofs in docstring ([84181e9](https://www.github.com/googleapis/python-dlp/commit/84181e971ee04b46a603119d44410816fd7f04be)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
* chore: Update gapic-generator-python to v1.11.2 PiperOrigin-RevId: 546510849 Source-Link: googleapis/googleapis@736073a Source-Link: googleapis/googleapis-gen@deb64e8 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZGViNjRlOGVjMTlkMTQxZTMxMDg5ZmU5MzJiM2E5OTdhZDU0MWM0ZCJ9 * 🦉 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>
Source-Link: googleapis/synthtool@56da63e Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:993a058718e84a82fda04c3177e58f0a43281a996c7c395e0a56ccc4d6d210d7
fix(deps): require proto-plus>=1.15.0
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
This adds region tags in order to support the Cloud Code API Explorer pilot
🤖 I have created a release \*beep\* \*boop\* --- ### [3.6.1](https://www.github.com/googleapis/python-translate/compare/v3.6.0...v3.6.1) (2021-11-04) ### Bug Fixes * **deps:** drop packaging dependency ([7924322](https://www.github.com/googleapis/python-translate/commit/79243222e5e16e1b7cb50b9d69862ddf6023ad4f)) * **deps:** require google-api-core >= 1.28.0 ([7924322](https://www.github.com/googleapis/python-translate/commit/79243222e5e16e1b7cb50b9d69862ddf6023ad4f)) ### Documentation * list oneofs in docstring ([7924322](https://www.github.com/googleapis/python-translate/commit/79243222e5e16e1b7cb50b9d69862ddf6023ad4f)) * **samples:** Add Cloud Code tags for API Explorer pilot ([#282](https://www.github.com/googleapis/python-translate/issues/282)) ([3e8df68](https://www.github.com/googleapis/python-translate/commit/3e8df6836f0508fb4c6cd1c4a9f2f39192a01cea)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Source-Link: https://togithub.com/googleapis/synthtool/commit/352b9d4c068ce7c05908172af128b294073bf53c Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:3e3800bb100af5d7f9e810d48212b37812c1856d20ffeafb99ebe66461b61fc7
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
#282) Tests were failing because the `str` method for the context returned by `pytest.raises` no longer prints the contained exception. Instead, use `match=regex_value` to check for the desired error message.
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Daniel Sanche <[email protected]>
add test cases for interceptor
…p/templates/python_library/.kokoro (#282) Source-Link: googleapis/synthtool@d0f51a0 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:240b5bcc2bafd450912d2da2be15e62bc6de2cf839823ae4bf94d4f392b451dc Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
…282) * chore: add default_version and codeowner_team to .repo-metadata.json * Assign @googleapis/actools-python as codeowner
… and bigquery (#282) * chore(deps): update dependency charset-normalizer to v2.0.4 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore(deps): update dependency google-cloud-bigquery-storage to v2.6.3 * chore(deps): update dependency google-resumable-media to v1.3.3 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore(deps): update dependency greenlet to v1.1.1 * chore(deps): update dependency importlib-metadata to v4.6.4 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore(deps): update dependency libcst to v0.3.20 * chore(deps): update dependency pybigquery to v0.10.1 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore(deps): update dependency dataclasses to v0.8 * chore(deps): update dependency google-auth to v1.35.0 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore(deps): update dependency google-cloud-bigquery to v2.24.0 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore(deps): update dependency numpy to v1.21.2 * chore(deps): update dependency pandas to v1.3.2 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore(deps): update dependency pyproj to v3.1.0 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore(deps): update dependency google-auth to v2 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * Update requirements.txt * minor sorting * chore(deps): update dependency sqlalchemy to v1.4.23 * Use older pyproj for Python 3.6 * Use older version of pandas for Python 3.6 * Use older numpy for Python 3.6 * Use older dataclasses for Python 3.8 and earlier * Don't need dataclasses for 3.7 and later, as they're in the standard library * chore(deps): update dependency google-api-core to v2 * chore(deps): update dependency google-cloud-core to v2 * require google-cloud-bigquery 2.24.1 (or greater) * Include tests dependencies in noxfile * Include tests dependencies in noxfile for compliance tests Co-authored-by: Renovate Bot <[email protected]> Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
* feat: add support for IN/NOT_IN/!= operator * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * chore: fix tests * chore: fix tests Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <[email protected]>
Source-Link: googleapis/synthtool@9ae0785 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:52210e0e0559f5ea8c52be148b33504022e1faef4e95fbe4b32d68022af2fa7e Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Lingqing Gan <[email protected]>
Source-Link: googleapis/synthtool@9ae0785 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:52210e0e0559f5ea8c52be148b33504022e1faef4e95fbe4b32d68022af2fa7e Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
In addition,
__eq__was implemented on datastore.key.Key to allow for easy comparison.See #281 for some context. As mentioned there, I looked and didn't see any equivalent bugs for these features.