twalthr commented on code in PR #26076: URL: https://github.com/apache/flink/pull/26076#discussion_r1944576029
########## flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/stream/ProcessTableFunctionTestPrograms.java: ########## @@ -0,0 +1,266 @@ +/* + * 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.stream; + +import org.apache.flink.table.planner.plan.nodes.exec.stream.ProcessTableFunctionTestUtils.AtomicTypeWrappingFunction; +import org.apache.flink.table.planner.plan.nodes.exec.stream.ProcessTableFunctionTestUtils.ContextFunction; +import org.apache.flink.table.planner.plan.nodes.exec.stream.ProcessTableFunctionTestUtils.EmptyArgFunction; +import org.apache.flink.table.planner.plan.nodes.exec.stream.ProcessTableFunctionTestUtils.PojoArgsFunction; +import org.apache.flink.table.planner.plan.nodes.exec.stream.ProcessTableFunctionTestUtils.PojoCreatingFunction; +import org.apache.flink.table.planner.plan.nodes.exec.stream.ProcessTableFunctionTestUtils.ScalarArgsFunction; +import org.apache.flink.table.planner.plan.nodes.exec.stream.ProcessTableFunctionTestUtils.TableAsRowFunction; +import org.apache.flink.table.planner.plan.nodes.exec.stream.ProcessTableFunctionTestUtils.TableAsRowPassThroughFunction; +import org.apache.flink.table.planner.plan.nodes.exec.stream.ProcessTableFunctionTestUtils.TableAsSetFunction; +import org.apache.flink.table.planner.plan.nodes.exec.stream.ProcessTableFunctionTestUtils.TableAsSetOptionalPartitionFunction; +import org.apache.flink.table.planner.plan.nodes.exec.stream.ProcessTableFunctionTestUtils.TableAsSetPassThroughFunction; +import org.apache.flink.table.planner.plan.nodes.exec.stream.ProcessTableFunctionTestUtils.TableAsSetUpdatingArgFunction; +import org.apache.flink.table.planner.plan.nodes.exec.stream.ProcessTableFunctionTestUtils.TestProcessTableFunctionBase; +import org.apache.flink.table.planner.plan.nodes.exec.stream.ProcessTableFunctionTestUtils.TypedTableAsRowFunction; +import org.apache.flink.table.planner.plan.nodes.exec.stream.ProcessTableFunctionTestUtils.TypedTableAsSetFunction; +import org.apache.flink.table.test.program.SinkTestStep; +import org.apache.flink.table.test.program.TableTestProgram; + +/** {@link TableTestProgram} definitions for testing {@link StreamExecProcessTableFunction}. */ +public class ProcessTableFunctionTestPrograms { + + private static final String BASIC_VALUES = + "CREATE VIEW t AS SELECT * FROM (VALUES ('Bob', 12), ('Alice', 42)) AS T(name, score)"; + + private static final String UPDATING_VALUES = + "CREATE VIEW t AS SELECT name, COUNT(*) FROM " + + "(VALUES ('Bob', 12), ('Alice', 42), ('Bob', 14)) AS T(name, score) " + + "GROUP BY name"; + + /** Corresponds to {@link TestProcessTableFunctionBase}. */ + private static final String BASE_SINK_SCHEMA = "`out` STRING, `count` INT"; + + /** Corresponds to {@link TestProcessTableFunctionBase}. */ + private static final String KEYED_BASE_SINK_SCHEMA = "`name` STRING, `out` STRING, `count` INT"; + + /** Corresponds to {@link TestProcessTableFunctionBase}. */ + private static final String PASS_THROUGH_BASE_SINK_SCHEMA = + "`name` STRING, `score` INT, `out` STRING, `count` INT"; + + public static final TableTestProgram PROCESS_SCALAR_ARGS = + TableTestProgram.of("process-scalar-args", "no table as input") + .setupTemporarySystemFunction("f", ScalarArgsFunction.class) + .setupTableSink( + SinkTestStep.newBuilder("sink") + .addSchema(BASE_SINK_SCHEMA) + .consumedValues("+I[{42, true}, 1]", "+I[{42, true}, 2]") + .build()) + .runSql( + "INSERT INTO sink SELECT * FROM f(i => 42, b => CAST('TRUE' AS BOOLEAN))") + .build(); + + public static final TableTestProgram PROCESS_TABLE_AS_ROW = + TableTestProgram.of("process-row", "table with row semantics") + .setupTemporarySystemFunction("f", TableAsRowFunction.class) + .setupSql(BASIC_VALUES) + .setupTableSink( + SinkTestStep.newBuilder("sink") + .addSchema(BASE_SINK_SCHEMA) + .consumedValues( + "+I[{+I[Bob, 12], 1}, 1]", + "+I[{+I[Bob, 12], 1}, 2]", + "+I[{+I[Alice, 42], 1}, 1]", + "+I[{+I[Alice, 42], 1}, 2]") + .build()) + .runSql("INSERT INTO sink SELECT * FROM f(r => TABLE t, i => 1)") + .build(); + + public static final TableTestProgram PROCESS_TYPED_TABLE_AS_ROW = + TableTestProgram.of("process-typed-row", "typed table with row semantics") + .setupTemporarySystemFunction("f", TypedTableAsRowFunction.class) + .setupSql(BASIC_VALUES) + .setupTableSink( + SinkTestStep.newBuilder("sink") + .addSchema(BASE_SINK_SCHEMA) + .consumedValues( + "+I[{User(s='Bob', i=12), 1}, 1]", + "+I[{User(s='Bob', i=12), 1}, 2]", + "+I[{User(s='Alice', i=42), 1}, 1]", + "+I[{User(s='Alice', i=42), 1}, 2]") + .build()) + .runSql("INSERT INTO sink SELECT * FROM f(u => TABLE t, i => 1)") + .build(); + + public static final TableTestProgram PROCESS_TABLE_AS_SET = + TableTestProgram.of("process-set", "table with set semantics") + .setupTemporarySystemFunction("f", TableAsSetFunction.class) + .setupSql(BASIC_VALUES) + .setupTableSink( + SinkTestStep.newBuilder("sink") + .addSchema(KEYED_BASE_SINK_SCHEMA) + .consumedValues( + "+I[Bob, {+I[Bob, 12], 1}, 1]", + "+I[Bob, {+I[Bob, 12], 1}, 2]", Review Comment: I'm also annoyed by it nowadays. I will remove this. -- 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]
