ganeshashree commented on code in PR #59828:
URL: https://github.com/apache/spark/pull/59828#discussion_r4422029990
##########
sql/core/src/test/scala/org/apache/spark/sql/JsonObjectSuite.scala:
##########
@@ -1350,6 +1604,59 @@ world'))"""))
}
}
+ test("invalid: a direct star in VALUE/colon JSON_OBJECT forms is not
expanded") {
+ // Clause-free VALUE / colon forms route through function resolution, but
the stock built-in
+ // still rejects a direct member value `*`; only a shadowing routine may
receive it expanded.
+ Seq(
+ "SELECT json_object('a' VALUE *, 'b' VALUE json_object('c' VALUE 1)) " +
+ "FROM VALUES ('id', 7) AS t(a, b)",
+ "SELECT json_object('a': *, 'b': json_object('c': 1)) " +
+ "FROM VALUES ('id', 7) AS t(a, b)"
+ ).foreach { query =>
+ Seq(false, true).foreach { singlePass =>
+ withSQLConf(SQLConf.ANALYZER_SINGLE_PASS_RESOLVER_ENABLED.key ->
singlePass.toString) {
+ val e = intercept[AnalysisException] {
+ sql(query).queryExecution.analyzed
+ }
+ assert(e.getCondition == "INVALID_USAGE_OF_STAR_OR_REGEX",
+ s"singlePass=$singlePass for $query")
+ }
+ }
+ }
+ }
+
+ test("VALUE/colon JSON_OBJECT star expands for a shadow owner") {
+ withSQLConf(
+ SQLConf.PATH_ENABLED.key -> "true",
+ SQLConf.SESSION_FUNCTION_RESOLUTION_ORDER.key -> "second") {
+ try {
+ sql("CREATE TEMPORARY FUNCTION json_object(k1 STRING, v1 STRING, v2
INT, " +
+ "k2 STRING, v3 STRING) RETURNS STRING RETURN 'shadowed-5'")
+ sql("SET PATH = system.session, system.builtin")
+ Seq(
+ "SELECT json_object('a' VALUE *, 'b' VALUE json_object('c' VALUE 1))
" +
+ "FROM VALUES ('id', 7) AS t(a, b)",
+ "SELECT json_object('a': *, 'b': json_object('c': 1)) " +
+ "FROM VALUES ('id', 7) AS t(a, b)"
+ ).foreach { query =>
+ checkAnswer(sql(query), Row("shadowed-5"))
+ // Strict single-pass expands the nested star and routes to the
shadow owner too, but the
Review Comment:
Done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]