Github user yhuai commented on a diff in the pull request:
https://github.com/apache/spark/pull/9562#discussion_r44353866
--- Diff:
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala
---
@@ -1448,4 +1448,21 @@ class SQLQuerySuite extends QueryTest with
SQLTestUtils with TestHiveSingleton {
Row("1", "10") :: Row("2", "20") :: Row("3", "30") :: Row("4",
"40") :: Nil)
}
}
+
+ test("SPARK-11590: use native json_tuple in lateral view") {
+ checkAnswer(sql(
+ """
+ |SELECT a, b
+ |FROM (SELECT '{"f1": "value1", "f2": 12}' json) test
+ |LATERAL VIEW json_tuple(json, 'f1', 'f2') jt AS a, b
+ """.stripMargin), Row("value1", "12"))
+
+ // we should use `c0`, `c1`... as the name of fields if no alias is
provided, to follow hive.
+ checkAnswer(sql(
+ """
+ |SELECT c0, c1
+ |FROM (SELECT '{"f1": "value1", "f2": 12}' json) test
+ |LATERAL VIEW json_tuple(json, 'f1', 'f2') jt
+ """.stripMargin), Row("value1", "12"))
--- End diff --
For SQL, can we put `json_tuple` in the select clause?
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]