2017-12-20 2 views
1

Ich bin neu zu entfachen, und ich versuche, ein Schema für ein JSON-Daten zu definieren und lief in die folgenden Fehler in (Funken Schal,überladene Methode Wert gilt mit Alternativen:

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

Kann jemand mich leiten zu was geht hier vor? :) Ich würde deine Hilfe wirklich schätzen!

Antwort

1

Dies, weil dies geschieht:

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

Sie StructType erstellen und StructField als Argument übergeben, während es eine Folge von StructFields sein sollte:

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