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

The schema of MapType can not be printed correctly

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.1
    • Fix Version/s: 2.4.0
    • Component/s: SQL
    • Labels:
    • Target Version/s:

      Description

      Something wrong with the function `buildFormattedString` in `MapType`

       

      import spark.implicits._
      case class Key(a: Int)
      case class Value(b: Int)
      Seq(
        (1, Map(Key(1) -> Value(2))), 
        (2, Map(Key(1) -> Value(2)))
      ).toDF("id", "dict").printSchema
      

      The result is:

      root
      |-- id: integer (nullable = false)
      |-- dict: map (nullable = true)
      | |-- key: struct
      | |-- value: struct (valueContainsNull = true)
      | | |-- a: integer (nullable = false)
      | | |-- b: integer (nullable = false)
      

       The expected is

      root
      |-- id: integer (nullable = false)
      |-- dict: map (nullable = true)
      | |-- key: struct
      | | |-- a: integer (nullable = false)
      | |-- value: struct (valueContainsNull = true)
      | | |-- b: integer (nullable = false)
      

        Attachments

          Activity

            People

            • Assignee:
              invkrh Hao Ren
              Reporter:
              invkrh Hao Ren
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: