apache-spark-encoders

Encoder error while trying to map dataframe row to updated row

[亡魂溺海] 提交于 2019-12-16 22:22:41
问题 When I m trying to do the same thing in my code as mentioned below dataframe.map(row => { val row1 = row.getAs[String](1) val make = if (row1.toLowerCase == "tesla") "S" else row1 Row(row(0),make,row(2)) }) I have taken the above reference from here: Scala: How can I replace value in Dataframs using scala But I am getting encoder error as Unable to find encoder for type stored in a Dataset. Primitive types (Int, S tring, etc) and Product types (case classes) are supported by importing spark

Apache Spark 2.1 : java.lang.UnsupportedOperationException: No Encoder found for scala.collection.immutable.Set[String]

安稳与你 提交于 2019-12-12 10:06:24
问题 I am using Spark 2.1.1 with Scala 2.11.6. I am getting the following error. I am not using any case classes. java.lang.UnsupportedOperationException: No Encoder found for scala.collection.immutable.Set[String] field (class: "scala.collection.immutable.Set", name: "_2") field (class: "scala.Tuple2", name: "_2") root class: "scala.Tuple2" The following portion of code is where the stacktrace points at. val tweetArrayRDD = nameDF.select("namedEnts", "text", "storylines") .flatMap { case Row

spark custom kryo encoder not providing schema for UDF

为君一笑 提交于 2019-12-10 23:39:35
问题 When following along with How to store custom objects in Dataset? and trying to register my own kryo encoder for a data frame I face an issue of Schema for type com.esri.core.geometry.Envelope is not supported There is a function which will parse a String (WKT) to an geometry object like: def mapWKTToEnvelope(wkt: String): Envelope = { val envBound = new Envelope() val spatialReference = SpatialReference.create(4326) // Parse the WKT String into a Geometry Object val ogcObj = OGCGeometry

Spark: java.lang.UnsupportedOperationException: No Encoder found for java.time.LocalDate

给你一囗甜甜゛ 提交于 2019-12-07 11:36:14
问题 I'm writing a Spark application using version 2.1.1. The following code got the error when calling a method with LocalDate parameter? Exception in thread "main" java.lang.UnsupportedOperationException: No Encoder found for java.time.LocalDate - field (class: "java.time.LocalDate", name: "_2") - root class: "scala.Tuple2" at org.apache.spark.sql.catalyst.ScalaReflection$.org$apache$spark$sql$catalyst$ScalaReflection$$serializerFor(ScalaReflection.scala:602) at org.apache.spark.sql.catalyst

Apache Spark 2.1 : java.lang.UnsupportedOperationException: No Encoder found for scala.collection.immutable.Set[String]

让人想犯罪 __ 提交于 2019-12-06 07:42:59
I am using Spark 2.1.1 with Scala 2.11.6. I am getting the following error. I am not using any case classes. java.lang.UnsupportedOperationException: No Encoder found for scala.collection.immutable.Set[String] field (class: "scala.collection.immutable.Set", name: "_2") field (class: "scala.Tuple2", name: "_2") root class: "scala.Tuple2" The following portion of code is where the stacktrace points at. val tweetArrayRDD = nameDF.select("namedEnts", "text", "storylines") .flatMap { case Row(namedEnts: Traversable[(String, String)], text: String, storylines: Traversable[String]) => Option

How to implement Functor[Dataset]

被刻印的时光 ゝ 提交于 2019-12-06 06:03:23
问题 I am struggling on how to create an instance of Functor[Dataset] ... the problem is that when you map from A to B the Encoder[B] must be in the implicit scope but I am not sure how to do it. implicit val datasetFunctor: Functor[Dataset] = new Functor[Dataset] { override def map[A, B](fa: Dataset[A])(f: A => B): Dataset[B] = fa.map(f) } Of course this code is throwing a compilation error since Encoder[B] is not available but I can't add Encoder[B] as an implicit parameter because it would

scala generic encoder for spark case class

♀尐吖头ヾ 提交于 2019-12-06 03:16:04
问题 How can I get this method to compile. Strangely, sparks implicit are already imported. def loadDsFromHive[T <: Product](tableName: String, spark: SparkSession): Dataset[T] = { import spark.implicits._ spark.sql(s"SELECT * FROM $tableName").as[T] } This is the error: Unable to find encoder for type stored in a Dataset. Primitive types (Int, String, etc) and Product types (case classes) are supported by importing spark.implicits._ Support for serializing other types will be added in future

Generic T as Spark Dataset[T] constructor

久未见 提交于 2019-12-05 15:59:29
In the following snippet, the tryParquet function tries to load a Dataset from a Parquet file if it exists. If not, it computes, persists and returns back the Dataset plan which was provided: import scala.util.{Try, Success, Failure} import org.apache.spark.sql.SparkSession import org.apache.spark.sql.Dataset sealed trait CustomRow case class MyRow( id: Int, name: String ) extends CustomRow val ds: Dataset[MyRow] = Seq((1, "foo"), (2, "bar"), (3, "baz")).toDF("id", "name").as[MyRow] def tryParquet[T <: CustomRow](session: SparkSession, path: String, target: Dataset[T]): Dataset[T] = Try

Spark: java.lang.UnsupportedOperationException: No Encoder found for java.time.LocalDate

馋奶兔 提交于 2019-12-05 11:57:47
I'm writing a Spark application using version 2.1.1. The following code got the error when calling a method with LocalDate parameter? Exception in thread "main" java.lang.UnsupportedOperationException: No Encoder found for java.time.LocalDate - field (class: "java.time.LocalDate", name: "_2") - root class: "scala.Tuple2" at org.apache.spark.sql.catalyst.ScalaReflection$.org$apache$spark$sql$catalyst$ScalaReflection$$serializerFor(ScalaReflection.scala:602) at org.apache.spark.sql.catalyst.ScalaReflection$$anonfun$9.apply(ScalaReflection.scala:596) at org.apache.spark.sql.catalyst

How to implement Functor[Dataset]

痞子三分冷 提交于 2019-12-04 10:45:10
I am struggling on how to create an instance of Functor[Dataset] ... the problem is that when you map from A to B the Encoder[B] must be in the implicit scope but I am not sure how to do it. implicit val datasetFunctor: Functor[Dataset] = new Functor[Dataset] { override def map[A, B](fa: Dataset[A])(f: A => B): Dataset[B] = fa.map(f) } Of course this code is throwing a compilation error since Encoder[B] is not available but I can't add Encoder[B] as an implicit parameter because it would change the map method signature, how can I solve this? You cannot apply f right away, because you are