重载的方法值适用于替代方法: [英] Overloaded method value apply with alternatives:
本文介绍了重载的方法值适用于替代方法:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是火花的新手,我试图为json数据定义架构,并在(spark-shell,
I am new to spark and I was trying to define a schema for a json data and ran into the following error in (spark-shell,
<console>:28: error: overloaded method value apply with alternatives:
(fields: Array[org.apache.spark.sql.types.StructField])org.apache.spark.sql.types.StructType <and>
(fields: java.util.List[org.apache.spark.sql.types.StructField])org.apache.spark.sql.types.StructType <and>
(fields: Seq[org.apache.spark.sql.types.StructField])org.apache.spark.sql.types.StructType
cannot be applied to (org.apache.spark.sql.types.StructField, org.apache.spark.sql.types.StructField)
val schema = StructType(Array(StructField("type", StructType(StructField("name", StringType, true), StructField("version", StringType, true)), true) :: StructField("value", StructType(StructField("answerBlacklistedEntities", StringType, true) :: StructField("answerBlacklistedPhrase", StringType, true) :: StructField("answerEntities", StringType, true) :: StructField("answerText", StringType, true) :: StructField("blacklistReason", StringType, true) :: StructField("blacklistedDomains", StringType, true) :: StructField("blacklistedEntities", ArrayType(StringType, true), true) :: StructField("customerId", StringType, true) :: StructField("impolitePhrase", StringType, true) :: StructField("isResponseBlacklisted", BooleanType, true) :: StructField("queryString", StringType, true) :: StructField("utteranceDomains", StringType, true) :: StructField("utteranceEntities", ArrayType(StringType, true), true) :: StructField("utteranceId", StructType(StructField("identifier", StringType, true)), true)) :: Nil)))
有人可以引导我了解这里发生的事情吗? :)非常感谢您的帮助!
Can anybody guide me to what's going on here? :) I'd really appreciate your help!
推荐答案
发生这种情况的原因是:
This happens because of this:
val schema = StructType(Array(StructField("type",
StructType(StructField("name", StringType, true), ...))
您创建StructType
并将StructField
作为参数传递,但它应该是StructFields
的序列:
You create StructType
and pass StructField
as an argument, while it should be a sequence of StructFields
:
val schema = StructType(Array(StructField("type",
StructType(Array(StructField("name", StringType, true), ...)) ...)
这篇关于重载的方法值适用于替代方法:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文