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

nullability of GetArrayStructFields is incorrect

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 1.6.3, 2.0.2, 2.1.3, 2.2.3, 2.3.4, 2.4.6, 3.0.0
    • Fix Version/s: 2.4.7, 3.0.1, 3.1.0
    • Component/s: SQL
    • Labels:

      Description

      The following should be `Array([WrappedArray(1, null)])` instead of `Array([WrappedArray(1, 0)])`

      import scala.collection.JavaConverters._
      import org.apache.spark.sql.Row
      import org.apache.spark.sql.types.{ArrayType, StructType}
      
      val innerStruct = new StructType().add("i", "int", nullable = true)
      val schema = new StructType().add("arr", ArrayType(innerStruct, containsNull = false))
      val df = spark.createDataFrame(List(Row(Seq(Row(1), Row(null)))).asJava, schema)
      df.select($"arr".getField("i")).collect
      

       

        Attachments

          Activity

            People

            • Assignee:
              cloud_fan Wenchen Fan
              Reporter:
              cloud_fan Wenchen Fan
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: