Github user HyukjinKwon commented on a diff in the pull request: https://github.com/apache/spark/pull/18875#discussion_r138103265 --- Diff: sql/core/src/test/scala/org/apache/spark/sql/JsonFunctionsSuite.scala --- @@ -180,10 +180,30 @@ class JsonFunctionsSuite extends QueryTest with SharedSQLContext { test("to_json - array") { val df = Seq(Tuple1(Tuple1(1) :: Nil)).toDF("a") + val df2 = Seq(Tuple1(Map("a" -> 1) :: Nil)).toDF("a") checkAnswer( df.select(to_json($"a")), Row("""[{"_1":1}]""") :: Nil) + checkAnswer( + df2.select(to_json($"a")), + Row("""[{"a":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") + val df3 = Seq(Map("a" -> 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 -- I get your point and I know that also makes sense. How about removing this case out away? I think we might have to discuss more if this is a bug or not but want to rather take out what we are not sure of for now (as it is strictly not related with this PR, if I understood correctly).
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org