ganeshashree commented on code in PR #58005:
URL: https://github.com/apache/spark/pull/58005#discussion_r3841480921


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/jsonExpressions.scala:
##########
@@ -1201,7 +1204,410 @@ object JsonQuery {
 }
 
 /**
- * Converts an json input string to a [[StructType]], [[ArrayType]] or 
[[MapType]]
+ * Behavior of `JSON_ARRAY`'s `ON NULL` clause: what to do with NULL elements 
in the array.
+ */
+sealed trait JsonConstructorNullBehavior
+object JsonConstructorNullBehavior {
+  /** Include NULL elements as JSON `null` values. */
+  case object Null extends JsonConstructorNullBehavior
+  /** Omit NULL elements from the array. */
+  case object Absent extends JsonConstructorNullBehavior
+}
+
+/**
+ * Marker for expressions whose result is JSON text and therefore carry an 
implicit SQL/JSON
+ * `FORMAT JSON`: when such an expression appears as an argument of a JSON 
constructor (e.g.
+ * `JSON_ARRAY`), its value is spliced in verbatim rather than quoted as a 
JSON string, so
+ * `JSON_ARRAY(JSON_ARRAY(1))` yields `[[1]]`, not `[["[1]"]]`. Crucially, the 
constructor freezes
+ * this decision from the *lexical* argument at parse time (see 
`AstBuilder.visitJsonArray`) rather
+ * than re-deriving it from the child expression during evaluation, so a later 
optimizer rewrite
+ * (e.g. `CollapseProject` inlining a `JSON_ARRAY` alias into an argument 
position) cannot change
+ * whether a value is spliced or quoted. `JSON_OBJECT` / `JSON_QUERY` should 
extend this as they are

Review Comment:
   Fixed via `emitsImplicitJsonText`; `OMIT QUOTES` stays quoted; regression 
tests added.



-- 
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]

Reply via email to