slinkydeveloper commented on a change in pull request #17186:
URL: https://github.com/apache/flink/pull/17186#discussion_r704083943



##########
File path: 
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/api/Expressions.java
##########
@@ -562,6 +563,43 @@ public static ApiExpression withoutColumns(Object head, 
Object... tail) {
         return 
apiCallAtLeastOneArgument(BuiltInFunctionDefinitions.WITHOUT_COLUMNS, head, 
tail);
     }
 
+    /**
+     * Builds a JSON string from a list of key-value pairs.
+     *
+     * <p>{@param keyValues} is an even-numbered list of alternating key/value 
pairs. Note that keys
+     * must be non-{@code NULL} string literals, while values may be arbitrary 
expressions.
+     *
+     * <p>The {@link JsonOnNull onNull} behavior defines how to treat {@code 
NULL} values.
+     *
+     * <p>Note that this function only returns a JSON string, not an actual 
JSON type. Not all JSON
+     * can currently be represented in Flink's type system.
+     *
+     * <p>Examples:
+     *
+     * <pre>{@code
+     * // "{}"
+     * jsonObject(JsonOnNull.NULL)
+     * // "{\"K1\":\"V1\",\"K2\":\"V2\"}"
+     * jsonObject(JsonOnNull.NULL, "K1", "V1", "K2", "V2")
+     *
+     * // Expressions as values
+     * jsonObject(JsonOnNull.NULL, "orderNo", $("orderId"))
+     *
+     * // ON NULL
+     * jsonObject(JsonOnNull.NULL, "K1", nullOf(DataTypes.STRING()))   // 
"{\"K1\":null}"
+     * jsonObject(JsonOnNull.ABSENT, "K1", nullOf(DataTypes.STRING())) // "{}"
+     *
+     * // "{\"K1\":\"{\\\"K2\\\":\\\"V\\\"}\"}"
+     * jsonObject(JsonOnNull.NULL, "K1", jsonObject(JsonOnNull.NULL, "K2", 
"V"))
+     * }</pre>
+     */
+    public static ApiExpression jsonObject(JsonOnNull onNull, Object... 
keyValues) {

Review comment:
       Perhaps you could have a signature or `Map.Entry` varargs and then 
provide a static method to simplify the construction of `SimpleImmutableEntry` 
like: `Map.Entry<String, Object> entry(String key, Object value)`




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


Reply via email to