[
https://issues.apache.org/jira/browse/BEAM-7577?focusedWorklogId=268112&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-268112
]
ASF GitHub Bot logged work on BEAM-7577:
----------------------------------------
Author: ASF GitHub Bot
Created on: 27/Jun/19 00:13
Start Date: 27/Jun/19 00:13
Worklog Time Spent: 10m
Work Description: udim commented on pull request #8950: [BEAM-7577] Allow
ValueProviders in Datastore Query filters
URL: https://github.com/apache/beam/pull/8950#discussion_r297913773
##########
File path: sdks/python/apache_beam/io/gcp/datastore/v1new/types_test.py
##########
@@ -134,6 +135,36 @@ def testQuery(self):
logging.info('query: %s', q) # Test __repr__()
+ def testRuntimeFilters(self):
+ filter_list = [
+ [(StaticValueProvider(str, 'property_name'), # Filter 1
+ StaticValueProvider(str, '='),
+ StaticValueProvider(str, 'value'))],
+ [(StaticValueProvider(str, 'property_name'), # Filter 2(1)
+ StaticValueProvider(str, '='),
+ StaticValueProvider(str, 'value')),
+ ('property_name', '=', 'value')], # Filter 2(2)
+ ]
+ for filters in filter_list:
+ projection = ['f1', 'f2']
+ order = projection
+ distinct_on = projection
+ ancestor_key = Key(['kind', 'id'], project=self._PROJECT)
+ q = Query(kind='kind', project=self._PROJECT, namespace=self._NAMESPACE,
+ ancestor=ancestor_key, filters=filters, projection=projection,
+ order=order, distinct_on=distinct_on)
+ cq = q._to_client_query(self._test_client)
Review comment:
This is testing `_set_runtime_filters` with itself.
Assuming all filter tuples have the same expected values, this test can be
written and simplified as:
```py
filter_list = [...]
expected_filter = ('property_name', '=', 'value')
for filters in filter_list:
...
q = ...
cq = ...
for _filter in cq.filters:
self.assertEqual(expected_filter, _filter)
```
(the other asserts are covered in `testQuery`, but you can keep them if you
want)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 268112)
Time Spent: 1h 10m (was: 1h)
> Allow the use of ValueProviders in
> datastore.v1new.datastoreio.ReadFromDatastore query
> --------------------------------------------------------------------------------------
>
> Key: BEAM-7577
> URL: https://issues.apache.org/jira/browse/BEAM-7577
> Project: Beam
> Issue Type: New Feature
> Components: io-python-gcp
> Affects Versions: 2.13.0
> Reporter: EDjur
> Priority: Minor
> Time Spent: 1h 10m
> Remaining Estimate: 0h
>
> The current implementation of ReadFromDatastore does not support specifying
> the query parameter at runtime. This could potentially be fixed through the
> usage of a ValueProvider to specify and build the Datastore query.
> Allowing specifying the query at runtime makes it easier to use dynamic
> queries in Dataflow templates. Currently, there is no way to have a Dataflow
> template that includes a dynamic query (such as filtering by a timestamp or
> similar).
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)