raminqaf commented on code in PR #27901:
URL: https://github.com/apache/flink/pull/27901#discussion_r3092396288
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/stream/ProcessTableFunctionTestUtils.java:
##########
@@ -918,6 +918,19 @@ public void eval(Context ctx,
@ArgumentHint({ROW_SEMANTIC_TABLE, SUPPORT_UPDATES
collectUpdate(ctx, r);
}
+ @Override
+ public ChangelogMode getChangelogMode(ChangelogContext
changelogContext) {
+ return ChangelogMode.upsert(false);
+ }
+ }
+
+ /** Testing function that uses row semantics with retract mode (valid). */
+ public static class UpdatingRetractRowSemanticFunction
+ extends ChangelogProcessTableFunctionBase {
+ public void eval(Context ctx, @ArgumentHint({ROW_SEMANTIC_TABLE,
SUPPORT_UPDATES}) Row r) {
Review Comment:
Good catch! Addressed
##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/stream/FromChangelogTestPrograms.java:
##########
@@ -0,0 +1,239 @@
+/*
+ * 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.connector.ChangelogMode;
+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;
+import org.apache.flink.types.RowKind;
+
+/** {@link TableTestProgram} definitions for testing the built-in
FROM_CHANGELOG PTF. */
+public class FromChangelogTestPrograms {
+
+ private static final SourceTestStep SIMPLE_CDC_SOURCE =
+ SourceTestStep.newBuilder("cdc_stream")
+ .addSchema("id INT", "op STRING", "name STRING")
+ .producedValues(Row.of(1, "INSERT", "Alice"))
+ .build();
+
+ //
--------------------------------------------------------------------------------------------
+ // SQL tests
+ //
--------------------------------------------------------------------------------------------
+
+ public static final TableTestProgram DEFAULT_OP_MAPPING =
+ TableTestProgram.of(
+ "from-changelog-default-op-mapping",
+ "default mapping with standard op names")
+ .setupTableSource(
+ SourceTestStep.newBuilder("cdc_stream")
+ .addSchema("id INT", "op STRING", "name
STRING")
+ .producedValues(
+ Row.of(1, "INSERT", "Alice"),
+ Row.of(2, "INSERT", "Bob"),
+ Row.of(1, "UPDATE_BEFORE",
"Alice"),
+ Row.of(1, "UPDATE_AFTER",
"Alice2"),
+ Row.of(2, "DELETE", "Bob"))
+ .build())
+ .setupTableSink(
+ SinkTestStep.newBuilder("sink")
+ .addSchema(
+ "id INT NOT NULL",
+ "name STRING",
+ "PRIMARY KEY (id) NOT ENFORCED")
+ .consumedValues(
+ Row.ofKind(RowKind.INSERT, 1,
"Alice"),
+ Row.ofKind(RowKind.INSERT, 2,
"Bob"),
+ Row.ofKind(RowKind.UPDATE_BEFORE,
1, "Alice"),
+ Row.ofKind(RowKind.UPDATE_AFTER,
1, "Alice2"),
+ Row.ofKind(RowKind.DELETE, 2,
"Bob"))
+ .build())
+ .runSql(
+ "INSERT INTO sink SELECT * FROM FROM_CHANGELOG("
+ + "input => TABLE cdc_stream)")
+ .build();
+
+ public static final TableTestProgram DEBEZIUM_MAPPING =
+ TableTestProgram.of(
+ "from-changelog-custom-mapping",
+ "custom op_mapping with comma-separated keys")
+ .setupTableSource(
+ SourceTestStep.newBuilder("cdc_stream")
+ .addSchema("id INT", "__op STRING", "name
STRING")
Review Comment:
Removed all __op
--
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]