raminqaf commented on code in PR #29342:
URL: https://github.com/apache/flink/pull/29342#discussion_r4152576629
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/JsonFunctionsITCase.java:
##########
@@ -1096,6 +1096,33 @@ private static List<TestSetSpec> parseJsonSpec() {
"JSON_STRING(TRY_PARSE_JSON(f2, true))",
"{\"a\":2}",
STRING()),
+ // Input is parsed from its UTF-8 bytes. A NUL or a BOM must
not be read as a
+ // UTF-16 or UTF-32 hint that turns invalid JSON into a value.
+ TestSetSpec.forFunction(
+ BuiltInFunctionDefinitions.PARSE_JSON,
+ "input bytes are always read as UTF-8")
+ .onFieldsWithData("1\u0000", "\u00001", "\uFEFF1")
+ .andDataTypes(STRING().notNull(), STRING().notNull(),
STRING().notNull())
+ .testSqlRuntimeError(
+ "PARSE_JSON(f0)",
+ TableRuntimeException.class,
+ "Failed to parse json string")
+ .testSqlRuntimeError(
+ "PARSE_JSON(f1)",
+ TableRuntimeException.class,
+ "Failed to parse json string")
+ .testSqlRuntimeError(
+ "PARSE_JSON(f2)",
+ TableRuntimeException.class,
+ "Failed to parse json string"),
Review Comment:
When the input is not valid UTF-8, the error now names the charset and
points at the byte: `Failed to parse json string: Invalid UTF-8 byte at index 1
of 3`. It uses the same wording as a strict `CAST(BYTES AS STRING)`.
--
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]