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

The schema of MapType can not be printed correctly

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.3.1
    • 2.4.0
    • SQL

    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

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

            Dates

              Created:
              Updated:
              Resolved: