数据流pub / sub上的apply方法问题

时间:2021-09-17 15:35:19

I am new at dataflow, and i am trying to write some message to pub/sub when tryin to use the apply method for PubsubIO.writeStrings().to("projects/market-place-sql/topics/emisiones") and it say: [数据流pub / sub上的apply方法问题]

我是dataflow的新手,我试图在pubsubIO.writeStrings()。(“projects / market-place-sql / topics / emisiones”)中使用apply方法时向pub / sub写一些消息说:[]

1 个解决方案

#1


1  

The error is simply a type mismatch. The apply() method for the Pipeline class accepts a second parameter of the type PTransform<? super PBegin,OutputT>.

错误只是类型不匹配。 Pipeline类的apply()方法接受PTransform <?类型的第二个参数。超级PBegin,OutputT>。

PubSubIO.writeStrings().to() returns a PTransform<PCollection<T>,PDone> type. Hence, the type mismatch.

PubSubIO.writeStrings()。to()返回PTransform ,PDone>类型。因此,类型不匹配。

Based on the screenshot of the error, it looks like p is a Pipeline object. You'll need to first apply an input transform to the Pipeline object, which will return a PCollection. Then call apply() on the PCollection.

根据错误的屏幕截图,看起来p是一个Pipeline对象。您需要首先将输入变换应用于Pipeline对象,该对象将返回PCollection。然后在PCollection上调用apply()。

Example:

例:

p.apply("read from Pub/Sub", PubsubIO.readMessages().fromSubscription("subscription/path"))
 .apply("write to Pub/Sub", PubsubIO.writeStrings().to("topic/path"));

p.run();

References: Pipeline.apply(), PCollection.apply()

参考文献:Pipeline.apply(),PCollection.apply()

#1


1  

The error is simply a type mismatch. The apply() method for the Pipeline class accepts a second parameter of the type PTransform<? super PBegin,OutputT>.

错误只是类型不匹配。 Pipeline类的apply()方法接受PTransform <?类型的第二个参数。超级PBegin,OutputT>。

PubSubIO.writeStrings().to() returns a PTransform<PCollection<T>,PDone> type. Hence, the type mismatch.

PubSubIO.writeStrings()。to()返回PTransform ,PDone>类型。因此,类型不匹配。

Based on the screenshot of the error, it looks like p is a Pipeline object. You'll need to first apply an input transform to the Pipeline object, which will return a PCollection. Then call apply() on the PCollection.

根据错误的屏幕截图,看起来p是一个Pipeline对象。您需要首先将输入变换应用于Pipeline对象,该对象将返回PCollection。然后在PCollection上调用apply()。

Example:

例:

p.apply("read from Pub/Sub", PubsubIO.readMessages().fromSubscription("subscription/path"))
 .apply("write to Pub/Sub", PubsubIO.writeStrings().to("topic/path"));

p.run();

References: Pipeline.apply(), PCollection.apply()

参考文献:Pipeline.apply(),PCollection.apply()