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



##########
File path: 
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/JsonFunctionsITCase.java
##########
@@ -420,8 +431,146 @@ private static TestSpec jsonValue() throws Exception {
                                 "No results for path"));
     }
 
+    private static List<TestSpec> jsonObjectSpec() {
+        final Map<String, String> mapData = new HashMap<>();
+        mapData.put("M1", "V1");
+        mapData.put("M2", "V2");
+
+        final Map<String, Integer> multisetData = new HashMap<>();
+        multisetData.put("M1", 1);
+        multisetData.put("M2", 2);
+
+        return Arrays.asList(
+                TestSpec.forFunction(BuiltInFunctionDefinitions.JSON_OBJECT)
+                        .onFieldsWithData(0)
+                        .testResult(
+                                jsonObject(JsonOnNull.NULL),
+                                "JSON_OBJECT()",
+                                "{}",
+                                STRING().notNull(),
+                                VARCHAR(2000).notNull())
+                        .testResult(
+                                jsonObject(JsonOnNull.NULL, "K", 
nullOf(STRING())),
+                                "JSON_OBJECT(KEY 'K' VALUE CAST(NULL AS 
STRING) NULL ON NULL)",
+                                "{\"K\":null}",
+                                STRING().notNull(),
+                                VARCHAR(2000).notNull())
+                        .testResult(
+                                jsonObject(JsonOnNull.ABSENT, "K", 
nullOf(STRING())),
+                                "JSON_OBJECT(KEY 'K' VALUE CAST(NULL AS 
STRING) ABSENT ON NULL)",
+                                "{}",
+                                STRING().notNull(),
+                                VARCHAR(2000).notNull()),
+                TestSpec.forFunction(BuiltInFunctionDefinitions.JSON_OBJECT)
+                        .onFieldsWithData(
+                                "V",
+                                true,
+                                1,
+                                1.23d,
+                                1.23,
+                                LocalDateTime.parse("1990-06-02T13:37:42.001"),
+                                Instant.parse("1990-06-02T13:37:42.001Z"),
+                                Arrays.asList("A1", "A2", "A3"),
+                                Row.of("R1"),

Review comment:
       Done. I also added another example which nestes several complex types as 
that revealed another minor bug in the implementation.




-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to