我正在嘗試修改此示例,如下所示:
@BigQueryType.fromQuery("SELECT weight_pounds FROM [bigquery-public-data:samples.natality]")
class Row
@BigQueryType.toTable
case class Result(weight_pounds: Double)
sc.typedBigQuery[Row]()
.map(r => r.weight_pounds.getOrElse(0.0)) // return 0 if weight_pounds is None
.top(100)
.map(x => Result(x))
// Convert elements from Result to TableRow and save output to BigQuery.
.saveAsTypedBigQueryTable(
Table.Spec(args("output")),
writeDisposition = WRITE_TRUNCATE,
createDisposition = CREATE_IF_NEEDED
)
上面給了我以下錯誤:
[error] /Users/me/scio/scio-examples/src/main/scala/com/spotify/scio/examples/foo.scala:66:24: type mismatch;
[error] found : Iterable[Double]
[error] required: Double
[error] .map(x => Result(x))
[error] ^
我怎樣才能解決這個問題?
uj5u.com熱心網友回復:
flatMap(x => x)訣竅是在之后添加一個top(100)
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/496953.html
標籤:斯卡拉 spotify-scio
上一篇:抽象特征的Scalajson4s反序列化導致MappingExeption:意外的型別資訊RefinedType
