vinodkc commented on code in PR #58024:
URL: https://github.com/apache/spark/pull/58024#discussion_r4474109409
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/jsonExpressions.scala:
##########
@@ -2689,3 +2689,70 @@ object JsonObjectExpr {
case _ => false
}
}
+
+// Shape qualifier for IS [NOT] JSON: which top-level JSON type to require.
+sealed trait IsJsonShape
+object IsJsonShape {
+ // Per ANSI SQL:2016 T821, IS JSON VALUE is semantically equivalent to bare
IS JSON:
+ // both accept any well-formed JSON value (object, array, or scalar). They
are kept as
+ // separate shapes so the sql() output round-trips faithfully.
+ case object Any extends IsJsonShape // IS JSON (no qualifier)
+ case object Value extends IsJsonShape // IS JSON VALUE
+ case object Scalar extends IsJsonShape // IS JSON SCALAR -- primitives only
(not object/array)
+ case object Array extends IsJsonShape // IS JSON ARRAY
+ case object Object extends IsJsonShape // IS JSON OBJECT
+}
+
+case class IsJson(child: Expression, shape: IsJsonShape = IsJsonShape.Any)
Review Comment:
Fixed.
IsJson is added to the JSON arm of
ResolverGuard.isGenerallySupportedExpression, and ResolverGuardSuite gets cases
for SELECT '{}' IS JSON, SELECT '{}' IS NOT JSON OBJECT and SELECT NULL IS JSON.
--
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]