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

Wrong results of insertion of Array of Struct

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.1.1, 2.2.0
    • Fix Version/s: 2.1.2, 2.2.0
    • Component/s: SQL
    • Labels:
      None
    • Target Version/s:

      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

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

              Dates

              • Created:
                Updated:
                Resolved: