dawidwys commented on code in PR #23660: URL: https://github.com/apache/flink/pull/23660#discussion_r1386534891
########## flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/testutils/SortTestPrograms.java: ########## @@ -0,0 +1,121 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.table.planner.plan.nodes.exec.testutils; + +import org.apache.flink.table.planner.plan.nodes.exec.stream.StreamExecSortLimit; +import org.apache.flink.table.test.program.SinkTestStep; +import org.apache.flink.table.test.program.SourceTestStep; +import org.apache.flink.table.test.program.TableTestProgram; +import org.apache.flink.types.Row; + +/** {@link TableTestProgram} definitions for testing {@link StreamExecSortLimit}. */ +public class SortTestPrograms { + + static final TableTestProgram SORT_LIMIT_ASC = + TableTestProgram.of( + "sort-limit-asc", + "validates sort limit node by sorting integers in asc mode") + .setupTableSource( + SourceTestStep.newBuilder("source_t") + .addSchema("a INT", "b VARCHAR", "c INT") + .producedBeforeRestore( + Row.of(2, "a", 6), + Row.of(4, "b", 8), + Row.of(6, "c", 10), + Row.of(1, "a", 5), + Row.of(3, "b", 7), + Row.of(5, "c", 9)) + .producedAfterRestore( + Row.of(2, "a", 6), + Row.of(4, "b", 8), + Row.of(6, "c", 10), + Row.of(1, "a", 5), + Row.of(3, "b", 7), + Row.of(5, "c", 9)) Review Comment: Personally, I find this confusing. Having exact same data as an input twice is an artificial case. I think it rarely occurs in production use cases. Bear in mind this does not model the "replaying" case: reading from the same offset before and after restore. The API models a perfect source that stores the offsets in the checkpoint. Currently you model an input like (using only the first column for simplicity): ``` offset | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 data. | 2 | 4 | 6 | 1 | 3 | 5 | 2 | 4 | 6 | 1 | 3 | 5 ``` with a savepoint at offset `5`. In other words. If you were testing `SELECT a, COUNT(*) FROM t GROUP BY a;` you'd get (after materializing all updates of course): ``` a | COUNT(*) ------ 2 | 2 4 | 2 6 | 2 1 | 2 3 | 2 5 | 2 ``` Having said all that. I am not sure which property having the same data twice showcases? I find it even more confusing, because I am starting to see a pattern in using the same data twice in more PRs: https://github.com/apache/flink/pull/23675 Having such visible patterns easily caughts the attention and makes people wonder. If we want to test particular behaviour could we add a comment what is the role of each row, e.g. ``` .producedBeforeRestore( Row.of(2, "a", 6), Row.of(4, "b", 8), Row.of(6, "c", 10), Row.of(1, "a", 5), Row.of(3, "b", 7), Row.of(5, "c", 9)) .producedAfterRestore( Row.of(2, "a", 6), # should replace [3, b, 7] from before the restore Row.of(4, "b", 8), # should be ignored as it is "bigger" than the lowest [2, "a", 6] Row.of(6, "c", 10), # what is the added benefit? It's the same as the row above, right? Row.of(1, "a", 5), # should replace [2, a, 6] from before the restore Row.of(3, "b", 7), # can be removed, right? Row.of(5, "c", 9)) # can be removed, right? ``` -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org