xuyangzhong commented on code in PR #18375:
URL: https://github.com/apache/flink/pull/18375#discussion_r1433633656
##########
flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/runtime/stream/sql/AggregateITCase.scala:
##########
@@ -1331,6 +1331,81 @@ class AggregateITCase(aggMode: AggMode, miniBatch:
MiniBatchMode, backend: State
assertThat(sink.getRetractResults.sorted).isEqualTo(expected.sorted)
}
+ @TestTemplate
+ def testMinMaxWithChar(): Unit = {
+ val data =
+ List(
+ rowOf(1, "a"),
+ rowOf(1, "b"),
+ rowOf(2, "d"),
+ rowOf(2, "c")
+ )
+ val dataId = TestValuesTableFactory.registerData(data)
+ tEnv.executeSql(s"""
+ |CREATE TABLE src(
+ | `id` INT,
+ | `char` CHAR(1)
+ |) WITH (
+ | 'connector' = 'values',
+ | 'data-id' = '$dataId'
+ |)
+ |""".stripMargin)
+
+ val sql =
+ """
+ |select `id`, count(*), min(`char`), max(`char`) from src group by `id`
+ """.stripMargin
+
+ val sink = new TestingRetractSink()
+ tEnv.sqlQuery(sql).toRetractStream[Row].addSink(sink)
+ env.execute()
+
+ val expected = List("1,2,a,b", "2,2,c,d")
+ assertThat(sink.getRetractResults.sorted).isEqualTo(expected.sorted)
+ }
+
+ @TestTemplate
+ def testRetractMinMaxWithChar(): Unit = {
+ val data =
+ List(
+ changelogRow("+I", Int.box(1), "a"),
+ changelogRow("+I", Int.box(1), "b"),
+ changelogRow("+I", Int.box(1), "c"),
+ changelogRow("-D", Int.box(1), "c"),
+ changelogRow("-D", Int.box(1), "a"),
+ changelogRow("+I", Int.box(2), "a"),
+ changelogRow("+I", Int.box(2), "b"),
+ changelogRow("+I", Int.box(2), "c"),
+ changelogRow("-U", Int.box(2), "b"),
+ changelogRow("+U", Int.box(2), "d"),
+ changelogRow("-U", Int.box(2), "a"),
+ changelogRow("+U", Int.box(2), "b")
+ )
+ val dataId = TestValuesTableFactory.registerData(data)
+ tEnv.executeSql(s"""
+ |CREATE TABLE src(
+ | `id` INT,
+ | `char` CHAR(1)
+ |) WITH (
+ | 'connector' = 'values',
Review Comment:
I have updated the test to add a new field with type "char(2)", and test it
with data that actually has a length of 1 or 2.
--
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]