Guest User

Untitled

a guest
Jul 20th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. import apache_beam as beam
  2.  
  3. from apache_beam.io.gcp.datastore.v1.datastoreio import ReadFromDatastore
  4. from google.cloud.proto.datastore.v1 import query_pb2
  5.  
  6. from googledatastore import helper as datastore_helper
  7. from googledatastore import PropertyFilter
  8.  
  9.  
  10. p = beam.Pipeline(options=pipeline_options)
  11.  
  12. # Create a query and filter by kind
  13. query = query_pb2.Query()
  14. query.kind.add().name = 'EntityKind'
  15.  
  16. # Read just the entry with a specific __key__ property
  17. datastore_helper.set_property_filter(query.filter, '__key__', PropertyFilter.EQUALS, key)
  18.  
  19. result = p | ReadFromDatastore(project=PROJECT_ID, query=query)
Add Comment
Please, Sign In to add comment