snuyanzin commented on code in PR #28688:
URL: https://github.com/apache/flink/pull/28688#discussion_r3577683891
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/codegen/JsonParseReuseTest.java:
##########
@@ -165,4 +165,39 @@ void testDifferentJsonInputs() {
.as("JSON_VALUE calls on different inputs should parse
separately")
.isEqualTo(2);
}
+
+ @Test
+ void testTwoJsonLengthCalls() {
+ final String sql =
+ "SELECT JSON_LENGTH(json_data), JSON_LENGTH(json_data,
'$.address') FROM json_src";
+ final List<Row> rows = collect(sql);
+ assertThat(rows).containsExactlyInAnyOrder(Row.of(4, 1), Row.of(4, 1));
+ assertThat(countJsonParse(extractGeneratedCode(sql)))
+ .as("Two JSON_LENGTH calls on the same input should parse
once")
+ .isEqualTo(1);
+ }
+
+ @Test
+ void testJsonLengthAndJsonValueMixed() {
+ final String sql =
+ "SELECT JSON_LENGTH(json_data), JSON_VALUE(json_data,
'$.type') FROM json_src";
+ final List<Row> rows = collect(sql);
+ assertThat(rows).containsExactlyInAnyOrder(Row.of(4, "account"),
Row.of(4, "admin"));
+ assertThat(countJsonParse(extractGeneratedCode(sql)))
+ .as("JSON_LENGTH + JSON_VALUE on the same input should parse
once")
+ .isEqualTo(1);
Review Comment:
```suggestion
.isOne();
```
nit
--
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]