Tadayasu Yotsu
Tadayasu Yotsu

Reputation: 159

Output data to Datastore with Entity by Google Cloud Client Library for Java

My pipeline store data to Datastore. When I used google api service to create entity object, there were not any compile error. As following page, I should Google Cloud Client Library instead of Google api service. https://developers.google.com/api-client-library/java/apis/datastore/v1beta2

So that I changed my code for using Google Cloud Client Library for Java. But a compile error is occured.

The method apply(PTransform,OutputT>) in the type PCollection is not applicable for the arguments (DatastoreV1.Write)

How can I solve the error?

Upvotes: 1

Views: 109

Answers (1)

Idrees Khan
Idrees Khan

Reputation: 107

You should be using DatastoreIO, and not the Google Cloud Client Library for Datastore, unless you want to deal with the overhead of writing your own PTransform. Can you post the code or more details about the implementation?

Based on the documentation here your code should look like this:

PCollection<Entity> entities = ...;
entities.apply(DatastoreIO.v1().write().withProjectId(projectId));

The documentation for DatastoreV1.Write can be found here. There is not much else I can answer unless you most the implementation details. I'd post this as a comment but unfortunately do not have enough reputation.

Upvotes: 1

Related Questions