You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by xi...@apache.org on 2025/04/20 22:37:06 UTC

(calcite) branch main updated: [CALCITE-6957] The RelOptRulesTest tests should fail if the xml file contains tests that do not exist in Java

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

xiong pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git


The following commit(s) were added to refs/heads/main by this push:
     new 9be4b4edde [CALCITE-6957] The RelOptRulesTest tests should fail if the xml file contains tests that do not exist in Java
9be4b4edde is described below

commit 9be4b4edde270ce38df0c42fa0cb5d21d014b7bb
Author: Xiong Duan <no...@gmail.com>
AuthorDate: Fri Apr 18 19:35:22 2025 +0800

    [CALCITE-6957] The RelOptRulesTest tests should fail if the xml file contains tests that do not exist in Java
---
 .../org/apache/calcite/test/RelOptRulesTest.xml    | 373 ---------------------
 .../apache/calcite/test/SqlToRelConverterTest.xml  |  13 -
 .../org/apache/calcite/test/DiffRepository.java    |  76 ++++-
 .../apache/calcite/test/DiffRepositoryTest.java    |  13 +
 .../org/apache/calcite/test/DiffRepositoryTest.xml |   2 +
 5 files changed, 77 insertions(+), 400 deletions(-)

diff --git a/core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml b/core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml
index f5d3ede283..c2062e20ac 100644
--- a/core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml
+++ b/core/src/test/resources/org/apache/calcite/test/RelOptRulesTest.xml
@@ -586,62 +586,6 @@ LogicalAggregate(group=[{7, 10}])
   LogicalJoin(condition=[=($7, $9)], joinType=[left])
     LogicalTableScan(table=[[CATALOG, SALES, EMP]])
     LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
-]]>
-    </Resource>
-  </TestCase>
-  <TestCase name="testAggregateJoinRemoveRule1">
-    <Resource name="sql">
-      <![CDATA[select count(distinct sal) from sales.emp e
-left outer join sales.dept d1 on e.job = d1.name
-left outer join sales.dept d2 on e.job = d2.name
-group by e.job
-]]>
-    </Resource>
-    <Resource name="planBefore">
-      <![CDATA[
-LogicalAggregate(group=[{0}], EXPR$1=[COUNT(DISTINCT $1)])
-  LogicalProject(JOB=[$2], NAME0=[$12])
-    LogicalJoin(condition=[=($2, $12)], joinType=[left])
-      LogicalJoin(condition=[=($2, $10)], joinType=[left])
-        LogicalTableScan(table=[[CATALOG, SALES, EMP]])
-        LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
-      LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
-]]>
-    </Resource>
-    <Resource name="planAfter">
-      <![CDATA[
-LogicalAggregate(group=[{2}], EXPR$1=[COUNT(DISTINCT $10)])
-  LogicalJoin(condition=[=($2, $10)], joinType=[left])
-    LogicalTableScan(table=[[CATALOG, SALES, EMP]])
-    LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
-]]>
-    </Resource>
-  </TestCase>
-  <TestCase name="testAggregateJoinRemoveRule2">
-    <Resource name="sql">
-      <![CDATA[select count(distinct sal) from sales.emp e
-left outer join sales.dept d1 on e.job = d1.name
-left outer join sales.dept d2 on e.job = d2.name
-group by e.job
-]]>
-    </Resource>
-    <Resource name="planBefore">
-      <![CDATA[
-LogicalAggregate(group=[{0, 1}])
-  LogicalProject(JOB=[$2], NAME=[$12])
-    LogicalJoin(condition=[=($2, $12)], joinType=[left])
-      LogicalJoin(condition=[=($2, $10)], joinType=[left])
-        LogicalTableScan(table=[[CATALOG, SALES, EMP]])
-        LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
-      LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
-]]>
-    </Resource>
-    <Resource name="planAfter">
-      <![CDATA[
-LogicalAggregate(group=[{2, 10}])
-  LogicalJoin(condition=[=($2, $10)], joinType=[left])
-    LogicalTableScan(table=[[CATALOG, SALES, EMP]])
-    LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
 ]]>
     </Resource>
   </TestCase>
@@ -2501,80 +2445,6 @@ LogicalProject(NAME=[$1])
           LogicalAggregate(group=[{0, 1, 2}])
             LogicalProject(SAL=[FIRST_VALUE($5) OVER (PARTITION BY $7 ORDER BY EXTRACT(FLAG(YEAR), $4) NULLS LAST, $5 DESC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)], EXPR$1=[FIRST_VALUE(EXTRACT(FLAG(YEAR), $4)) OVER (PARTITION BY $7 ORDER BY EXTRACT(FLAG(YEAR), $4) NULLS LAST, $5 DESC NULLS FIRST RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)], DEPTNO=[$7])
               LogicalTableScan(table=[[CATALOG, SALES, EMP]])
-]]>
-    </Resource>
-  </TestCase>
-  <TestCase name="testDecorrelateProjectFetchOne">
-    <Resource name="sql">
-      <![CDATA[SELECT name, (SELECT mgr FROM emp where dept.deptno = emp.deptno order by mgr limit 1) FROM dept]]>
-    </Resource>
-    <Resource name="planBefore">
-      <![CDATA[
-LogicalProject(variablesSet=[[$cor0]], NAME=[$1], EXPR$1=[$SCALAR_QUERY({
-LogicalSort(sort0=[$0], dir0=[ASC], fetch=[1])
-  LogicalProject(MGR=[$3])
-    LogicalFilter(condition=[=($cor0.DEPTNO, $7)])
-      LogicalTableScan(table=[[CATALOG, SALES, EMP]])
-})])
-  LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
-]]>
-    </Resource>
-    <Resource name="planMid">
-      <![CDATA[
-LogicalProject(NAME=[$1], EXPR$1=[$2])
-  LogicalCorrelate(correlation=[$cor0], joinType=[left], requiredColumns=[{0}])
-    LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
-    LogicalSort(sort0=[$0], dir0=[ASC], fetch=[1])
-      LogicalProject(MGR=[$3])
-        LogicalFilter(condition=[=($cor0.DEPTNO, $7)])
-          LogicalTableScan(table=[[CATALOG, SALES, EMP]])
-]]>
-    </Resource>
-    <Resource name="planAfter">
-      <![CDATA[
-LogicalProject(NAME=[$1], EXPR$1=[$3])
-  LogicalJoin(condition=[=($0, $2)], joinType=[left])
-    LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
-    LogicalAggregate(group=[{0}], agg#0=[MIN($1)])
-      LogicalProject(DEPTNO=[$7], MGR=[$3])
-        LogicalTableScan(table=[[CATALOG, SALES, EMP]])
-]]>
-    </Resource>
-  </TestCase>
-  <TestCase name="testDecorrelateProjectFetchOneDesc">
-    <Resource name="sql">
-      <![CDATA[SELECT name, (SELECT emp.mgr FROM emp WHERE dept.deptno = emp.deptno ORDER BY emp.mgr desc LIMIT 1) FROM dept]]>
-    </Resource>
-    <Resource name="planBefore">
-      <![CDATA[
-LogicalProject(variablesSet=[[$cor0]], NAME=[$1], EXPR$1=[$SCALAR_QUERY({
-LogicalSort(sort0=[$0], dir0=[DESC], fetch=[1])
-  LogicalProject(MGR=[$3])
-    LogicalFilter(condition=[=($cor0.DEPTNO, $7)])
-      LogicalTableScan(table=[[CATALOG, SALES, EMP]])
-})])
-  LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
-]]>
-    </Resource>
-    <Resource name="planMid">
-      <![CDATA[
-LogicalProject(NAME=[$1], EXPR$1=[$2])
-  LogicalCorrelate(correlation=[$cor0], joinType=[left], requiredColumns=[{0}])
-    LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
-    LogicalSort(sort0=[$0], dir0=[DESC], fetch=[1])
-      LogicalProject(MGR=[$3])
-        LogicalFilter(condition=[=($cor0.DEPTNO, $7)])
-          LogicalTableScan(table=[[CATALOG, SALES, EMP]])
-]]>
-    </Resource>
-    <Resource name="planAfter">
-      <![CDATA[
-LogicalProject(NAME=[$1], EXPR$1=[$3])
-  LogicalJoin(condition=[=($0, $2)], joinType=[left])
-    LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
-    LogicalAggregate(group=[{0}], agg#0=[MAX($1)])
-      LogicalProject(DEPTNO=[$7], MGR=[$3])
-        LogicalTableScan(table=[[CATALOG, SALES, EMP]])
 ]]>
     </Resource>
   </TestCase>
@@ -3796,23 +3666,6 @@ LogicalIntersect(all=[false])
     <Resource name="planAfter">
       <![CDATA[
 LogicalValues(tuples=[[]])
-]]>
-    </Resource>
-  </TestCase>
-  <TestCase name="testEmptyLimitZero">
-    <Resource name="sql">
-      <![CDATA[select * from emp order by deptno limit 0]]>
-    </Resource>
-    <Resource name="planBefore">
-      <![CDATA[
-SortRel(sort0=[$7], dir0=[Ascending], fetch=[0])
-  ProjectRel(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
-    TableAccessRel(table=[[CATALOG, SALES, EMP]])
-]]>
-    </Resource>
-    <Resource name="planAfter">
-      <![CDATA[
-EmptyRel
 ]]>
     </Resource>
   </TestCase>
@@ -4339,49 +4192,6 @@ LogicalProject(EMPNO=[$0])
           LogicalProject(i=[true])
             LogicalFilter(condition=[<($0, 20)])
               LogicalTableScan(table=[[CATALOG, SALES, EMP]])
-]]>
-    </Resource>
-  </TestCase>
-  <TestCase name="testExpandFilterExists3Value">
-    <Resource name="sql">
-      <![CDATA[select empno
-from sales.emp
-where empno
-  < case exists (select deptno from sales.emp where empno < 20)
-    when true then 10 when false then 20 else 30 end]]>
-    </Resource>
-    <Resource name="planBefore">
-      <![CDATA[
-LogicalProject(EMPNO=[$0])
-  LogicalFilter(condition=[<($0, CASE(=(IN($7, {
-LogicalProject(EXPR$0=[CASE(true, CAST($7):INTEGER, null)])
-  LogicalFilter(condition=[<($0, 20)])
-    LogicalTableScan(table=[[CATALOG, SALES, EMP]])
-}), true), 10, =(IN($7, {
-LogicalProject(EXPR$0=[CASE(true, CAST($7):INTEGER, null)])
-  LogicalFilter(condition=[<($0, 20)])
-    LogicalTableScan(table=[[CATALOG, SALES, EMP]])
-}), false), 20, 30))])
-    LogicalTableScan(table=[[CATALOG, SALES, EMP]])
-]]>
-    </Resource>
-    <Resource name="planAfter">
-      <![CDATA[
-LogicalProject(EMPNO=[$0])
-  LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
-    LogicalFilter(condition=[<($0, CASE(=(CASE(=($9, 0), false, IS NOT NULL($12), true, <($10, $9), null, false), true), 10, =(CASE(=($9, 0), false, IS NOT NULL($12), true, <($10, $9), null, false), false), 20, 30))])
-      LogicalJoin(condition=[=($7, $11)], joinType=[left])
-        LogicalJoin(condition=[true], joinType=[inner])
-          LogicalTableScan(table=[[CATALOG, SALES, EMP]])
-          LogicalAggregate(group=[{}], c=[COUNT()], ck=[COUNT($0)])
-            LogicalProject(EXPR$0=[CASE(true, CAST($7):INTEGER, null)])
-              LogicalFilter(condition=[<($0, 20)])
-                LogicalTableScan(table=[[CATALOG, SALES, EMP]])
-        LogicalAggregate(group=[{0, 1}])
-          LogicalProject(EXPR$0=[$0], i=[true])
-            LogicalProject(EXPR$0=[CASE(true, CAST($7):INTEGER, null)])
-              LogicalFilter(condition=[<($0, 20)])
-                LogicalTableScan(table=[[CATALOG, SALES, EMP]])
 ]]>
     </Resource>
   </TestCase>
@@ -8521,19 +8331,6 @@ from empm]]>
       <![CDATA[
 LogicalProject(DEPTNO=[$7], AVGSAL=[CAST(/(SUM($5) OVER (ROWS CURRENT ROW), COUNT($5) OVER (ROWS CURRENT ROW))):INTEGER NOT NULL])
   LogicalTableScan(table=[[CATALOG, SALES, EMP]])
-]]>
-    </Resource>
-  </TestCase>
-  <TestCase name="testMeasureWithoutGroupBy2">
-    <Resource name="sql">
-      <![CDATA[with empm as
-  (select *, avg(sal) as measure avgSal from emp)
-select deptno, avgSal from empm]]>
-    </Resource>
-    <Resource name="planBefore">
-      <![CDATA[
-LogicalProject(DEPTNO=[$7], AVGSAL=[CAST(/(SUM($5) OVER (), COUNT($5) OVER ())):INTEGER NOT NULL])
-  LogicalTableScan(table=[[CATALOG, SALES, EMP]])
 ]]>
     </Resource>
   </TestCase>
@@ -8797,45 +8594,6 @@ LogicalUnion(all=[false])
     LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
       LogicalFilter(condition=[=($7, 30)])
         LogicalTableScan(table=[[CATALOG, SALES, EMP]])
-]]>
-    </Resource>
-  </TestCase>
-  <TestCase name="testMergeUnion">
-    <Resource name="sql">
-      <![CDATA[select * from emp where deptno = 10
-union all
-select * from emp where deptno = 20
-union all
-select * from emp where deptno = 30
-]]>
-    </Resource>
-    <Resource name="planBefore">
-      <![CDATA[
-LogicalUnion(all=[true])
-  LogicalUnion(all=[true])
-    LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
-      LogicalFilter(condition=[=($7, 10)])
-        LogicalTableScan(table=[[CATALOG, SALES, EMP]])
-    LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
-      LogicalFilter(condition=[=($7, 20)])
-        LogicalTableScan(table=[[CATALOG, SALES, EMP]])
-  LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
-    LogicalFilter(condition=[=($7, 30)])
-      LogicalTableScan(table=[[CATALOG, SALES, EMP]])
-]]>
-    </Resource>
-    <Resource name="planAfter">
-      <![CDATA[
-LogicalUnion(all=[true])
-  LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
-    LogicalFilter(condition=[=($7, 10)])
-      LogicalTableScan(table=[[CATALOG, SALES, EMP]])
-  LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
-    LogicalFilter(condition=[=($7, 20)])
-      LogicalTableScan(table=[[CATALOG, SALES, EMP]])
-  LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
-    LogicalFilter(condition=[=($7, 30)])
-      LogicalTableScan(table=[[CATALOG, SALES, EMP]])
 ]]>
     </Resource>
   </TestCase>
@@ -11087,39 +10845,6 @@ LogicalProject(DEPTNO=[$0], NAME=[$1], EMPNO=[$2], ENAME=[$3], JOB=[$4], MGR=[$5
   LogicalJoin(condition=[AND(=($0, $9), >($0, $5))], joinType=[inner])
     LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
     LogicalTableScan(table=[[CATALOG, SALES, EMP]])
-]]>
-    </Resource>
-  </TestCase>
-  <TestCase name="testPushAggThroughUnion">
-    <Resource name="sql">
-      <![CDATA[select ename,sum(empno),count(*) from (select * from emp as e1 union all select * from emp as e2) group by ename]]>
-    </Resource>
-    <Resource name="planBefore">
-      <![CDATA[
-AggregateRel(group=[{0}], EXPR$1=[SUM($1)], EXPR$2=[COUNT()])
-  ProjectRel(ENAME=[$1], EMPNO=[$0])
-    UnionRel(all=[true])
-      ProjectRel(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
-        TableAccessRel(table=[[CATALOG, SALES, EMP]])
-      ProjectRel(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
-        TableAccessRel(table=[[CATALOG, SALES, EMP]])
-]]>
-    </Resource>
-    <Resource name="planAfter">
-      <![CDATA[
-ProjectRel(ENAME=[$0], EXPR$1=[$1], EXPR$2=[CAST($2):BIGINT NOT NULL])
-  AggregateRel(group=[{0}], EXPR$1=[SUM($1)], EXPR$2=[SUM($2)])
-    UnionRel(all=[true])
-      AggregateRel(group=[{0}], EXPR$1=[SUM($1)], EXPR$2=[COUNT()])
-        ProjectRel(ENAME=[$1], EMPNO=[$0])
-          ProjectRel(EMPNO=[$0], ENAME=[$1])
-            ProjectRel(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
-              TableAccessRel(table=[[CATALOG, SALES, EMP]])
-      AggregateRel(group=[{0}], EXPR$1=[SUM($1)], EXPR$2=[COUNT()])
-        ProjectRel(ENAME=[$1], EMPNO=[$0])
-          ProjectRel(EMPNO=[$0], ENAME=[$1])
-            ProjectRel(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
-              TableAccessRel(table=[[CATALOG, SALES, EMP]])
 ]]>
     </Resource>
   </TestCase>
@@ -12613,29 +12338,6 @@ LogicalProject(DNAME=[$1])
     LogicalTableScan(table=[[scott, DEPT]])
     LogicalFilter(condition=[=($5, 100)])
       LogicalTableScan(table=[[scott, EMP]])
-]]>
-    </Resource>
-  </TestCase>
-  <TestCase name="testPushFilterThroughOuterJoin">
-    <Resource name="sql">
-      <![CDATA[select 1 from sales.dept d left outer join sales.emp e on d.deptno = e.deptno where d.name = 'Charlie']]>
-    </Resource>
-    <Resource name="planBefore">
-      <![CDATA[
-ProjectRel(EXPR$0=[1])
-  FilterRel(condition=[=($1, 'Charlie')])
-    JoinRel(condition=[=($0, $9)], joinType=[left])
-      TableAccessRel(table=[[CATALOG, SALES, DEPT]])
-      TableAccessRel(table=[[CATALOG, SALES, EMP]])
-]]>
-    </Resource>
-    <Resource name="planAfter">
-      <![CDATA[
-ProjectRel(EXPR$0=[1])
-  JoinRel(condition=[=($0, $9)], joinType=[left])
-    FilterRel(condition=[=($1, 'Charlie')])
-      TableAccessRel(table=[[CATALOG, SALES, DEPT]])
-    TableAccessRel(table=[[CATALOG, SALES, EMP]])
 ]]>
     </Resource>
   </TestCase>
@@ -13251,35 +12953,6 @@ LogicalProject(EXPR$0=[$1], EXPR$1=[$0])
           LogicalTableScan(table=[[CATALOG, SALES, EMP]])
         LogicalProject(ENAME=[$0])
           LogicalTableScan(table=[[CATALOG, SALES, BONUS]])
-]]>
-    </Resource>
-  </TestCase>
-  <TestCase name="testPushProjectPastLeftJoinStrong">
-    <Resource name="sql">
-      <![CDATA[select count(*), case when e.sal < 11 then -1 * e.sal else e.sal end
-            from bonus b left outer join emp e on e.ename = b.ename group by
-            case when e.sal < 11 then -1 * e.sal else e.sal end]]>
-    </Resource>
-    <Resource name="planBefore">
-      <![CDATA[
-LogicalProject(EXPR$0=[$1], EXPR$1=[$0])
-  LogicalAggregate(group=[{0}], EXPR$0=[COUNT()])
-    LogicalProject(EXPR$1=[CASE(<($9, 11), *(-1, $9), $9)])
-      LogicalJoin(condition=[=($5, $0)], joinType=[left])
-        LogicalTableScan(table=[[CATALOG, SALES, BONUS]])
-        LogicalTableScan(table=[[CATALOG, SALES, EMP]])
-]]>
-    </Resource>
-    <Resource name="planAfter">
-      <![CDATA[
-LogicalProject(EXPR$0=[$1], EXPR$1=[$0])
-  LogicalAggregate(group=[{0}], EXPR$0=[COUNT()])
-    LogicalProject(EXPR$1=[$2])
-      LogicalJoin(condition=[=($1, $0)], joinType=[left])
-        LogicalProject(ENAME=[$0])
-          LogicalTableScan(table=[[CATALOG, SALES, BONUS]])
-        LogicalProject(ENAME=[$1], CASE=[CASE(<($5, 11), *(-1, $5), $5)])
-          LogicalTableScan(table=[[CATALOG, SALES, EMP]])
 ]]>
     </Resource>
   </TestCase>
@@ -15568,29 +15241,6 @@ LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$
 LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO0=[$9], NAME=[$10])
   LogicalProject(EMPNO=[CAST($0):INTEGER], ENAME=[CAST($1):VARCHAR(20)], JOB=[CAST($2):VARCHAR(10)], MGR=[$3], HIREDATE=[CAST($4):TIMESTAMP(0)], SAL=[CAST($5):INTEGER], COMM=[CAST($6):INTEGER], DEPTNO=[CAST($7):INTEGER], SLACKER=[CAST($8):BOOLEAN], DEPTNO0=[null:INTEGER], NAME=[null:VARCHAR(10)])
     LogicalTableScan(table=[[CATALOG, SALES, EMP]])
-]]>
-    </Resource>
-  </TestCase>
-  <TestCase name="testRightEmptyInnerCorrelate">
-    <Resource name="sql">
-      <![CDATA[select * from emp e where exists (select 1 from dept where empno=null)]]>
-    </Resource>
-    <Resource name="planBefore">
-      <![CDATA[
-LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
-  LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
-    LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{0}])
-      LogicalTableScan(table=[[CATALOG, SALES, EMP]])
-      LogicalValues(tuples=[[]])
-]]>
-    </Resource>
-    <Resource name="planAfter">
-      <![CDATA[
-LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
-  LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
-    LogicalJoin(condition=[true], joinType=[inner])
-      LogicalTableScan(table=[[CATALOG, SALES, EMP]])
-      LogicalValues(tuples=[[]])
 ]]>
     </Resource>
   </TestCase>
@@ -17915,29 +17565,6 @@ LogicalProject(EXPR$0=[1])
   LogicalJoin(condition=[=($7, $16)], joinType=[inner])
     LogicalTableScan(table=[[CATALOG, SALES, EMP]])
     LogicalTableScan(table=[[CATALOG, SALES, EMP]])
-]]>
-    </Resource>
-  </TestCase>
-  <TestCase name="testTransitiveInferenceConstantPredicate">
-    <Resource name="sql">
-      <![CDATA[select 1 from sales.emp d inner join sales.emp e on d.deptno = e.deptno  where 2 > 1]]>
-    </Resource>
-    <Resource name="planBefore">
-      <![CDATA[
-ProjectRel(EXPR$0=[1])
-  JoinRel(condition=[=($7, $16)], joinType=[inner])
-    FilterRel(condition=[>(2, 1)])
-      TableAccessRel(table=[[CATALOG, SALES, EMP]])
-    TableAccessRel(table=[[CATALOG, SALES, EMP]])
-]]>
-    </Resource>
-    <Resource name="planAfter">
-      <![CDATA[
-ProjectRel(EXPR$0=[1])
-  JoinRel(condition=[=($7, $16)], joinType=[inner])
-    FilterRel(condition=[>(2, 1)])
-      TableAccessRel(table=[[CATALOG, SALES, EMP]])
-    TableAccessRel(table=[[CATALOG, SALES, EMP]])
 ]]>
     </Resource>
   </TestCase>
diff --git a/core/src/test/resources/org/apache/calcite/test/SqlToRelConverterTest.xml b/core/src/test/resources/org/apache/calcite/test/SqlToRelConverterTest.xml
index 5229782822..316fb51ba5 100644
--- a/core/src/test/resources/org/apache/calcite/test/SqlToRelConverterTest.xml
+++ b/core/src/test/resources/org/apache/calcite/test/SqlToRelConverterTest.xml
@@ -5714,19 +5714,6 @@ LogicalSort(sort0=[$0], dir0=[DESC])
 LogicalSort(sort0=[$1], dir0=[ASC])
   LogicalProject(X=[+($0, 1)], Y=[-($0, 2)])
     LogicalTableScan(table=[[CATALOG, SALES, EMP]])
-]]>
-    </Resource>
-  </TestCase>
-  <TestCase name="testOrderByAliasDoesNotObscure">
-    <Resource name="sql">
-      <![CDATA[select empno + 1 as empno, empno - 2 as y from emp order by empno + 3]]>
-    </Resource>
-    <Resource name="plan">
-      <![CDATA[
-ProjectRel(EMPNO=[$0], Y=[$1])
-  SortRel(sort0=[$2], dir0=[Ascending])
-    ProjectRel(EMPNO=[+($0, 1)], Y=[-($0, 2)], EXPR$2=[+($0, 3)])
-      TableAccessRel(table=[[SALES, EMP]])
 ]]>
     </Resource>
   </TestCase>
diff --git a/testkit/src/main/java/org/apache/calcite/test/DiffRepository.java b/testkit/src/main/java/org/apache/calcite/test/DiffRepository.java
index a6a6b9b110..46ab2f6ba0 100644
--- a/testkit/src/main/java/org/apache/calcite/test/DiffRepository.java
+++ b/testkit/src/main/java/org/apache/calcite/test/DiffRepository.java
@@ -46,13 +46,18 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.Writer;
+import java.lang.reflect.Method;
 import java.net.URL;
 import java.util.AbstractList;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
+import java.util.Map;
 import java.util.Objects;
+import java.util.Set;
 import java.util.SortedMap;
 import java.util.TreeMap;
+import java.util.stream.Collectors;
 import javax.xml.XMLConstants;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -194,6 +199,8 @@ public class DiffRepository {
   private final @Nullable DiffRepository baseRepository;
   private final int indent;
   private final ImmutableSortedSet<String> outOfOrderTests;
+  private final Boolean existsMethodOnlyInXml;
+  private final SortedMap<String, Node> xmlTestCases;
   private Document doc;
   private final Element root;
   private final URL refFile;
@@ -213,7 +220,7 @@ public class DiffRepository {
    */
   private DiffRepository(URL refFile, File logFile,
       @Nullable DiffRepository baseRepository, @Nullable Filter filter,
-      int indent) {
+      int indent, Set<String> javaTestMethods) {
     this.baseRepository = baseRepository;
     this.filter = filter;
     this.indent = indent;
@@ -237,7 +244,9 @@ private DiffRepository(URL refFile, File logFile,
         flushDoc();
       }
       this.root = doc.getDocumentElement();
-      outOfOrderTests = validate(this.root);
+      this.xmlTestCases = analyze(this.root);
+      existsMethodOnlyInXml = checkExists(this.root, javaTestMethods, this.xmlTestCases);
+      outOfOrderTests = validateOrder(this.root, this.xmlTestCases);
     } catch (ParserConfigurationException | SAXException e) {
       throw new RuntimeException("error while creating xml parser", e);
     }
@@ -246,6 +255,11 @@ private DiffRepository(URL refFile, File logFile,
   //~ Methods ----------------------------------------------------------------
 
   public void checkActualAndReferenceFiles() {
+    if (existsMethodOnlyInXml) {
+      modCount++;
+      flushDoc();
+    }
+
     if (!logFile.exists()) {
       return;
     }
@@ -617,11 +631,10 @@ private synchronized void flushDoc() {
     modCountAtLastWrite = modCount;
   }
 
-  /** Validates the root element.
+  /** Analyzes the root element.
    *
-   * <p>Returns the set of test names that are out of order in the reference
-   * file (empty if the reference file is fully sorted). */
-  private static ImmutableSortedSet<String> validate(Element root) {
+   * <p>Returns the set of test names that in the reference file. */
+  private static SortedMap<String, Node> analyze(Element root) {
     if (!root.getNodeName().equals(ROOT_TAG)) {
       throw new RuntimeException("expected root element of type '" + ROOT_TAG
           + "', but found '" + root.getNodeName() + "'");
@@ -631,8 +644,6 @@ private static ImmutableSortedSet<String> validate(Element root) {
     // tests are out of order.
     final SortedMap<String, Node> testCases = new TreeMap<>();
     final NodeList childNodes = root.getChildNodes();
-    final List<String> outOfOrderNames = new ArrayList<>();
-    String previousName = null;
     for (int i = 0; i < childNodes.getLength(); i++) {
       Node child = childNodes.item(i);
       if (child.getNodeName().equals(TEST_CASE_TAG)) {
@@ -641,13 +652,47 @@ private static ImmutableSortedSet<String> validate(Element root) {
         if (testCases.put(name, testCase) != null) {
           throw new RuntimeException("TestCase '" + name + "' is duplicate");
         }
-        if (previousName != null
-            && previousName.compareTo(name) > 0) {
-          outOfOrderNames.add(name);
-        }
-        previousName = name;
       }
     }
+    return testCases;
+  }
+
+  /** Checks if there are methods that only exist in XML.
+   *
+   * <p>Returns true if there are methods that only exist in XML. */
+  private static Boolean checkExists(Element root, Set<String> javaTestMethods,
+      Map<String, Node> testCases) {
+    final List<String> existsOnlyInXml = new ArrayList<>();
+    for (Map.Entry<String, Node> entry : testCases.entrySet()) {
+      String name = entry.getKey();
+      if (!javaTestMethods.contains(name)) {
+        existsOnlyInXml.add(name);
+      }
+    }
+    if (!existsOnlyInXml.isEmpty()) {
+      for (String value : existsOnlyInXml) {
+        root.removeChild(testCases.get(value));
+      }
+    }
+
+    return !existsOnlyInXml.isEmpty();
+  }
+
+  /** Validates the root element order.
+   *
+   * <p>Returns the set of test names that are out of order in the reference
+   * file (empty if the reference file is fully sorted). */
+  private static ImmutableSortedSet<String> validateOrder(Element root,
+      SortedMap<String, Node> testCases) {
+    String previousName = null;
+    final List<String> outOfOrderNames = new ArrayList<>();
+    for (Map.Entry<String, Node> entry : testCases.entrySet()) {
+      String name = entry.getKey();
+      if (previousName != null && previousName.compareTo(name) > 0) {
+        outOfOrderNames.add(name);
+      }
+      previousName = name;
+    }
 
     // If any nodes were out of order, rebuild the document in sorted order.
     if (!outOfOrderNames.isEmpty()) {
@@ -944,8 +989,11 @@ DiffRepository toRepo() {
           .replace(".xml", "_actual.xml");
       final File logFile = new File(logFilePath);
       assert !refFilePath.equals(logFile.getAbsolutePath());
+      Set<String> javaTestMethods =
+          Arrays.stream(clazz.getDeclaredMethods()).map(Method::getName)
+              .filter(name -> name.startsWith("test")).collect(Collectors.toSet());
       return new DiffRepository(refFile, logFile, baseRepository, filter,
-          indent);
+          indent, javaTestMethods);
     }
   }
 
diff --git a/testkit/src/test/java/org/apache/calcite/test/DiffRepositoryTest.java b/testkit/src/test/java/org/apache/calcite/test/DiffRepositoryTest.java
index e02b570ce4..e70b914838 100644
--- a/testkit/src/test/java/org/apache/calcite/test/DiffRepositoryTest.java
+++ b/testkit/src/test/java/org/apache/calcite/test/DiffRepositoryTest.java
@@ -44,4 +44,17 @@ public class DiffRepositoryTest {
     }
     assertThat("First assertion must always fail", assertPassed, is(false));
   }
+
+  @Test void testMethodOnlyExistsInXml() {
+    boolean assertPassed = false;
+    DiffRepository r = DiffRepository.lookup(DiffRepositoryTest.class);
+    final String actual = "testMethodOnlyExistsInXml1";
+    try {
+      r.checkActualAndReferenceFiles();
+      assertPassed = true;
+    } catch (IllegalArgumentException e) {
+      assertThat(e.getMessage(), containsString(actual));
+    }
+    assertThat("First assertion must always fail", assertPassed, is(false));
+  }
 }
diff --git a/testkit/src/test/resources/org/apache/calcite/test/DiffRepositoryTest.xml b/testkit/src/test/resources/org/apache/calcite/test/DiffRepositoryTest.xml
index 310d593140..96159215d3 100644
--- a/testkit/src/test/resources/org/apache/calcite/test/DiffRepositoryTest.xml
+++ b/testkit/src/test/resources/org/apache/calcite/test/DiffRepositoryTest.xml
@@ -22,4 +22,6 @@
 ]]>
     </Resource>
   </TestCase>
+  <TestCase name="testMethodOnlyExistsInXml"/>
+  <TestCase name="testMethodOnlyExistsInXml1"/>
 </Root>