2017-12-20 5 views
1

私はスパークに新しいですし、私はJSONデータのスキーマを定義しようとしていると(スパーク・シェルで次のようなエラーに遭遇した、オーバーロードメソッドの値は選択肢に適用されます。

<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))) 

誰もが私を導くことができますここで何が起こっているの?:)私は本当にあなたの助けに感謝します!

答えて

1

これは、このために起こる:

val schema = StructType(Array(StructField("type", 
    StructType(StructField("name", StringType, true), ...)) 

あなたはStructTypeを作成し、それがStructFieldsの順序でなければなりませんが、引数としてStructFieldを渡す:

val schema = StructType(Array(StructField("type", 
    StructType(Array(StructField("name", StringType, true), ...)) ...) 
関連する問題