raminqaf commented on code in PR #28741:
URL: https://github.com/apache/flink/pull/28741#discussion_r3585707959
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/JsonFunctionsITCase.java:
##########
@@ -316,59 +316,97 @@ private static List<TestSetSpec> isJsonSpec() {
TestSetSpec.forFunction(BuiltInFunctionDefinitions.IS_JSON)
.onFieldsWithData((String) null)
.andDataTypes(STRING())
- .testResult($("f0").isJson(), "f0 IS JSON", false,
BOOLEAN().notNull()),
+ // IS [NOT] JSON follows SQL three-valued logic and
returns NULL for a NULL
+ // input, see FLINK-39943. This holds for every JSON
type and for both the
+ // IS JSON and IS NOT JSON forms.
+ .testResult($("f0").isJson(), "f0 IS JSON", null,
BOOLEAN())
+ .testResult($("f0").isJson().not(), "f0 IS NOT JSON",
null, BOOLEAN())
+ .testResult(
+ $("f0").isJson(JsonType.VALUE), "f0 IS JSON
VALUE", null, BOOLEAN())
+ .testResult(
+ $("f0").isJson(JsonType.VALUE).not(),
+ "f0 IS NOT JSON VALUE",
+ null,
+ BOOLEAN())
+ .testResult(
+ $("f0").isJson(JsonType.SCALAR),
+ "f0 IS JSON SCALAR",
+ null,
+ BOOLEAN())
+ .testResult(
+ $("f0").isJson(JsonType.SCALAR).not(),
+ "f0 IS NOT JSON SCALAR",
+ null,
+ BOOLEAN())
+ .testResult(
+ $("f0").isJson(JsonType.ARRAY), "f0 IS JSON
ARRAY", null, BOOLEAN())
+ .testResult(
+ $("f0").isJson(JsonType.ARRAY).not(),
+ "f0 IS NOT JSON ARRAY",
+ null,
+ BOOLEAN())
+ .testResult(
+ $("f0").isJson(JsonType.OBJECT),
+ "f0 IS JSON OBJECT",
+ null,
+ BOOLEAN())
+ .testResult(
+ $("f0").isJson(JsonType.OBJECT).not(),
+ "f0 IS NOT JSON OBJECT",
+ null,
+ BOOLEAN()),
TestSetSpec.forFunction(BuiltInFunctionDefinitions.IS_JSON)
.onFieldsWithData("a")
.andDataTypes(STRING())
+ .testResult($("f0").isJson(), "f0 IS JSON", false,
BOOLEAN())
+ .testResult($("f0").isJson().not(), "f0 IS NOT JSON",
true, BOOLEAN()),
+ TestSetSpec.forFunction(BuiltInFunctionDefinitions.IS_JSON)
+ // A non-nullable input yields a non-nullable BOOLEAN
result.
+ .onFieldsWithData("a")
+ .andDataTypes(STRING().notNull())
Review Comment:
nit: Is the comment correct here?
```suggestion
TestSetSpec.forFunction(BuiltInFunctionDefinitions.IS_JSON)
// A non-nullable input yields a non-nullable STRING
result.
.onFieldsWithData("a")
.andDataTypes(STRING().notNull())
```
--
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]