cjohnson-confluent commented on code in PR #29063:
URL: https://github.com/apache/flink/pull/29063#discussion_r3936295388
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/JsonFunctionsITCase.java:
##########
@@ -886,7 +1083,214 @@ private static List<TestSetSpec> jsonQuerySpec() {
.testTableApiRuntimeError(
$("f0").jsonQuery("strict $.err10",
WITHOUT_ARRAY, NULL, ERROR),
TableRuntimeException.class,
- "No results for path"));
+ "No results for path"),
+
+ // Typed RETURNING ARRAY<T> support
+ TestSetSpec.forFunction(BuiltInFunctionDefinitions.JSON_QUERY)
+ .onFieldsWithData(
+ "{\"ints\": [1, 2, 3], \"doubles\": [1.5,
2.5], \"bools\": [true, false], \"withNull\": [1, null, 3], \"bigints\": [1,
9999999999]}")
+ .andDataTypes(STRING())
+ .testResult(
+ $("f0").jsonQuery("$.ints", ARRAY(INT())),
+ "JSON_QUERY(f0, '$.ints' RETURNING
ARRAY<INT>)",
+ new Integer[] {1, 2, 3},
+ ARRAY(INT()))
+ .testResult(
+ $("f0").jsonQuery("$.ints", ARRAY(TINYINT())),
+ "JSON_QUERY(f0, '$.ints' RETURNING
ARRAY<TINYINT>)",
+ new Byte[] {1, 2, 3},
+ ARRAY(TINYINT()))
+ .testResult(
+ $("f0").jsonQuery("$.ints", ARRAY(SMALLINT())),
+ "JSON_QUERY(f0, '$.ints' RETURNING
ARRAY<SMALLINT>)",
+ new Short[] {1, 2, 3},
+ ARRAY(SMALLINT()))
+ .testResult(
+ $("f0").jsonQuery("$.ints", ARRAY(BIGINT())),
+ "JSON_QUERY(f0, '$.ints' RETURNING
ARRAY<BIGINT>)",
+ new Long[] {1L, 2L, 3L},
+ ARRAY(BIGINT()))
+ .testResult(
+ $("f0").jsonQuery("$.bigints",
ARRAY(BIGINT())),
+ "JSON_QUERY(f0, '$.bigints' RETURNING
ARRAY<BIGINT>)",
+ new Long[] {1L, 9999999999L},
+ ARRAY(BIGINT()))
+ .testResult(
+ $("f0").jsonQuery("$.doubles",
ARRAY(DOUBLE())),
+ "JSON_QUERY(f0, '$.doubles' RETURNING
ARRAY<DOUBLE>)",
+ new Double[] {1.5, 2.5},
+ ARRAY(DOUBLE()))
Review Comment:
Already present at [line
1078](https://github.com/apache/flink/pull/29063/commits/dd9d07b652964350f7267235ad079c8f3bd04b83#diff-553c0ac1e78ae37ac56c7c7f1e2c013d1c5b6a6f6d8e20e6b18e5f7c1fa06e13R1078-R1081).
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/JsonFunctionsITCase.java:
##########
@@ -886,7 +1083,214 @@ private static List<TestSetSpec> jsonQuerySpec() {
.testTableApiRuntimeError(
$("f0").jsonQuery("strict $.err10",
WITHOUT_ARRAY, NULL, ERROR),
TableRuntimeException.class,
- "No results for path"));
+ "No results for path"),
+
+ // Typed RETURNING ARRAY<T> support
+ TestSetSpec.forFunction(BuiltInFunctionDefinitions.JSON_QUERY)
+ .onFieldsWithData(
+ "{\"ints\": [1, 2, 3], \"doubles\": [1.5,
2.5], \"bools\": [true, false], \"withNull\": [1, null, 3], \"bigints\": [1,
9999999999]}")
+ .andDataTypes(STRING())
+ .testResult(
+ $("f0").jsonQuery("$.ints", ARRAY(INT())),
+ "JSON_QUERY(f0, '$.ints' RETURNING
ARRAY<INT>)",
+ new Integer[] {1, 2, 3},
+ ARRAY(INT()))
+ .testResult(
+ $("f0").jsonQuery("$.ints", ARRAY(TINYINT())),
+ "JSON_QUERY(f0, '$.ints' RETURNING
ARRAY<TINYINT>)",
+ new Byte[] {1, 2, 3},
+ ARRAY(TINYINT()))
+ .testResult(
+ $("f0").jsonQuery("$.ints", ARRAY(SMALLINT())),
+ "JSON_QUERY(f0, '$.ints' RETURNING
ARRAY<SMALLINT>)",
+ new Short[] {1, 2, 3},
+ ARRAY(SMALLINT()))
+ .testResult(
+ $("f0").jsonQuery("$.ints", ARRAY(BIGINT())),
+ "JSON_QUERY(f0, '$.ints' RETURNING
ARRAY<BIGINT>)",
+ new Long[] {1L, 2L, 3L},
+ ARRAY(BIGINT()))
+ .testResult(
+ $("f0").jsonQuery("$.bigints",
ARRAY(BIGINT())),
+ "JSON_QUERY(f0, '$.bigints' RETURNING
ARRAY<BIGINT>)",
+ new Long[] {1L, 9999999999L},
+ ARRAY(BIGINT()))
+ .testResult(
+ $("f0").jsonQuery("$.doubles",
ARRAY(DOUBLE())),
+ "JSON_QUERY(f0, '$.doubles' RETURNING
ARRAY<DOUBLE>)",
+ new Double[] {1.5, 2.5},
+ ARRAY(DOUBLE()))
+ .testResult(
+ $("f0").jsonQuery("$.doubles", ARRAY(FLOAT())),
+ "JSON_QUERY(f0, '$.doubles' RETURNING
ARRAY<FLOAT>)",
+ new Float[] {1.5f, 2.5f},
+ ARRAY(FLOAT()))
+ .testResult(
+ $("f0").jsonQuery("$.bools", ARRAY(BOOLEAN())),
+ "JSON_QUERY(f0, '$.bools' RETURNING
ARRAY<BOOLEAN>)",
+ new Boolean[] {true, false},
+ ARRAY(BOOLEAN()))
+ .testResult(
+ $("f0").jsonQuery("$.withNull", ARRAY(INT())),
+ "JSON_QUERY(f0, '$.withNull' RETURNING
ARRAY<INT>)",
+ new Integer[] {1, null, 3},
+ ARRAY(INT()))
Review Comment:
Added.
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/functions/JsonFunctionsITCase.java:
##########
@@ -886,7 +1083,214 @@ private static List<TestSetSpec> jsonQuerySpec() {
.testTableApiRuntimeError(
$("f0").jsonQuery("strict $.err10",
WITHOUT_ARRAY, NULL, ERROR),
TableRuntimeException.class,
- "No results for path"));
+ "No results for path"),
+
+ // Typed RETURNING ARRAY<T> support
+ TestSetSpec.forFunction(BuiltInFunctionDefinitions.JSON_QUERY)
+ .onFieldsWithData(
+ "{\"ints\": [1, 2, 3], \"doubles\": [1.5,
2.5], \"bools\": [true, false], \"withNull\": [1, null, 3], \"bigints\": [1,
9999999999]}")
Review Comment:
Added three cases: `[0, 1]` converts to `{false, true}` (integer 0/1 to
boolean), `["yes", "no"]` converts to `{true, false}` (recognized strings), and
`["Y", "n"]` returns null ("Y"/"n" are not in the accepted set for
`parseStringAsBoolean`).
--
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]