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

Schema of ArrayType change after saveAsTable and read

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • 2.4.0
    • None
    • SQL
    • None
    • Spark 2.4

      Scala 2.11

    Description

      This is code for reproducing.

      val testTable = "testseq"
      val df = Seq(Some(Seq(1L,2L,3L)), None).toDF("seq")
      sqlContext.sql(s"DROP TABLE IF EXISTS $testTable")
      df.write.format("parquet").saveAsTable(testTable)
      val res = sqlContext.table(testTable)
      assert(df.schema === res.schema)

      My code is trying to save dataframe with array type and read from that table. After checking schema, I found that schema has change.

      This is the assertion message.

      Expected :StructType(StructField(seq,ArrayType(LongType,true),true))
      Actual :StructType(StructField(seq,ArrayType(LongType,false),true))

      containsNull in ArrayType changes from false to true after reading from the table.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              ksoullpwk Kritsada Limpawatkul
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: