Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-45081

Encoders.bean does no longer work with read-only properties

    XMLWordPrintableJSON

Details

    Description

      Since Spark 3.4.x an exception is thrown when Encoders.bean is called providing a bean having read-only properties, such as:

       

      public static class ReadOnlyPropertyBean implements Serializable {
          public boolean isEmpty() {
            return true;
          }
      } 

       

       
      Encoders.bean(ReadOnlyPropertyBean.class) will throw:

      java.util.NoSuchElementException: None.get
              at scala.None$.get(Option.scala:529)
              at scala.None$.get(Option.scala:527)
              at org.apache.spark.sql.catalyst.ScalaReflection$.$anonfun$deserializerFor$8(ScalaReflection.scala:359)
              at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:286)
              at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:36)
              at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:33)
              at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:38)
              at scala.collection.TraversableLike.map(TraversableLike.scala:286)
              at scala.collection.TraversableLike.map$(TraversableLike.scala:279)
              at scala.collection.AbstractTraversable.map(Traversable.scala:108)
              at org.apache.spark.sql.catalyst.ScalaReflection$.deserializerFor(ScalaReflection.scala:348)
              at org.apache.spark.sql.catalyst.ScalaReflection$.deserializerFor(ScalaReflection.scala:183)
              at org.apache.spark.sql.catalyst.encoders.ExpressionEncoder$.apply(ExpressionEncoder.scala:56)
              at org.apache.spark.sql.catalyst.encoders.ExpressionEncoder$.javaBean(ExpressionEncoder.scala:62)
              at org.apache.spark.sql.Encoders$.bean(Encoders.scala:179)
              at org.apache.spark.sql.Encoders.bean(Encoders.scala) 

      This problem is described also in link Encoders.bean doesn't work anymore on a Java POJO, with Spark 3.4.0

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              gbloisi-openaire Giambattista Bloisi
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: