【发布时间】:2018-06-12 12:44:19
【问题描述】:
我最近将现有管道从数据流 1.x 升级到数据流 2.x,但我看到了一个对我来说没有意义的错误。我将把相关代码放在下面,然后包含我看到的错误。
// This is essentially the final step in our pipeline, where we write
// one of the side outputs from the pipeline to a BigQuery table
results.get(matchedTag)
.apply("CountBackfill", Count.<String>perElement())
.apply("ToReportRow", ParDo.of(new ToReportRow()))
// at this point, there is now a PCollection<TableRow>
.apply("WriteReport", BigQueryIO.writeTableRows()
.to(reportingDataset + ".AttributeBackfill_" + dayStr)
.withSchema(ReportSchema.get())
.withWriteDisposition(BigQueryIO.Write.WriteDisposition.WRITE_TRUNCATE)
.withCreateDisposition(BigQueryIO.Write.CreateDisposition.CREATE_IF_NEEDED));
/*
* Create a TableRow from a key/value pair
*/
public static class ToReportRow extends DoFn<KV<String, Long>, TableRow> {
private static final long serialVersionUID = 1L;
@ProcessElement
public void processElement(ProcessContext c) throws InterruptedException {
KV<String, Long> row = c.element();
c.output(new TableRow()
.set(ReportSchema.ID, row.getKey())
.set(ReportSchema.COUNT, row.getValue()));
}
}
这是我看到的错误:
线程“主”java.lang.NoSuchMethodError 中的异常: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V 在 org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO$Write.expand(BigQueryIO.java:1426) 在 org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO$Write.expand(BigQueryIO.java:989) 在 org.apache.beam.sdk.Pipeline.applyInternal(Pipeline.java:525) 在 org.apache.beam.sdk.Pipeline.applyTransform(Pipeline.java:479) 在 org.apache.beam.sdk.values.PCollection.apply(PCollection.java:297) 在 com.prod.merge.DailyUniqueProfiles.buildPipeline(DUP.java:106) 在 com.prod.merge.MergePipeline.main(MergePipeline.java:91)
.apply("WriteReport", BigQueryIO.writeTableRows() 行是DUP.java 中的第 106 行,所以我怀疑这行是错误的。
对可能出现的问题有什么想法吗?
【问题讨论】:
-
问题似乎与番石榴的冲突版本有关,尽管我还不确定冲突是由什么引起的。
-
我也遇到了同样的错误。你能解决这个问题吗?
-
@Vetri 我刚刚在下面发布了我的解决方案。希望它也适合你。
-
谢谢@Max - 你的解决方案给了我一个提示,我修复了它。发布我的解决方案。
标签: java apache-beam dataflow