spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From igyu <i...@21cn.com>
Subject type mismatch
Date Fri, 03 Sep 2021 04:39:48 GMT
val schemas = createSchemas(config)
val arr = new Array[String](schemas.size())

lines.map(x => {
  val obj = JSON.parseObject(x)
  val vs = new Array[Any](schemas.size())
  for (i <- 0 until schemas.size()) {
    arr(i) = schemas.get(i).name
     vs(i) = x.getString(schemas.get(i).name)
    }
  }

  val seq = Seq(vs: _*)
  val record = Row.fromSeq(seq)
  record
})(Encoders.javaSerialization(Row.getClass))
  .toDF(arr: _*)

I get a error

type mismatch;
 found   : Class[?0] where type ?0 <: org.apache.spark.sql.Row.type
 required: Class[org.apache.spark.sql.Row]
    })(Encoders.javaSerialization(Row.getClass))


igyu
Mime
View raw message