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

Function to_json ignores the user-provided options

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.1.0
    • 2.1.1, 2.2.0
    • SQL
    • None

    Description

      val df = Seq(Tuple1(Tuple1(java.sql.Timestamp.valueOf("2015-08-26 18:00:00.0")))).toDF("a")
      val options = Map("timestampFormat" -> "dd/MM/yyyy HH:mm")
      df.select(to_json($"a", options)).show(false)
      

      The current output is like

      +--------------------------------------+
      |structtojson(a)                       |
      +--------------------------------------+
      |{"_1":"2015-08-26T18:00:00.000-07:00"}|
      +--------------------------------------+
      

      The expected output should be like

      +-------------------------+
      |structtojson(a)          |
      +-------------------------+
      |{"_1":"26/08/2015 18:00"}|
      +-------------------------+
      

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: