Github user goldmedal commented on a diff in the pull request: https://github.com/apache/spark/pull/18875#discussion_r132615092 --- Diff: sql/core/src/test/scala/org/apache/spark/sql/JsonFunctionsSuite.scala --- @@ -186,6 +186,18 @@ class JsonFunctionsSuite extends QueryTest with SharedSQLContext { Row("""[{"_1":1}]""") :: Nil) } + test("to_json - map") { + val df1 = Seq(Map("a" -> Tuple1(1))).toDF("a") + val df2 = Seq(Map(Tuple1(1) -> Tuple1(1))).toDF("a") + + checkAnswer( + df1.select(to_json($"a")), + Row("""{"a":{"_1":1}}""") :: Nil) + checkAnswer( + df2.select(to_json($"a")), + Row("""{"[0,1]":{"_1":1}}""") :: Nil) --- End diff -- Actually, I'm not sure what answer is it but I got `[0,1]` using ``` scala> Seq(Tuple1(Tuple1(Map(Tuple1(1)->Tuple1(1))))).toDF("a").select(to_json($"a")).show() +--------------------+ | structstojson(a)| +--------------------+ |[{"_1":{"[0,1]":{...| +--------------------+ ``` so I think this answer should be correct.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org