<?xml version="1.0" ?>
<Root>
    <TestCase name="testFennelSortRule">
        <Resource name="sql">
            <![CDATA[select * from sales.depts order by deptno]]>
        </Resource>
        <Resource name="planBefore">
            <![CDATA[
SortRel(sort0=[$0], dir0=[Ascending])
  ProjectRel(DEPTNO=[$0], NAME=[$1])
    TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
]]>
        </Resource>
        <Resource name="planAfter">
            <![CDATA[
FennelSortRel(key=[[0]], discardDuplicates=[false])
  ProjectRel(DEPTNO=[$0], NAME=[$1])
    TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
]]>
        </Resource>
    </TestCase>
    <TestCase name="testFennelCartesianJoinRule">
        <Resource name="sql">
            <![CDATA[select 1 from sales.emps,sales.depts]]>
        </Resource>
        <Resource name="planBefore">
            <![CDATA[
ProjectRel(EXPR$0=[1])
  JoinRel(condition=[true], joinType=[inner])
    TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
    TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
]]>
        </Resource>
        <Resource name="planAfter">
            <![CDATA[
ProjectRel(EXPR$0=[1])
  FennelCartesianProductRel(leftouterjoin=[false])
    TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
    TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
]]>
        </Resource>
    </TestCase>
    <TestCase name="testFennelAggRule">
        <Resource name="sql">
            <![CDATA[select deptno from sales.depts group by deptno]]>
        </Resource>
        <Resource name="planBefore">
            <![CDATA[
AggregateRel(groupCount=[1])
  ProjectRel(DEPTNO=[$0])
    TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
]]>
        </Resource>
        <Resource name="planAfter">
            <![CDATA[
FennelAggRel(groupCount=[1])
  FennelSortRel(key=[[0]], discardDuplicates=[false])
    ProjectRel(DEPTNO=[$0])
      TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
]]>
        </Resource>
    </TestCase>
    <TestCase name="testFtrsTableAccessRule">
        <Resource name="sql">
            <![CDATA[select deptno from sales.depts]]>
        </Resource>
        <Resource name="planBefore">
            <![CDATA[
ProjectRel(DEPTNO=[$0])
  TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
]]>
        </Resource>
        <Resource name="planAfter">
            <![CDATA[
ProjectRel(DEPTNO=[$0])
  FtrsIndexScanRel(table=[[LOCALDB, SALES, DEPTS]], projection=[*], index=[SYS$CONSTRAINT_INDEX$SYS$PRIMARY_KEY$DEPTS], preserveOrder=[false])
]]>
        </Resource>
    </TestCase>
    <TestCase name="testFtrsScanToSearchRule">
        <Resource name="sql">
            <![CDATA[select * from sales.depts where deptno=5]]>
        </Resource>
        <Resource name="planBefore">
            <![CDATA[
ProjectRel(DEPTNO=[$0], NAME=[$1])
  FilterRel(condition=[=($0, 5)])
    TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
]]>
        </Resource>
        <Resource name="planAfter">
            <![CDATA[
ProjectRel(DEPTNO=[$0], NAME=[$1])
  FtrsIndexSearchRel(table=[[LOCALDB, SALES, DEPTS]], projection=[*], index=[SYS$CONSTRAINT_INDEX$SYS$PRIMARY_KEY$DEPTS], uniqueKey=[false], preserveOrder=[false], outer=[false], inputKeyProj=[[1, 3]], inputJoinProj=[[]], inputDirectiveProj=[[0, 2]])
    FennelValuesRel(tuples=[[{ '[', 5, ']', 5 }]])
]]>
        </Resource>
    </TestCase>
    <TestCase name="testFtrsTableProjectionRule">
        <Resource name="sql">
            <![CDATA[select name from sales.emps]]>
        </Resource>
        <Resource name="planBefore">
            <![CDATA[
ProjectRel(NAME=[$1])
  TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
]]>
        </Resource>
        <Resource name="planAfter">
            <![CDATA[
FtrsIndexScanRel(table=[[LOCALDB, SALES, EMPS]], projection=[[1]], index=[EMPS_UX], preserveOrder=[false])
]]>
        </Resource>
    </TestCase>
    <TestCase name="testFennelToIteratorConverterRule">
        <Resource name="sql">
            <![CDATA[select upper(name) from sales.emps]]>
        </Resource>
        <Resource name="planBefore">
            <![CDATA[
ProjectRel(EXPR$0=[UPPER($1)])
  TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
]]>
        </Resource>
        <Resource name="planAfter">
            <![CDATA[
IterCalcRel(expr#0..9=[{inputs}], expr#10=[UPPER($t1)], EXPR$0=[$t10])
  FennelToIteratorConverter
    FtrsIndexScanRel(table=[[LOCALDB, SALES, EMPS]], projection=[*], index=[SYS$CONSTRAINT_INDEX$SYS$PRIMARY_KEY$EMPS], preserveOrder=[false])
]]>
        </Resource>
    </TestCase>
    <TestCase name="testHeterogeneousConversion">
        <Resource name="sql">
            <![CDATA[select upper(name) from sales.emps union all select lower(name) from sales.emps]]>
        </Resource>
        <Resource name="planBefore">
            <![CDATA[
UnionRel(all=[true])
  ProjectRel(EXPR$0=[UPPER($1)])
    TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
  ProjectRel(EXPR$0=[LOWER($1)])
    TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
]]>
        </Resource>
        <Resource name="planAfter">
            <![CDATA[
UnionRel(all=[true])
  IterCalcRel(expr#0..9=[{inputs}], expr#10=[UPPER($t1)], EXPR$0=[$t10])
    FennelToIteratorConverter
      FtrsIndexScanRel(table=[[LOCALDB, SALES, EMPS]], projection=[*], index=[SYS$CONSTRAINT_INDEX$SYS$PRIMARY_KEY$EMPS], preserveOrder=[false])
  FennelCalcRel(expr#0..9=[{inputs}], expr#10=[LOWER($t1)], EXPR$0=[$t10])
    FtrsIndexScanRel(table=[[LOCALDB, SALES, EMPS]], projection=[*], index=[SYS$CONSTRAINT_INDEX$SYS$PRIMARY_KEY$EMPS], preserveOrder=[false])
]]>
        </Resource>
    </TestCase>
    <TestCase name="testMergeFilterWithJoinCondition">
        <Resource name="sql">
            <![CDATA[select d.name as dname,e.name as ename from sales.emps e inner join sales.depts d on e.deptno=d.deptno where d.name='Propane']]>
        </Resource>
        <Resource name="planBefore">
            <![CDATA[
ProjectRel(DNAME=[$11], ENAME=[$1])
  FilterRel(condition=[=($11, 'Propane')])
    JoinRel(condition=[=($2, $10)], joinType=[inner])
      TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
      TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
]]>
        </Resource>
        <Resource name="planAfter">
            <![CDATA[
IterCalcRel(expr#0..11=[{inputs}], DNAME=[$t11], ENAME=[$t1])
  FennelToIteratorConverter
    FennelCalcRel(expr#0..11=[{inputs}], expr#12=[=($t2, $t10)], expr#13=['Propane'], expr#14=[=($t11, $t13)], expr#15=[AND($t12, $t14)], proj#0..11=[{exprs}], $condition=[$t15])
      FennelCartesianProductRel(leftouterjoin=[false])
        FtrsIndexScanRel(table=[[LOCALDB, SALES, EMPS]], projection=[*], index=[SYS$CONSTRAINT_INDEX$SYS$PRIMARY_KEY$EMPS], preserveOrder=[false])
        FennelBufferRel(inMemory=[false], multiPass=[true])
          FtrsIndexScanRel(table=[[LOCALDB, SALES, DEPTS]], projection=[*], index=[SYS$CONSTRAINT_INDEX$SYS$PRIMARY_KEY$DEPTS], preserveOrder=[false])
]]>
        </Resource>
    </TestCase>
    <TestCase name="testPushSemiJoinPastJoinRule_Left">
        <Resource name="sql">
            <![CDATA[select e1.name from sales.emps e1, sales.depts d, sales.emps e2 where e1.deptno = d.deptno and e1.empno = e2.empno]]>
        </Resource>
        <Resource name="planBefore">
            <![CDATA[
ProjectRel(NAME=[$1])
  FilterRel(condition=[AND(=($2, $10), =($0, $12))])
    JoinRel(condition=[true], joinType=[inner])
      JoinRel(condition=[true], joinType=[inner])
        TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
        TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
      TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
]]>
        </Resource>
        <Resource name="planAfter">
            <![CDATA[
ProjectRel(NAME=[$1])
  JoinRel(condition=[=($0, $12)], joinType=[inner], semiJoinDone=[true])
    JoinRel(condition=[=($2, $10)], joinType=[inner], semiJoinDone=[true])
      SemiJoinRel(condition=[=($0, $10)], joinType=[inner])
        SemiJoinRel(condition=[=($2, $10)], joinType=[inner])
          TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
          TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
        TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
      TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
    TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
]]>
        </Resource>
    </TestCase>
    <TestCase name="testPushSemiJoinPastJoinRule_Right">
        <Resource name="sql">
            <![CDATA[select e1.name from sales.emps e1, sales.depts d, sales.emps e2 where e1.deptno = d.deptno and d.deptno = e2.deptno]]>
        </Resource>
        <Resource name="planBefore">
            <![CDATA[
ProjectRel(NAME=[$1])
  FilterRel(condition=[AND(=($2, $10), =($10, $14))])
    JoinRel(condition=[true], joinType=[inner])
      JoinRel(condition=[true], joinType=[inner])
        TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
        TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
      TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
]]>
        </Resource>
        <Resource name="planAfter">
            <![CDATA[
ProjectRel(NAME=[$1])
  JoinRel(condition=[=($10, $14)], joinType=[inner], semiJoinDone=[true])
    JoinRel(condition=[=($2, $10)], joinType=[inner], semiJoinDone=[true])
      SemiJoinRel(condition=[=($2, $10)], joinType=[inner])
        TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
        TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
      SemiJoinRel(condition=[=($0, $4)], joinType=[inner])
        TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
        TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
    TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
]]>
        </Resource>
    </TestCase>
    <TestCase name="testPushSemiJoinPastFilter">
        <Resource name="sql">
            <![CDATA[select e.name from sales.emps e, sales.depts d where e.deptno = d.deptno and e.name = 'foo']]>
        </Resource>
        <Resource name="planBefore">
            <![CDATA[
ProjectRel(NAME=[$1])
  FilterRel(condition=[AND(=($2, $10), =($1, 'foo'))])
    JoinRel(condition=[true], joinType=[inner])
      TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
      TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
]]>
        </Resource>
        <Resource name="planAfter">
            <![CDATA[
ProjectRel(NAME=[$1])
  JoinRel(condition=[=($2, $10)], joinType=[inner], semiJoinDone=[true])
    FilterRel(condition=[=($1, 'foo')])
      SemiJoinRel(condition=[=($2, $10)], joinType=[inner])
        TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
        TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
    TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
]]>
        </Resource>
    </TestCase>
    <TestCase name="testConvertMultiJoinRule">
        <Resource name="sql">
            <![CDATA[select e1.name from sales.emps e1, sales.depts d, sales.emps e2 where e1.deptno = d.deptno and d.deptno = e2.deptno]]>
        </Resource>
        <Resource name="planBefore">
            <![CDATA[
ProjectRel(NAME=[$1])
  FilterRel(condition=[AND(=($2, $10), =($10, $14))])
    JoinRel(condition=[true], joinType=[inner])
      JoinRel(condition=[true], joinType=[inner])
        TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
        TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
      TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
]]>
        </Resource>
        <Resource name="planAfter">
            <![CDATA[
ProjectRel(NAME=[$1])
  MultiJoinRel(joinFilter=[AND(=($10, $14), =($2, $10))], isFullOuterJoin=[false], joinTypes=[[INNER, INNER, INNER]], outerJoinConditions=[[NULL, NULL, NULL]], projFields=[[ALL, ALL, ALL]])
    TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
    TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
    TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
]]>
        </Resource>
    </TestCase>
    <TestCase name="testReduceConstants">
        <Resource name="sql">
            <![CDATA[select 1+2, d.deptno+(3+4), (5+6)+d.deptno, cast(null as integer), coalesce(2,null), row(7+8) from sales.depts d inner join sales.emps e on d.deptno = e.deptno + (5-5) where d.deptno=(7+8) and d.deptno=coalesce(2,null)]]>
        </Resource>
        <Resource name="planBefore">
            <![CDATA[
ProjectRel(EXPR$0=[+(1, 2)], EXPR$1=[+($0, +(3, 4))], EXPR$2=[+(+(5, 6), $0)], EXPR$3=[CAST(null):INTEGER], EXPR$4=[CASE(IS NOT NULL(2), 2, CAST(null):INTEGER)], EXPR$5=[ROW(+(7, 8))])
  FilterRel(condition=[AND(=($0, +(7, 8)), =($0, CASE(IS NOT NULL(2), 2, CAST(null):INTEGER)))])
    JoinRel(condition=[=($0, +($4, -(5, 5)))], joinType=[inner])
      TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
      TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
]]>
        </Resource>
        <Resource name="planAfter">
            <![CDATA[
ProjectRel(EXPR$0=[3], EXPR$1=[+($0, 7)], EXPR$2=[+(11, $0)], EXPR$3=[CAST(null):INTEGER], EXPR$4=[CAST(2):INTEGER], EXPR$5=[ROW(15)])
  FilterRel(condition=[AND(=($0, 15), =($0, 2))])
    JoinRel(condition=[=($0, +($4, 0))], joinType=[inner])
      TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
      TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
]]>
        </Resource>
    </TestCase>
    <TestCase name="testRemoveSemiJoin">
        <Resource name="sql">
            <![CDATA[select e.name from sales.emps e, sales.depts d where e.deptno = d.deptno]]>
        </Resource>
        <Resource name="planBefore">
            <![CDATA[
ProjectRel(NAME=[$1])
  FilterRel(condition=[=($2, $10)])
    JoinRel(condition=[true], joinType=[inner])
      TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
      TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
]]>
        </Resource>
        <Resource name="planAfter">
            <![CDATA[
ProjectRel(NAME=[$1])
  JoinRel(condition=[=($2, $10)], joinType=[inner], semiJoinDone=[true])
    TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
    TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
]]>
        </Resource>
    </TestCase>
    <TestCase name="testRemoveSemiJoinWithFilter">
        <Resource name="sql">
            <![CDATA[select e.name from sales.emps e, sales.depts d where e.deptno = d.deptno and e.name = 'foo']]>
        </Resource>
        <Resource name="planBefore">
            <![CDATA[
ProjectRel(NAME=[$1])
  FilterRel(condition=[AND(=($2, $10), =($1, 'foo'))])
    JoinRel(condition=[true], joinType=[inner])
      TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
      TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
]]>
        </Resource>
        <Resource name="planAfter">
            <![CDATA[
ProjectRel(NAME=[$1])
  JoinRel(condition=[=($2, $10)], joinType=[inner], semiJoinDone=[true])
    FilterRel(condition=[=($1, 'foo')])
      TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
    TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
]]>
        </Resource>
    </TestCase>
    <TestCase name="testRemoveSemiJoinRight">
        <Resource name="sql">
            <![CDATA[select e1.name from sales.emps e1, sales.depts d, sales.emps e2 where e1.deptno = d.deptno and d.deptno = e2.deptno]]>
        </Resource>
        <Resource name="planBefore">
            <![CDATA[
ProjectRel(NAME=[$1])
  FilterRel(condition=[AND(=($2, $10), =($10, $14))])
    JoinRel(condition=[true], joinType=[inner])
      JoinRel(condition=[true], joinType=[inner])
        TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
        TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
      TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
]]>
        </Resource>
        <Resource name="planAfter">
            <![CDATA[
ProjectRel(NAME=[$1])
  JoinRel(condition=[=($10, $14)], joinType=[inner], semiJoinDone=[true])
    JoinRel(condition=[=($2, $10)], joinType=[inner], semiJoinDone=[true])
      TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
      TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
    TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
]]>
        </Resource>
    </TestCase>
    <TestCase name="testRemoveSemiJoinRightWithFilter">
        <Resource name="sql">
            <![CDATA[select e1.name from sales.emps e1, sales.depts d, sales.emps e2 where e1.deptno = d.deptno and d.deptno = e2.deptno and d.name = 'foo']]>
        </Resource>
        <Resource name="planBefore">
            <![CDATA[
ProjectRel(NAME=[$1])
  FilterRel(condition=[AND(AND(=($2, $10), =($10, $14)), =($11, 'foo'))])
    JoinRel(condition=[true], joinType=[inner])
      JoinRel(condition=[true], joinType=[inner])
        TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
        TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
      TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
]]>
        </Resource>
        <Resource name="planAfter">
            <![CDATA[
ProjectRel(NAME=[$1])
  JoinRel(condition=[=($10, $14)], joinType=[inner], semiJoinDone=[true])
    JoinRel(condition=[=($2, $10)], joinType=[inner], semiJoinDone=[true])
      TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
      FilterRel(condition=[=($1, 'foo')])
        TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
    TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
]]>
        </Resource>
    </TestCase>
    <TestCase name="testConvertMultiJoinRuleOuterJoins">
        <Resource name="sql">
            <![CDATA[select * from     (select * from         (select * from             (select * from A right outer join B on a = b)             left outer join             (select * from C full outer join D on c = d)            on a = c and b = d)         right outer join         (select * from             (select * from E full outer join F on e = f)             right outer join             (select * from G left outer join H on g = h)             on e = g and f = h)         on a = e and b = f and c = g and d = h)     inner join     (select * from I inner join J on i = j)     on a = i and h = j]]>
        </Resource>
        <Resource name="planBefore">
            <![CDATA[
ProjectRel(A=[$0], B=[$1], C=[$2], D=[$3], E=[$4], F=[$5], G=[$6], H=[$7], I=[$8], J=[$9])
  JoinRel(condition=[AND(=($0, $8), =($7, $9))], joinType=[inner])
    ProjectRel(A=[$0], B=[$1], C=[$2], D=[$3], E=[$4], F=[$5], G=[$6], H=[$7])
      JoinRel(condition=[AND(AND(AND(=($0, $4), =($1, $5)), =($2, $6)), =($3, $7))], joinType=[right])
        ProjectRel(A=[$0], B=[$1], C=[$2], D=[$3])
          JoinRel(condition=[AND(=($0, $2), =($1, $3))], joinType=[left])
            ProjectRel(A=[$0], B=[$1])
              JoinRel(condition=[=($0, $1)], joinType=[right])
                TableAccessRel(table=[[LOCALDB, OJ, A]])
                TableAccessRel(table=[[LOCALDB, OJ, B]])
            ProjectRel(C=[$0], D=[$1])
              JoinRel(condition=[=($0, $1)], joinType=[full])
                TableAccessRel(table=[[LOCALDB, OJ, C]])
                TableAccessRel(table=[[LOCALDB, OJ, D]])
        ProjectRel(E=[$0], F=[$1], G=[$2], H=[$3])
          JoinRel(condition=[AND(=($0, $2), =($1, $3))], joinType=[right])
            ProjectRel(E=[$0], F=[$1])
              JoinRel(condition=[=($0, $1)], joinType=[full])
                TableAccessRel(table=[[LOCALDB, OJ, E]])
                TableAccessRel(table=[[LOCALDB, OJ, F]])
            ProjectRel(G=[$0], H=[$1])
              JoinRel(condition=[=($0, $1)], joinType=[left])
                TableAccessRel(table=[[LOCALDB, OJ, G]])
                TableAccessRel(table=[[LOCALDB, OJ, H]])
    ProjectRel(I=[$0], J=[$1])
      JoinRel(condition=[=($0, $1)], joinType=[inner])
        TableAccessRel(table=[[LOCALDB, OJ, I]])
        TableAccessRel(table=[[LOCALDB, OJ, J]])
]]>
        </Resource>
        <Resource name="planAfter">
            <![CDATA[
MultiJoinRel(joinFilter=[AND(AND(=($0, $8), =($7, $9)), =($8, $9))], isFullOuterJoin=[false], joinTypes=[[RIGHT, RIGHT, INNER, LEFT, INNER, INNER]], outerJoinConditions=[[AND(AND(AND(=($0, $4), =($1, $5)), =($2, $6)), =($3, $7)), AND(=($4, $6), =($5, $7)), NULL, =($6, $7), NULL, NULL]], projFields=[[ALL, ALL, ALL, ALL, ALL, ALL]])
  MultiJoinRel(joinFilter=[true], isFullOuterJoin=[false], joinTypes=[[RIGHT, INNER, LEFT]], outerJoinConditions=[[=($0, $1), NULL, AND(=($0, $2), =($1, $3))]], projFields=[[ALL, ALL, ALL]])
    TableAccessRel(table=[[LOCALDB, OJ, A]])
    TableAccessRel(table=[[LOCALDB, OJ, B]])
    MultiJoinRel(joinFilter=[=($0, $1)], isFullOuterJoin=[true], joinTypes=[[INNER, INNER]], outerJoinConditions=[[NULL, NULL]], projFields=[[ALL, ALL]])
      TableAccessRel(table=[[LOCALDB, OJ, C]])
      TableAccessRel(table=[[LOCALDB, OJ, D]])
  MultiJoinRel(joinFilter=[=($0, $1)], isFullOuterJoin=[true], joinTypes=[[INNER, INNER]], outerJoinConditions=[[NULL, NULL]], projFields=[[ALL, ALL]])
    TableAccessRel(table=[[LOCALDB, OJ, E]])
    TableAccessRel(table=[[LOCALDB, OJ, F]])
  TableAccessRel(table=[[LOCALDB, OJ, G]])
  TableAccessRel(table=[[LOCALDB, OJ, H]])
  TableAccessRel(table=[[LOCALDB, OJ, I]])
  TableAccessRel(table=[[LOCALDB, OJ, J]])
]]>
        </Resource>
    </TestCase>
    <TestCase name="testPushSemiJoinPastProject">
        <Resource name="sql">
            <![CDATA[select e.* from (select name, trim(city), age * 2, deptno from sales.emps) e, sales.depts d where e.deptno = d.deptno]]>
        </Resource>
        <Resource name="planBefore">
            <![CDATA[
ProjectRel(NAME=[$0], EXPR$1=[$1], EXPR$2=[$2], DEPTNO=[$3])
  FilterRel(condition=[=($3, $4)])
    JoinRel(condition=[true], joinType=[inner])
      ProjectRel(NAME=[$1], EXPR$1=[TRIM(FLAG(BOTH), ' ', $4)], EXPR$2=[*($6, 2)], DEPTNO=[$2])
        TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
      TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
]]>
        </Resource>
        <Resource name="planAfter">
            <![CDATA[
ProjectRel(NAME=[$0], EXPR$1=[$1], EXPR$2=[$2], DEPTNO=[$3])
  JoinRel(condition=[=($3, $4)], joinType=[inner], semiJoinDone=[true])
    ProjectRel(NAME=[$1], EXPR$1=[TRIM(FLAG(BOTH), ' ', $4)], EXPR$2=[*($6, 2)], DEPTNO=[$2])
      SemiJoinRel(condition=[=($2, $10)], joinType=[inner])
        TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
        TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
    TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
]]>
        </Resource>
    </TestCase>
    <TestCase name="testReduceValuesUnderFilter">
        <Resource name="sql">
            <![CDATA[select a, b from (values (10, 'x'), (20, 'y')) as t(a, b) where a < 15]]>
        </Resource>
        <Resource name="planBefore">
            <![CDATA[
ProjectRel(A=[$0], B=[$1])
  FilterRel(condition=[<($0, 15)])
    ValuesRel(tuples=[[{ 10, 'x' }, { 20, 'y' }]])
]]>
        </Resource>
        <Resource name="planAfter">
            <![CDATA[
ProjectRel(A=[$0], B=[$1])
  ValuesRel(tuples=[[{ 10, 'x' }]])
]]>
        </Resource>
    </TestCase>
    <TestCase name="testReduceValuesUnderProject">
        <Resource name="sql">
            <![CDATA[select a + b from (values (10, 1), (20, 3)) as t(a, b)]]>
        </Resource>
        <Resource name="planBefore">
            <![CDATA[
ProjectRel(EXPR$0=[+($0, $1)])
  ValuesRel(tuples=[[{ 10, 1 }, { 20, 3 }]])
]]>
        </Resource>
        <Resource name="planAfter">
            <![CDATA[
ValuesRel(tuples=[[{ 11 }, { 23 }]])
]]>
        </Resource>
    </TestCase>
    <TestCase name="testReduceValuesUnderProjectFilter">
        <Resource name="sql">
            <![CDATA[select a + b as x, b, a from (values (10, 1), (30, 7), (20, 3)) as t(a, b) where a - b < 21]]>
        </Resource>
        <Resource name="planBefore">
            <![CDATA[
ProjectRel(X=[+($0, $1)], B=[$1], A=[$0])
  FilterRel(condition=[<(-($0, $1), 21)])
    ValuesRel(tuples=[[{ 10, 1 }, { 30, 7 }, { 20, 3 }]])
]]>
        </Resource>
        <Resource name="planAfter">
            <![CDATA[
ValuesRel(tuples=[[{ 11, 1, 10 }, { 23, 3, 20 }]])
]]>
        </Resource>
    </TestCase>
    <TestCase name="testReduceValuesToEmpty">
        <Resource name="sql">
            <![CDATA[select a + b as x, b, a from (values (10, 1), (30, 7)) as t(a, b) where a - b < 0]]>
        </Resource>
        <Resource name="planBefore">
            <![CDATA[
ProjectRel(X=[+($0, $1)], B=[$1], A=[$0])
  FilterRel(condition=[<(-($0, $1), 0)])
    ValuesRel(tuples=[[{ 10, 1 }, { 30, 7 }]])
]]>
        </Resource>
        <Resource name="planAfter">
            <![CDATA[
EmptyRel
]]>
        </Resource>
    </TestCase>
    <TestCase name="testEmptyFilterProjectUnion">
        <Resource name="sql">
            <![CDATA[select * from (
select * from (values (10, 1), (30, 3)) as t (x, y)
union all
select * from (values (20, 2))
)
where x + y > 30]]>
        </Resource>
        <Resource name="planBefore">
            <![CDATA[
ProjectRel(X=[$0], Y=[$1])
  FilterRel(condition=[>(+($0, $1), 30)])
    UnionRel(all=[true])
      ProjectRel(X=[$0], Y=[$1])
        ValuesRel(tuples=[[{ 10, 1 }, { 30, 3 }]])
      ProjectRel(EXPR$0=[$0], EXPR$1=[$1])
        ValuesRel(tuples=[[{ 20, 2 }]])
]]>
        </Resource>
        <Resource name="planAfter">
            <![CDATA[
ProjectRel(X=[$0], Y=[$1])
  ValuesRel(tuples=[[{ 30, 3 }]])
]]>
        </Resource>
    </TestCase>
    <TestCase name="testReduceConstantsCalc">
        <Resource name="sql">
            <![CDATA[select * from (
  select upper(substring(x FROM 1 FOR 2) || substring(x FROM 3)) as u,
      substring(x FROM 1 FOR 1) as s
  from (
    select 'table' as x from (values (true))
    union
    select 'view' from (values (true))
    union
    select 'foreign table' from (values (true))
  )
) where u = 'TABLE']]>
        </Resource>
        <Resource name="planBefore">
            <![CDATA[
ProjectRel(U=[$0], S=[$1])
  FilterRel(condition=[=($0, 'TABLE')])
    ProjectRel(U=[UPPER(||(SUBSTRING($0, 1, 2), SUBSTRING($0, 3)))], S=[SUBSTRING($0, 1, 1)])
      UnionRel(all=[false])
        UnionRel(all=[false])
          ProjectRel(X=['table'])
            ValuesRel(tuples=[[{ true }]])
          ProjectRel(EXPR$0=['view'])
            ValuesRel(tuples=[[{ true }]])
        ProjectRel(EXPR$0=['foreign table'])
          ValuesRel(tuples=[[{ true }]])
]]>
        </Resource>
        <Resource name="planAfter">
            <![CDATA[
CalcRel(expr#0=[{inputs}], expr#1=['TABLE        '], expr#2=['t'], U=[$t1], S=[$t2])
  ValuesRel(tuples=[[{ true }]])
]]>
        </Resource>
    </TestCase>
    <TestCase name="testReduceConstantsEliminatesFilter">
        <Resource name="sql">
            <![CDATA[select * from (values (1,2)) where 1 + 2 > 3 + CAST(NULL AS INTEGER)]]>
        </Resource>
        <Resource name="planBefore">
            <![CDATA[
ProjectRel(EXPR$0=[$0], EXPR$1=[$1])
  FilterRel(condition=[>(+(1, 2), +(3, CAST(null):INTEGER))])
    ValuesRel(tuples=[[{ 1, 2 }]])
]]>
        </Resource>
        <Resource name="planAfter">
            <![CDATA[
ProjectRel(EXPR$0=[$0], EXPR$1=[$1])
  EmptyRel
]]>
        </Resource>
    </TestCase>
    <TestCase name="testReduceValuesNull">
        <Resource name="sql">
            <![CDATA[insert into sales.depts(deptno,name) values (NULL, 'null')]]>
        </Resource>
        <Resource name="planBefore">
            <![CDATA[
TableModificationRel(table=[[LOCALDB, SALES, DEPTS]], operation=[INSERT], updateColumnList=[[]], flattened=[false])
  ProjectRel(DEPTNO=[$0], NAME=[$1])
    ProjectRel(EXPR$0=[$0], EXPR$1=[$1])
      ValuesRel(tuples=[[{ null, 'null' }]])
]]>
        </Resource>
        <Resource name="planAfter">
            <![CDATA[
TableModificationRel(table=[[LOCALDB, SALES, DEPTS]], operation=[INSERT], updateColumnList=[[]], flattened=[false])
  ValuesRel(tuples=[[{ null, 'null' }]])
]]>
        </Resource>
    </TestCase>
    <TestCase name="testAlreadyFalseEliminatesFilter">
        <Resource name="sql">
            <![CDATA[select * from (values (1,2)) where false]]>
        </Resource>
        <Resource name="planBefore">
            <![CDATA[
ProjectRel(EXPR$0=[$0], EXPR$1=[$1])
  FilterRel(condition=[false])
    ValuesRel(tuples=[[{ 1, 2 }]])
]]>
        </Resource>
        <Resource name="planAfter">
            <![CDATA[
ProjectRel(EXPR$0=[$0], EXPR$1=[$1])
  EmptyRel
]]>
        </Resource>
    </TestCase>
    <TestCase name="testReduceCasts">
        <Resource name="sql">
            <![CDATA[select cast(d.name as varchar(128)), cast(e.empno as integer) from sales.depts d inner join sales.emps e on cast(d.deptno as integer) = cast(e.deptno as integer) where cast(e.gender as char(1)) = 'M']]>
        </Resource>
        <Resource name="planBefore">
            <![CDATA[
ProjectRel(EXPR$0=[CAST($1):VARCHAR(128) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary" NOT NULL], EXPR$1=[CAST($2):INTEGER NOT NULL])
  FilterRel(condition=[=(CAST($5):CHAR(1) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary", 'M')])
    JoinRel(condition=[=(CAST($0):INTEGER NOT NULL, CAST($4):INTEGER NOT NULL)], joinType=[inner])
      TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
      TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
]]>
        </Resource>
        <Resource name="planAfter">
            <![CDATA[
ProjectRel(EXPR$0=[$1], EXPR$1=[$2])
  FilterRel(condition=[=($5, 'M')])
    JoinRel(condition=[=($0, $4)], joinType=[inner])
      TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
      TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
]]>
        </Resource>
    </TestCase>
    <TestCase name="testReduceCastAndConsts">
        <Resource name="sql">
            <![CDATA[select * from sales.emps where cast((empno + (10/2)) as int) = 13]]>
        </Resource>
        <Resource name="planBefore">
            <![CDATA[
ProjectRel(EMPNO=[$0], NAME=[$1], DEPTNO=[$2], GENDER=[$3], CITY=[$4], EMPID=[$5], AGE=[$6], PUBLIC_KEY=[$7], SLACKER=[$8], MANAGER=[$9])
  FilterRel(condition=[=(CAST(+($0, /(10, 2))):INTEGER NOT NULL, 13)])
    TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
]]>
        </Resource>
        <Resource name="planAfter">
            <![CDATA[
ProjectRel(EMPNO=[$0], NAME=[$1], DEPTNO=[$2], GENDER=[$3], CITY=[$4], EMPID=[$5], AGE=[$6], PUBLIC_KEY=[$7], SLACKER=[$8], MANAGER=[$9])
  FilterRel(condition=[=(+($0, 5), 13)])
    TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
]]>
        </Resource>
    </TestCase>
    <TestCase name="testReduceCastsNullable">
        <Resource name="sql">
            <![CDATA[insert into sales.depts(name) select cast(gender as varchar(128)) from sales.emps]]>
        </Resource>
        <Resource name="planBefore">
            <![CDATA[
TableModificationRel(table=[[LOCALDB, SALES, DEPTS]], operation=[INSERT], updateColumnList=[[]], flattened=[false])
  ProjectRel(DEPTNO=[CAST(null):INTEGER NOT NULL], NAME=[$0])
    ProjectRel(EXPR$0=[CAST($3):VARCHAR(128) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary"])
      TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
]]>
        </Resource>
        <Resource name="planAfter">
            <![CDATA[
TableModificationRel(table=[[LOCALDB, SALES, DEPTS]], operation=[INSERT], updateColumnList=[[]], flattened=[false])
  CalcRel(expr#0..9=[{inputs}], expr#10=[CAST(null):INTEGER NOT NULL], expr#11=[CAST($3):VARCHAR(128) CHARACTER SET "ISO-8859-1" COLLATE "ISO-8859-1$en_US$primary" NOT NULL], DEPTNO=[$t10], NAME=[$t11])
    TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
]]>
        </Resource>
    </TestCase>
    <TestCase name="testFennelBufferCommonRelSubExprRule">
        <Resource name="sql">
            <![CDATA[select * from (select * from sales.emps e, sales.depts d    where e.deptno = d.deptno), (select * from sales.depts d, sales.emps e    where e.deptno = d.deptno), (select * from sales.emps e, sales.depts d    where e.deptno = d.deptno)]]>
        </Resource>
        <Resource name="planBefore">
            <![CDATA[
ProjectRel(EMPNO=[$0], NAME=[$1], DEPTNO=[$2], GENDER=[$3], CITY=[$4], EMPID=[$5], AGE=[$6], PUBLIC_KEY=[$7], SLACKER=[$8], MANAGER=[$9], DEPTNO0=[$10], NAME0=[$11], DEPTNO1=[$12], NAME1=[$13], EMPNO0=[$14], NAME00=[$15], DEPTNO00=[$16], GENDER0=[$17], CITY0=[$18], EMPID0=[$19], AGE0=[$20], PUBLIC_KEY0=[$21], SLACKER0=[$22], MANAGER0=[$23], EMPNO1=[$24], NAME2=[$25], DEPTNO2=[$26], GENDER1=[$27], CITY1=[$28], EMPID1=[$29], AGE1=[$30], PUBLIC_KEY1=[$31], SLACKER1=[$32], MANAGER1=[$33], DEPTNO01=[$34], NAME01=[$35])
  JoinRel(condition=[true], joinType=[inner])
    JoinRel(condition=[true], joinType=[inner])
      ProjectRel(EMPNO=[$0], NAME=[$1], DEPTNO=[$2], GENDER=[$3], CITY=[$4], EMPID=[$5], AGE=[$6], PUBLIC_KEY=[$7], SLACKER=[$8], MANAGER=[$9], DEPTNO0=[$10], NAME0=[$11])
        FilterRel(condition=[=($2, $10)])
          JoinRel(condition=[true], joinType=[inner])
            TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
            TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
      ProjectRel(DEPTNO=[$0], NAME=[$1], EMPNO=[$2], NAME0=[$3], DEPTNO0=[$4], GENDER=[$5], CITY=[$6], EMPID=[$7], AGE=[$8], PUBLIC_KEY=[$9], SLACKER=[$10], MANAGER=[$11])
        FilterRel(condition=[=($4, $0)])
          JoinRel(condition=[true], joinType=[inner])
            TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
            TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
    ProjectRel(EMPNO=[$0], NAME=[$1], DEPTNO=[$2], GENDER=[$3], CITY=[$4], EMPID=[$5], AGE=[$6], PUBLIC_KEY=[$7], SLACKER=[$8], MANAGER=[$9], DEPTNO0=[$10], NAME0=[$11])
      FilterRel(condition=[=($2, $10)])
        JoinRel(condition=[true], joinType=[inner])
          TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
          TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
]]>
        </Resource>
        <Resource name="planAfter">
            <![CDATA[
ProjectRel(EMPNO=[$0], NAME=[$1], DEPTNO=[$2], GENDER=[$3], CITY=[$4], EMPID=[$5], AGE=[$6], PUBLIC_KEY=[$7], SLACKER=[$8], MANAGER=[$9], DEPTNO0=[$10], NAME0=[$11], DEPTNO1=[$12], NAME1=[$13], EMPNO0=[$14], NAME00=[$15], DEPTNO00=[$16], GENDER0=[$17], CITY0=[$18], EMPID0=[$19], AGE0=[$20], PUBLIC_KEY0=[$21], SLACKER0=[$22], MANAGER0=[$23], EMPNO1=[$24], NAME2=[$25], DEPTNO2=[$26], GENDER1=[$27], CITY1=[$28], EMPID1=[$29], AGE1=[$30], PUBLIC_KEY1=[$31], SLACKER1=[$32], MANAGER1=[$33], DEPTNO01=[$34], NAME01=[$35])
  JoinRel(condition=[true], joinType=[inner])
    JoinRel(condition=[true], joinType=[inner])
      FennelMultiUseBufferRel(inMemory=[false], readerRefCountParamId=[1])
        ProjectRel(EMPNO=[$0], NAME=[$1], DEPTNO=[$2], GENDER=[$3], CITY=[$4], EMPID=[$5], AGE=[$6], PUBLIC_KEY=[$7], SLACKER=[$8], MANAGER=[$9], DEPTNO0=[$10], NAME0=[$11])
          FilterRel(condition=[=($2, $10)])
            JoinRel(condition=[true], joinType=[inner])
              TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
              TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
      ProjectRel(DEPTNO=[$0], NAME=[$1], EMPNO=[$2], NAME0=[$3], DEPTNO0=[$4], GENDER=[$5], CITY=[$6], EMPID=[$7], AGE=[$8], PUBLIC_KEY=[$9], SLACKER=[$10], MANAGER=[$11])
        FilterRel(condition=[=($4, $0)])
          JoinRel(condition=[true], joinType=[inner])
            TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
            TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
    FennelMultiUseBufferRel(inMemory=[false], readerRefCountParamId=[1])
      ProjectRel(EMPNO=[$0], NAME=[$1], DEPTNO=[$2], GENDER=[$3], CITY=[$4], EMPID=[$5], AGE=[$6], PUBLIC_KEY=[$7], SLACKER=[$8], MANAGER=[$9], DEPTNO0=[$10], NAME0=[$11])
        FilterRel(condition=[=($2, $10)])
          JoinRel(condition=[true], joinType=[inner])
            TableAccessRel(table=[[LOCALDB, SALES, EMPS]])
            TableAccessRel(table=[[LOCALDB, SALES, DEPTS]])
]]>
        </Resource>
    </TestCase>
</Root>
