I work with the spark-csv Databricks package (through the Scala API) and have problems defining a custom schema.
After starting the console with
spark-shell --packages com.databricks:spark-csv_2.11:1.2.0
I import the necessary types
import org.apache.spark.sql.types.{StructType, StructField, StringType, IntegerType}
and then try defining this circuit:
val customSchema = StructType(
StructField("user_id", IntegerType, true),
StructField("item_id", IntegerType, true),
StructField("artist_id", IntegerType, true),
StructField("scrobble_time", StringType, true))
but I get the following error:
<console>:26: 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, org.apache.spark.sql.types.StructField, org.apache.spark.sql.types.StructField)
val customSchema = StructType(
I am very new to scala, therefore, not understanding this, but what am I doing wrong here? I follow a very simple example here .