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

Wrong results of insertion of Array of Struct

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Blocker
    • Resolution: Fixed
    • 2.1.1, 2.2.0
    • 2.1.2, 2.2.0
    • SQL
    • None

    Description

            spark.sql(
              """
                |CREATE TABLE `tab1`
                |(`custom_fields` ARRAY<STRUCT<`id`: BIGINT, `value`: STRING>>)
                |USING parquet
              """.stripMargin)
            spark.sql(
              """
                |INSERT INTO `tab1`
                |SELECT ARRAY(named_struct('id', 1, 'value', 'a'), named_struct('id', 2, 'value', 'b'))
              """.stripMargin)
      
            spark.sql("SELECT custom_fields.id, custom_fields.value FROM tab1").show()
      

      The returned result is wrong:

      Row(Array(2, 2), Array("b", "b"))
      

      Attachments

        Activity

          People

            smilegator Xiao Li
            smilegator Xiao Li
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: