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

The schema of MapType can not be printed correctly

Log workAgile BoardRank to TopRank to BottomAttach filesAttach ScreenshotBulk Copy AttachmentsBulk Move AttachmentsVotersWatch issueWatchersCreate sub-taskConvert to sub-taskMoveLinkCloneLabelsUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete CommentsDelete
    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

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment