This is an automated email from the ASF dual-hosted git repository.

snuyanzin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/master by this push:
     new d9e5778d595 [FLINK-38608][table] Drop abandoned plans without related 
tests
d9e5778d595 is described below

commit d9e5778d5957921ab7cd79bdba6ac6d451fbd512
Author: Sergey Nuyanzin <[email protected]>
AuthorDate: Mon Nov 3 21:08:01 2025 +0100

    [FLINK-38608][table] Drop abandoned plans without related tests
---
 .../flink/table/planner/AbandonedPlanTest.java     | 111 ++++++++++++++
 .../plan/rules/logical/JoinToMultiJoinRuleTest.xml |  56 -------
 .../plan/rules/logical/RewriteCoalesceRuleTest.xml | 164 ---------------------
 3 files changed, 111 insertions(+), 220 deletions(-)

diff --git 
a/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/AbandonedPlanTest.java
 
b/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/AbandonedPlanTest.java
new file mode 100644
index 00000000000..ac99476007e
--- /dev/null
+++ 
b/flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/AbandonedPlanTest.java
@@ -0,0 +1,111 @@
+/*
+ * 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;
+
+import org.junit.jupiter.api.Test;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.function.Function;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Test to check whether there is a plan without any corresponding test. */
+class AbandonedPlanTest {
+    @Test
+    void testIfThereAreAbandonedPlans() {
+        final Path resources = Paths.get("src", "test", "resources");
+        final String packageName =
+                AbandonedPlanTest.class.getPackageName().replace(".", 
File.separator);
+        final Path resourcePath = Paths.get(resources.toString(), packageName);
+        final Set<String> plans = new HashSet<>();
+        walk(
+                resourcePath,
+                path -> {
+                    if (path.toString().endsWith("Test.xml")) {
+                        plans.add(
+                                path.toString()
+                                        .replace(resources.toString(), "")
+                                        .replace(".xml", ""));
+                    }
+                    return FileVisitResult.CONTINUE;
+                });
+
+        final Path javaTestPath = Paths.get("src", "test", "java");
+        final Path scalaTestPath = Paths.get("src", "test", "scala");
+        final Path pathForJavaClasses = Paths.get(javaTestPath.toString(), 
packageName);
+        walk(
+                pathForJavaClasses,
+                path -> {
+                    if (path.toString().endsWith("Test.java")) {
+                        plans.remove(
+                                path.toString()
+                                        .replace(javaTestPath.toString(), "")
+                                        .replace(".java", ""));
+                        if (plans.isEmpty()) {
+                            return FileVisitResult.TERMINATE;
+                        }
+                    }
+                    return FileVisitResult.CONTINUE;
+                });
+
+        final Path pathForScalaClasses = Paths.get(scalaTestPath.toString(), 
packageName);
+        walk(
+                pathForScalaClasses,
+                path -> {
+                    if (path.toString().endsWith("Test.scala")) {
+                        plans.remove(
+                                path.toString()
+                                        .replace(scalaTestPath.toString(), "")
+                                        .replace(".scala", ""));
+                        if (plans.isEmpty()) {
+                            return FileVisitResult.TERMINATE;
+                        }
+                    }
+                    return FileVisitResult.CONTINUE;
+                });
+
+        assertThat(plans.stream().map(p -> p + ".xml"))
+                .as("There are xml plans without corresponding java or scala 
tests")
+                .isEmpty();
+    }
+
+    private void walk(Path startPath, Function<Path, FileVisitResult> 
function) {
+        try {
+            Files.walkFileTree(
+                    startPath,
+                    new SimpleFileVisitor<>() {
+                        @Override
+                        public FileVisitResult visitFile(Path file, 
BasicFileAttributes attrs) {
+                            return function.apply(file);
+                        }
+                    });
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
+}
diff --git 
a/flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/rules/logical/JoinToMultiJoinRuleTest.xml
 
b/flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/rules/logical/JoinToMultiJoinRuleTest.xml
deleted file mode 100644
index bd6e95faf3d..00000000000
--- 
a/flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/rules/logical/JoinToMultiJoinRuleTest.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-<?xml version="1.0" ?>
-<!--
-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.
--->
-<Root>
-  <TestCase name="testLeftOuterJoinRightOuterJoinToMultiJoin">
-    <Resource name="explain">
-      <![CDATA[== Abstract Syntax Tree ==
-LogicalProject(a1=[$0], b1=[$1], c1=[$2], a2=[$3], b2=[$4], c2=[$5], a3=[$6], 
b3=[$7], c3=[$8])
-+- LogicalJoin(condition=[=($0, $6)], joinType=[left])
-   :- LogicalJoin(condition=[=($0, $3)], joinType=[right])
-   :  :- LogicalTableScan(table=[[default_catalog, default_database, t1]])
-   :  +- LogicalTableScan(table=[[default_catalog, default_database, t2]])
-   +- LogicalProject(a3=[$0], b3=[$1], c3=[$2])
-      +- LogicalTableScan(table=[[default_catalog, default_database, t3]])
-
-== Optimized Physical Plan ==
-HashJoin(joinType=[LeftOuterJoin], where=[=(a1, a3)], select=[a1, b1, c1, a2, 
b2, c2, a3, b3, c3], build=[right])
-:- Exchange(distribution=[hash[a1]])
-:  +- Calc(select=[a1, b1, c1, a2, b2, c2])
-:     +- HashJoin(joinType=[LeftOuterJoin], where=[=(a1, a2)], select=[a2, b2, 
c2, a1, b1, c1], build=[right])
-:        :- Exchange(distribution=[hash[a2]])
-:        :  +- TableSourceScan(table=[[default_catalog, default_database, 
t2]], fields=[a2, b2, c2])
-:        +- Exchange(distribution=[hash[a1]])
-:           +- TableSourceScan(table=[[default_catalog, default_database, 
t1]], fields=[a1, b1, c1])
-+- Exchange(distribution=[hash[a3]])
-   +- TableSourceScan(table=[[default_catalog, default_database, t3]], 
fields=[a3, b3, c3])
-
-== Optimized Execution Plan ==
-HashJoin(joinType=[LeftOuterJoin], where=[(a1 = a3)], select=[a1, b1, c1, a2, 
b2, c2, a3, b3, c3], build=[right])
-:- Exchange(distribution=[hash[a1]])
-:  +- Calc(select=[a1, b1, c1, a2, b2, c2])
-:     +- HashJoin(joinType=[LeftOuterJoin], where=[(a1 = a2)], select=[a2, b2, 
c2, a1, b1, c1], build=[right])
-:        :- Exchange(distribution=[hash[a2]])
-:        :  +- TableSourceScan(table=[[default_catalog, default_database, 
t2]], fields=[a2, b2, c2])
-:        +- Exchange(distribution=[hash[a1]])
-:           +- TableSourceScan(table=[[default_catalog, default_database, 
t1]], fields=[a1, b1, c1])
-+- Exchange(distribution=[hash[a3]])
-   +- TableSourceScan(table=[[default_catalog, default_database, t3]], 
fields=[a3, b3, c3])
-]]>
-    </Resource>
-  </TestCase>
-</Root>
diff --git 
a/flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/rules/logical/RewriteCoalesceRuleTest.xml
 
b/flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/rules/logical/RewriteCoalesceRuleTest.xml
deleted file mode 100644
index 3e4258d3e72..00000000000
--- 
a/flink-table/flink-table-planner/src/test/resources/org/apache/flink/table/planner/plan/rules/logical/RewriteCoalesceRuleTest.xml
+++ /dev/null
@@ -1,164 +0,0 @@
-<?xml version="1.0" ?>
-<!--
-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.
--->
-<Root>
-  <TestCase name="testCalcite1018">
-    <Resource name="sql">
-      <![CDATA[
-select * from (select * from scott_emp) e left join (
-    select * from scott_dept d) using (deptno)
-    order by empno limit 10
-      ]]>
-    </Resource>
-    <Resource name="ast">
-      <![CDATA[
-LogicalSort(sort0=[$1], dir0=[ASC-nulls-first], fetch=[10])
-+- LogicalProject(deptno=[COALESCE($7, $8)], empno=[$0], ename=[$1], job=[$2], 
mgr=[$3], hiredate=[$4], sal=[$5], comm=[$6], dname=[$9], loc=[$10])
-   +- LogicalJoin(condition=[=($7, $8)], joinType=[left])
-      :- LogicalProject(empno=[$0], ename=[$1], job=[$2], mgr=[$3], 
hiredate=[$4], sal=[$5], comm=[$6], deptno=[$7])
-      :  +- LogicalTableScan(table=[[default_catalog, default_database, 
scott_emp, source: [TestTableSource(empno, ename, job, mgr, hiredate, sal, 
comm, deptno)]]])
-      +- LogicalProject(deptno=[$0], dname=[$1], loc=[$2])
-         +- LogicalTableScan(table=[[default_catalog, default_database, 
scott_dept, source: [TestTableSource(deptno, dname, loc)]]])
-]]>
-    </Resource>
-    <Resource name="optimized rel plan">
-      <![CDATA[
-LogicalSort(sort0=[$1], dir0=[ASC-nulls-first], fetch=[10])
-+- LogicalProject($f0=[CASE(IS NOT NULL($7), $7, $8)], empno=[$0], ename=[$1], 
job=[$2], mgr=[$3], hiredate=[$4], sal=[$5], comm=[$6], dname=[$9], loc=[$10])
-   +- LogicalJoin(condition=[=($7, $8)], joinType=[left])
-      :- LogicalProject(empno=[$0], ename=[$1], job=[$2], mgr=[$3], 
hiredate=[$4], sal=[$5], comm=[$6], deptno=[$7])
-      :  +- LogicalTableScan(table=[[default_catalog, default_database, 
scott_emp, source: [TestTableSource(empno, ename, job, mgr, hiredate, sal, 
comm, deptno)]]])
-      +- LogicalProject(deptno=[$0], dname=[$1], loc=[$2])
-         +- LogicalTableScan(table=[[default_catalog, default_database, 
scott_dept, source: [TestTableSource(deptno, dname, loc)]]])
-]]>
-    </Resource>
-  </TestCase>
-  <TestCase name="testCoalesceConstantReduce">
-    <Resource name="sql">
-      <![CDATA[
-select * from lateral (select * from scott_emp) as e
-    join (table scott_dept) using (deptno)
-    where e.deptno = 10
-      ]]>
-    </Resource>
-    <Resource name="ast">
-      <![CDATA[
-LogicalProject(deptno=[COALESCE($7, $8)], empno=[$0], ename=[$1], job=[$2], 
mgr=[$3], hiredate=[$4], sal=[$5], comm=[$6], dname=[$9], loc=[$10])
-+- LogicalFilter(condition=[=($7, 10)])
-   +- LogicalJoin(condition=[=($7, $8)], joinType=[inner])
-      :- LogicalProject(empno=[$0], ename=[$1], job=[$2], mgr=[$3], 
hiredate=[$4], sal=[$5], comm=[$6], deptno=[$7])
-      :  +- LogicalTableScan(table=[[default_catalog, default_database, 
scott_emp, source: [TestTableSource(empno, ename, job, mgr, hiredate, sal, 
comm, deptno)]]])
-      +- LogicalProject(deptno=[$0], dname=[$1], loc=[$2])
-         +- LogicalTableScan(table=[[default_catalog, default_database, 
scott_dept, source: [TestTableSource(deptno, dname, loc)]]])
-]]>
-    </Resource>
-    <Resource name="optimized rel plan">
-      <![CDATA[
-LogicalProject($f0=[CAST(10):INTEGER], empno=[$0], ename=[$1], job=[$2], 
mgr=[$3], hiredate=[$4], sal=[$5], comm=[$6], dname=[$9], loc=[$10])
-+- LogicalFilter(condition=[=($7, 10)])
-   +- LogicalJoin(condition=[=($7, $8)], joinType=[inner])
-      :- LogicalProject(empno=[$0], ename=[$1], job=[$2], mgr=[$3], 
hiredate=[$4], sal=[$5], comm=[$6], deptno=[$7])
-      :  +- LogicalTableScan(table=[[default_catalog, default_database, 
scott_emp, source: [TestTableSource(empno, ename, job, mgr, hiredate, sal, 
comm, deptno)]]])
-      +- LogicalProject(deptno=[$0], dname=[$1], loc=[$2])
-         +- LogicalTableScan(table=[[default_catalog, default_database, 
scott_dept, source: [TestTableSource(deptno, dname, loc)]]])
-]]>
-    </Resource>
-  </TestCase>
-  <TestCase name="testNaturalJoinLeftOuter">
-    <Resource name="sql">
-      <![CDATA[
-SELECT * FROM scott_dept
-    natural left join scott_emp
-    order by scott_dept.deptno, scott_emp.deptno
-      ]]>
-    </Resource>
-    <Resource name="ast">
-      <![CDATA[
-LogicalProject(deptno=[$0], dname=[$1], loc=[$2], empno=[$3], ename=[$4], 
job=[$5], mgr=[$6], hiredate=[$7], sal=[$8], comm=[$9])
-+- LogicalSort(sort0=[$10], sort1=[$11], dir0=[ASC-nulls-first], 
dir1=[ASC-nulls-first])
-   +- LogicalProject(deptno=[COALESCE($0, $10)], dname=[$1], loc=[$2], 
empno=[$3], ename=[$4], job=[$5], mgr=[$6], hiredate=[$7], sal=[$8], comm=[$9], 
deptno0=[$0], deptno1=[$10])
-      +- LogicalJoin(condition=[=($0, $10)], joinType=[left])
-         :- LogicalTableScan(table=[[default_catalog, default_database, 
scott_dept, source: [TestTableSource(deptno, dname, loc)]]])
-         +- LogicalTableScan(table=[[default_catalog, default_database, 
scott_emp, source: [TestTableSource(empno, ename, job, mgr, hiredate, sal, 
comm, deptno)]]])
-]]>
-    </Resource>
-    <Resource name="optimized rel plan">
-      <![CDATA[
-LogicalProject(deptno=[$0], dname=[$1], loc=[$2], empno=[$3], ename=[$4], 
job=[$5], mgr=[$6], hiredate=[$7], sal=[$8], comm=[$9])
-+- LogicalSort(sort0=[$10], sort1=[$11], dir0=[ASC-nulls-first], 
dir1=[ASC-nulls-first])
-   +- LogicalProject($f0=[CASE(IS NOT NULL($0), $0, $10)], dname=[$1], 
loc=[$2], empno=[$3], ename=[$4], job=[$5], mgr=[$6], hiredate=[$7], sal=[$8], 
comm=[$9], deptno=[$0], deptno0=[$10])
-      +- LogicalJoin(condition=[=($0, $10)], joinType=[left])
-         :- LogicalTableScan(table=[[default_catalog, default_database, 
scott_dept, source: [TestTableSource(deptno, dname, loc)]]])
-         +- LogicalTableScan(table=[[default_catalog, default_database, 
scott_emp, source: [TestTableSource(empno, ename, job, mgr, hiredate, sal, 
comm, deptno)]]])
-]]>
-    </Resource>
-  </TestCase>
-  <TestCase name="testNaturalJoinRightOuter">
-    <Resource name="sql">
-      <![CDATA[
-SELECT * FROM scott_dept
-    natural right join scott_emp
-    order by scott_dept.deptno, scott_emp.deptno
-      ]]>
-    </Resource>
-    <Resource name="ast">
-      <![CDATA[
-LogicalProject(deptno=[$0], dname=[$1], loc=[$2], empno=[$3], ename=[$4], 
job=[$5], mgr=[$6], hiredate=[$7], sal=[$8], comm=[$9])
-+- LogicalSort(sort0=[$10], sort1=[$11], dir0=[ASC-nulls-first], 
dir1=[ASC-nulls-first])
-   +- LogicalProject(deptno=[COALESCE($0, $10)], dname=[$1], loc=[$2], 
empno=[$3], ename=[$4], job=[$5], mgr=[$6], hiredate=[$7], sal=[$8], comm=[$9], 
deptno0=[$0], deptno1=[$10])
-      +- LogicalJoin(condition=[=($0, $10)], joinType=[right])
-         :- LogicalTableScan(table=[[default_catalog, default_database, 
scott_dept, source: [TestTableSource(deptno, dname, loc)]]])
-         +- LogicalTableScan(table=[[default_catalog, default_database, 
scott_emp, source: [TestTableSource(empno, ename, job, mgr, hiredate, sal, 
comm, deptno)]]])
-]]>
-    </Resource>
-    <Resource name="optimized rel plan">
-      <![CDATA[
-LogicalProject(deptno=[$0], dname=[$1], loc=[$2], empno=[$3], ename=[$4], 
job=[$5], mgr=[$6], hiredate=[$7], sal=[$8], comm=[$9])
-+- LogicalSort(sort0=[$10], sort1=[$11], dir0=[ASC-nulls-first], 
dir1=[ASC-nulls-first])
-   +- LogicalProject($f0=[CASE(IS NOT NULL($0), $0, $10)], dname=[$1], 
loc=[$2], empno=[$3], ename=[$4], job=[$5], mgr=[$6], hiredate=[$7], sal=[$8], 
comm=[$9], deptno=[$0], deptno0=[$10])
-      +- LogicalJoin(condition=[=($0, $10)], joinType=[right])
-         :- LogicalTableScan(table=[[default_catalog, default_database, 
scott_dept, source: [TestTableSource(deptno, dname, loc)]]])
-         +- LogicalTableScan(table=[[default_catalog, default_database, 
scott_emp, source: [TestTableSource(empno, ename, job, mgr, hiredate, sal, 
comm, deptno)]]])
-]]>
-    </Resource>
-  </TestCase>
-  <TestCase name="testNaturalJoinWithPredicates">
-    <Resource name="sql">
-      <![CDATA[
-select * from scott_dept natural join scott_emp where empno = 1
-      ]]>
-    </Resource>
-    <Resource name="ast">
-      <![CDATA[
-LogicalProject(deptno=[COALESCE($0, $10)], dname=[$1], loc=[$2], empno=[$3], 
ename=[$4], job=[$5], mgr=[$6], hiredate=[$7], sal=[$8], comm=[$9])
-+- LogicalFilter(condition=[=($3, 1)])
-   +- LogicalJoin(condition=[=($0, $10)], joinType=[inner])
-      :- LogicalTableScan(table=[[default_catalog, default_database, 
scott_dept, source: [TestTableSource(deptno, dname, loc)]]])
-      +- LogicalTableScan(table=[[default_catalog, default_database, 
scott_emp, source: [TestTableSource(empno, ename, job, mgr, hiredate, sal, 
comm, deptno)]]])
-]]>
-    </Resource>
-    <Resource name="optimized rel plan">
-      <![CDATA[
-LogicalProject($f0=[CASE(IS NOT NULL($0), $0, $10)], dname=[$1], loc=[$2], 
empno=[CAST(1):INTEGER], ename=[$4], job=[$5], mgr=[$6], hiredate=[$7], 
sal=[$8], comm=[$9])
-+- LogicalFilter(condition=[=($3, 1)])
-   +- LogicalJoin(condition=[=($0, $10)], joinType=[inner])
-      :- LogicalTableScan(table=[[default_catalog, default_database, 
scott_dept, source: [TestTableSource(deptno, dname, loc)]]])
-      +- LogicalTableScan(table=[[default_catalog, default_database, 
scott_emp, source: [TestTableSource(empno, ename, job, mgr, hiredate, sal, 
comm, deptno)]]])
-]]>
-    </Resource>
-  </TestCase>
-</Root>

Reply via email to