看起来google已经发布了对从python中的数据流/beam查询数据存储的支持。我试图让它在本地运行,但我遇到了一些问题:
import apache_beam as beam
from apache_beam.io.datastore.v1.datastoreio import ReadFromDatastore
from gcloud import datastore
client = datastore.Client('my-project')
query = client.query(kind='Document')
options = get_options()
p = beam.Pipeline(options=options)
entities = p | 'read' >> ReadFromDatastore(project='my-project', query=query)
entities | 'write' >> beam.io.Write(beam.io.TextFileSink('gs://output.txt'))
p.run()这给了我一个
AttributeError: 'Query' object has no attribute 'HasField' [while running 'read/Split Query']我猜我传入了错误的查询对象(您可以从3-4 pip包导入数据存储),但我不知道应该传入哪一个。在测试中,他们通过了原生质。这就是我要用的吗?如果我必须使用protobuf来显示一个简单的示例查询,任何人都可以这样做吗?
发布于 2016-12-14 06:00:28
字数算例使用protobufs进行查询。
看来你需要这样的东西:
from google.datastore.v1 import query_pb2
...
query = query_pb2.Query()
query.kind.add().name = 'Document'https://stackoverflow.com/questions/41132204
复制相似问题