pnowojski commented on code in PR #29624: URL: https://github.com/apache/flink/pull/29624#discussion_r4402363915
########## flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/runtime/stream/sql/ValuesStreamingRestoreITCase.java: ########## @@ -0,0 +1,201 @@ +/* + * 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.runtime.stream.sql; + +import org.apache.flink.client.program.rest.RestClusterClient; +import org.apache.flink.configuration.CheckpointingOptions; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.configuration.CoreOptions; +import org.apache.flink.configuration.ExternalizedCheckpointRetention; +import org.apache.flink.configuration.RestartStrategyOptions; +import org.apache.flink.configuration.StateRecoveryOptions; +import org.apache.flink.core.execution.CheckpointType; +import org.apache.flink.core.execution.JobClient; +import org.apache.flink.runtime.execution.ExecutionState; +import org.apache.flink.runtime.minicluster.MiniCluster; +import org.apache.flink.runtime.rest.messages.job.JobDetailsInfo; +import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration; +import org.apache.flink.table.api.EnvironmentSettings; +import org.apache.flink.table.api.TableEnvironment; +import org.apache.flink.table.planner.factories.TestValuesTableFactory; +import org.apache.flink.test.junit5.InjectClusterClient; +import org.apache.flink.test.junit5.InjectMiniCluster; +import org.apache.flink.test.junit5.MiniClusterExtension; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.api.io.TempDir; + +import java.nio.file.Path; +import java.time.Duration; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import static org.apache.flink.runtime.testutils.CommonTestUtils.waitForAllTaskRunning; +import static org.apache.flink.runtime.testutils.CommonTestUtils.waitUntilCondition; +import static org.assertj.core.api.Assertions.assertThat; + +/** + * VALUES waits for one more checkpoint after emitting its rows before it exits (FLIP-147). That + * checkpoint is triggered while the task is still running, so it doesn't mark VALUES as finished. A + * job restored from it must not read the VALUES rows again. + */ +class ValuesStreamingRestoreITCase { Review Comment: Is it right that in both cases VALUES has emitted all its rows before the restored checkpoint, so the restore works because the task is marked finished (FLIP-147), not because of the checkpointed row position? If so, the only test of a restore halfway through the rows is `ValuesCodeGeneratorTest#testRestoreEmitsOnlyTheRemainingRows`. I think that's fine, but could you mention it in the class Javadoc so nobody drops that unit test later as a duplicate? ########## flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/TransformationsTest.java: ########## @@ -151,6 +153,43 @@ void testLegacyBatchValues() { assertBoundedness(Boundedness.BOUNDED, sourceTransform); } + @Test + void testStreamValues() { + final StreamTableEnvironment env = + StreamTableEnvironment.create( + StreamExecutionEnvironment.getExecutionEnvironment(), + EnvironmentSettings.newInstance().inStreamingMode().build()); + + final Table table = env.fromValues(1, 2, 3); + + assertBoundedness( + Boundedness.CONTINUOUS_UNBOUNDED, toValuesSourceTransformation(env, table)); + } + + @Test + void testStreamValuesWithoutRows() { Review Comment: This test doesn't check that the VALUES node actually has no rows. If the planner stopped reducing `WHERE id < 0` to an empty `Values`, the test would still pass while testing a normal one-row source. Could you assert that the plan really has an empty VALUES, e.g. that `explainSql` contains `Values(tuples=[[]])`? ########## flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/TransformationsTest.java: ########## @@ -496,6 +535,27 @@ private static LegacySourceTransformation<?> toLegacySourceTransformation( return (LegacySourceTransformation<?>) transform; } + private static SourceTransformation<?, ?, ?> toValuesSourceTransformation( Review Comment: These two helpers repeat the walk-to-the-leaf loop that `toLegacySourceTransformation` already has. Could we pull out a single `toLeaf(Transformation<?>)` and have the callers do their own `isInstanceOf` checks? -- 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]
