File size: 7,668 Bytes
5a9e79d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | diff --git a/flink-clients/src/test/java/org/apache/flink/client/cli/ClientOptionsAugTest.java b/flink-clients/src/test/java/org/apache/flink/client/cli/ClientOptionsAugTest.java
new file mode 100644
index 00000000000..a8d6a1b885d
--- /dev/null
+++ b/flink-clients/src/test/java/org/apache/flink/client/cli/ClientOptionsAugTest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.client.cli;
+
+import org.apache.flink.configuration.Configuration;
+
+import org.junit.jupiter.api.Test;
+
+import java.time.Duration;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Additional regression coverage for unchanged client option configuration behavior. */
+class ClientOptionsAugTest {
+
+ @Test
+ void testClientTimeoutCopyKeepsConfigurationsIndependent() {
+ final Configuration original = new Configuration();
+ original.set(ClientOptions.CLIENT_TIMEOUT, Duration.ofSeconds(3));
+
+ final Configuration copy = new Configuration(original);
+ copy.set(ClientOptions.CLIENT_TIMEOUT, Duration.ofSeconds(7));
+
+ assertThat(original.get(ClientOptions.CLIENT_TIMEOUT))
+ .isEqualTo(Duration.ofSeconds(3));
+ assertThat(copy.get(ClientOptions.CLIENT_TIMEOUT)).isEqualTo(Duration.ofSeconds(7));
+ assertThat(new Configuration().get(ClientOptions.CLIENT_TIMEOUT))
+ .isEqualTo(ClientOptions.CLIENT_TIMEOUT.defaultValue());
+ }
+}
diff --git a/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/stream/sql/FromChangelogAugmentedValidationTest.java b/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/stream/sql/FromChangelogAugmentedValidationTest.java
new file mode 100644
index 00000000000..d8e4fa8dc0c
--- /dev/null
+++ b/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/stream/sql/FromChangelogAugmentedValidationTest.java
@@ -0,0 +1,118 @@
+/*
+ * 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.stream.sql;
+
+import org.apache.flink.table.api.TableConfig;
+import org.apache.flink.table.planner.plan.nodes.exec.stream.ProcessTableFunctionTestUtils.InvalidUpdatingSemanticsFunction;
+import org.apache.flink.table.planner.utils.TableTestBase;
+import org.apache.flink.table.planner.utils.TableTestUtil;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.apache.flink.core.testutils.FlinkAssertions.anyCauseMatches;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+/** Additional SQL validation tests for the FROM_CHANGELOG public process table function surface. */
+public class FromChangelogAugmentedValidationTest extends TableTestBase {
+
+ private TableTestUtil util;
+
+ @BeforeEach
+ void setup() {
+ util = streamTestUtil(TableConfig.getDefault());
+ util.tableEnv()
+ .executeSql(
+ "CREATE VIEW t AS SELECT * FROM "
+ + "(VALUES ('Bob', 12), ('Alice', 42)) AS T(name, score)");
+ }
+
+ @Test
+ void testRejectsEmptyOpDescriptor() {
+ createCdcStream("op STRING");
+ assertInvalidFromChangelog(
+ "SELECT * FROM FROM_CHANGELOG("
+ + "input => TABLE cdc_stream, "
+ + "op => DESCRIPTOR())",
+ "The descriptor for argument 'op' must contain exactly one column name.");
+ }
+
+ @Test
+ void testRejectsNonStringOpColumn() {
+ createCdcStream("op INT");
+ assertInvalidFromChangelog(
+ "SELECT * FROM FROM_CHANGELOG(input => TABLE cdc_stream)",
+ "The op column 'op' must be of STRING type");
+ }
+
+ @Test
+ void testRejectsDynamicOpMapping() {
+ createCdcStream("op STRING");
+ assertInvalidFromChangelog(
+ "SELECT * FROM FROM_CHANGELOG("
+ + "input => TABLE cdc_stream, "
+ + "op_mapping => MAP[UPPER('c'), 'INSERT'])",
+ "The 'op_mapping' argument must be a constant MAP literal.");
+ }
+
+ @Test
+ void testRejectsInvalidRowKindMapping() {
+ createCdcStream("op STRING");
+ assertInvalidFromChangelog(
+ "SELECT * FROM FROM_CHANGELOG("
+ + "input => TABLE cdc_stream, "
+ + "op_mapping => MAP['x', 'UPSERT'])",
+ "Unknown change operation: 'UPSERT'");
+ }
+
+ @Test
+ void testRejectsDuplicateRowKindMapping() {
+ createCdcStream("op STRING");
+ assertInvalidFromChangelog(
+ "SELECT * FROM FROM_CHANGELOG("
+ + "input => TABLE cdc_stream, "
+ + "op_mapping => MAP['c', 'INSERT', 'r', 'INSERT'])",
+ "Duplicate change operation: 'INSERT'");
+ }
+
+ @Test
+ void testRejectsUpsertOutputForRowSemanticTableArguments() {
+ util.addTemporarySystemFunction("f", InvalidUpdatingSemanticsFunction.class);
+ assertThatThrownBy(() -> util.verifyExecPlan("SELECT * FROM f(r => TABLE t)"))
+ .satisfies(
+ anyCauseMatches(
+ "PTFs that take table arguments with row semantics don't support upsert output. "
+ + "Table argument 'r' of function 'f' must use set semantics."));
+ }
+
+ private void createCdcStream(String opColumnDefinition) {
+ util.tableEnv()
+ .executeSql(
+ "CREATE TABLE cdc_stream ("
+ + " id INT,"
+ + opColumnDefinition
+ + ", name STRING"
+ + ") WITH ('connector' = 'values')");
+ }
+
+ private void assertInvalidFromChangelog(String sql, String message) {
+ assertThatThrownBy(() -> util.tableEnv().explainSql(sql))
+ .satisfies(anyCauseMatches(message));
+ }
+}
|