twalthr commented on a change in pull request #17313:
URL: https://github.com/apache/flink/pull/17313#discussion_r720075675
##########
File path:
flink-table/flink-table-api-scala/src/main/scala/org/apache/flink/table/api/ImplicitExpressionConversions.scala
##########
@@ -811,8 +815,45 @@ trait ImplicitExpressionConversions {
* // {"K1":{"K2":"V"}}
* jsonObject(JsonOnNull.NULL, "K1", jsonObject(JsonOnNull.NULL, "K2", "V"))
* }}}
+ *
+ * @see #jsonObject
*/
def jsonObject(onNull: JsonOnNull, keyValues: Any*): Expression = {
Expressions.jsonObject(onNull, keyValues)
}
+
+ /**
+ * Builds a JSON array string from a list of values.
+ *
+ * This function returns a JSON string. The values can be arbitrary
expressions. The
+ * [[JsonOnNull onNull]] behavior defines how to treat `NULL` values.
+ *
+ * Elements which are created from another JSON construction function call
+ * (`jsonObject`, `jsonArray`) are inserted directly rather than as a
string. This allows
+ * building nested JSON structures.
+ *
+ * Examples:
+ *
+ * {{{
+ * // "[]"
+ * jsonArray(JsonOnNull.NULL)
+ * // "[1,\"2\"]"
+ * jsonArray(JsonOnNull.NULL, 1, "2")
+ *
+ * // Expressions as values
+ * jsonArray(JsonOnNull.NULL, $("orderId"))
+ *
+ * // ON NULL
+ * jsonArray(JsonOnNull.NULL, nullOf(DataTypes.STRING())) // "[null]"
+ * jsonArray(JsonOnNull.ABSENT, nullOf(DataTypes.STRING())) // "[]"
+ *
+ * // "[[1]]"
+ * jsonArray(JsonOnNull.NULL, jsonArray(JsonOnNull.NULL, 1))
+ * }}}
+ *
+ * @see #jsonObject
+ */
+ def jsonArray(onNull: JsonOnNull, values: Any*): Expression = {
Review comment:
`keyValues` should be `Expression*` to trigger Scala's implicit
conversions
##########
File path:
flink-table/flink-table-api-scala/src/main/scala/org/apache/flink/table/api/ImplicitExpressionConversions.scala
##########
@@ -811,8 +815,45 @@ trait ImplicitExpressionConversions {
* // {"K1":{"K2":"V"}}
* jsonObject(JsonOnNull.NULL, "K1", jsonObject(JsonOnNull.NULL, "K2", "V"))
* }}}
+ *
+ * @see #jsonObject
*/
def jsonObject(onNull: JsonOnNull, keyValues: Any*): Expression = {
Review comment:
`keyValues` should be `Expression*` to trigger Scala's implicit
conversions
##########
File path:
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/JsonGenerateUtils.scala
##########
@@ -31,12 +31,27 @@ import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.{Arr
import
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.util.RawValue
import org.apache.calcite.rex.{RexCall, RexNode}
+import org.apache.calcite.sql.SqlJsonConstructorNullClause
import java.time.format.DateTimeFormatter
/** Utility for generating JSON function calls. */
object JsonGenerateUtils {
+ /** Returns a term which wraps the given <code>expression</code> into a
[[JsonNode]]. If the
Review comment:
nit: `<code>` is not Scala
--
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]