gpt4 book ai didi

java - Apache Beam,BigQueryIO.WriteTableRows() 上的 NoSuchMethodError?

转载 作者:搜寻专家 更新时间:2023-11-01 03:46:48 24 4
gpt4 key购买 nike

我最近将现有管道从数据流 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()));
}
}

这是我看到的错误:

Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V at org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO$Write.expand(BigQueryIO.java:1426) at org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO$Write.expand(BigQueryIO.java:989) at org.apache.beam.sdk.Pipeline.applyInternal(Pipeline.java:525) at org.apache.beam.sdk.Pipeline.applyTransform(Pipeline.java:479) at org.apache.beam.sdk.values.PCollection.apply(PCollection.java:297) at com.prod.merge.DailyUniqueProfiles.buildPipeline(DUP.java:106) at com.prod.merge.MergePipeline.main(MergePipeline.java:91)

.apply("WriteReport", BigQueryIO.writeTableRows()DUP.java 中的第 106 行,所以我怀疑这是错误的行。

关于问题可能是什么的任何想法?

最佳答案

这个问题的解决方案最终出现在 maven 依赖项中。添加以下依赖项并使用 mvn 重新编译后,错误消失了。

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>22.0</version>
</dependency>

关于java - Apache Beam,BigQueryIO.WriteTableRows() 上的 NoSuchMethodError?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48067265/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com