gustavodemorais commented on code in PR #28836:
URL: https://github.com/apache/flink/pull/28836#discussion_r3675097602
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/codegen/JsonParseReuseTest.java:
##########
@@ -165,4 +242,38 @@ void testDifferentJsonInputs() {
.as("JSON_VALUE calls on different inputs should parse
separately")
.isEqualTo(2);
}
+
+ @Test
+ void testReuseInOverWindowQueryIsResetPerRow() {
+ // JSON scalars run in a Calc ahead of the OverAggregate; each row
must get its own parse
+ final TableEnvironment bEnv =
TableEnvironment.create(EnvironmentSettings.inBatchMode());
+ bEnv.createTemporaryView(
+ "over_src",
+ bEnv.fromValues(Row.of(1, JSON_ROW1), Row.of(2,
JSON_ROW2)).as("id", "j"));
+ final String sql =
+ "SELECT id, "
+ + "MAX(JSON_VALUE(j, '$.type')) OVER (ORDER BY id ROWS
BETWEEN CURRENT ROW AND CURRENT ROW), "
+ + "MAX(JSON_QUERY(j, '$.address')) OVER (ORDER BY id
ROWS BETWEEN CURRENT ROW AND CURRENT ROW) "
+ + "FROM over_src";
+ final List<Row> rows = new ArrayList<>();
+ bEnv.executeSql(sql).collect().forEachRemaining(rows::add);
+ assertThat(rows)
+ .containsExactlyInAnyOrder(
+ Row.of(1, "account", "{\"city\":\"Munich\"}"),
+ Row.of(2, "admin", "{\"city\":\"Berlin\"}"));
+ }
+
+ @Test
+ void testFilterAndProjectionShareParse() {
Review Comment:
All tests use a plain column: could you add a test using a computed column
like using TRIM(json_data) as the input to the json functions?
--
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]