blob: 6902fe5f81fa9f7755e569e689b014c6ebf1426e [file] [log] [blame]
<?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="testAggCaseInSubQuery">
<Resource name="sql">
<![CDATA[SELECT SUM(
CASE WHEN deptno IN (SELECT deptno FROM dept) THEN 1 ELSE 0 END)
FROM emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{}], EXPR$0=[SUM($0)])
LogicalProject($f0=[CASE(IN($7, {
LogicalProject(DEPTNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
}), 1, 0)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testAggCaseSubQuery">
<Resource name="sql">
<![CDATA[SELECT SUM(CASE WHEN empno IN (3) THEN 0 ELSE 1 END) FROM emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{}], EXPR$0=[SUM($0)])
LogicalProject($f0=[CASE(=($0, 3), 0, 1)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testAggDistinct">
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{0}], EXPR$1=[SUM($1)], EXPR$2=[SUM(DISTINCT $1)], EXPR$3=[COUNT()])
LogicalProject(DEPTNO=[$7], SAL=[$5])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select deptno, sum(sal), sum(distinct sal), count(*)
from emp
group by deptno]]>
</Resource>
</TestCase>
<TestCase name="testAggFilter">
<Resource name="sql">
<![CDATA[select
deptno, sum(sal * 2) filter (where empno < 10), count(*)
from emp
group by deptno]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{0}], EXPR$1=[SUM($1) FILTER $2], EXPR$2=[COUNT()])
LogicalProject(DEPTNO=[$7], $f1=[*($5, 2)], $f2=[<($0, 10)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testAggFilterWithIn">
<Resource name="sql">
<![CDATA[select
deptno, sum(sal * 2) filter (where empno not in (1, 2)), count(*)
from emp
group by deptno]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{0}], EXPR$1=[SUM($1) FILTER $2], EXPR$2=[COUNT()])
LogicalProject(DEPTNO=[$7], $f1=[*($5, 2)], $f2=[SEARCH($0, Sarg[(-∞..1), (1..2), (2..+∞)])])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testAggFilterWithInSubQuery">
<Resource name="sql">
<![CDATA[select
count(*) filter (where empno in (select deptno from empnullables))
from empnullables]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{}], EXPR$0=[COUNT() FILTER $0])
LogicalProject($f0=[IS TRUE(IN($0, {
LogicalProject(DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMPNULLABLES]])
}))])
LogicalTableScan(table=[[CATALOG, SALES, EMPNULLABLES]])
]]>
</Resource>
</TestCase>
<TestCase name="testAggNoDuplicateColumnNames">
<Resource name="sql">
<![CDATA[SELECT empno, EXPR$2, COUNT(empno) FROM (
SELECT empno, deptno AS EXPR$2
FROM emp)
GROUP BY empno, EXPR$2]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], EXPR$2=[$1], EXPR$20=[$2])
LogicalAggregate(group=[{0, 1}], EXPR$2=[COUNT()])
LogicalProject(EMPNO=[$0], EXPR$2=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testAggScalarSubQuery">
<Resource name="sql">
<![CDATA[SELECT SUM(SELECT min(deptno) FROM dept) FROM emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{}], EXPR$0=[SUM($0)])
LogicalProject(EXPR$0=[$9])
LogicalJoin(condition=[true], joinType=[left])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{}], EXPR$0=[MIN($0)])
LogicalProject(DEPTNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testAggregateAndScalarSubQueryInHaving">
<Resource name="sql">
<![CDATA[select deptno
from emp
group by deptno
having max(emp.empno) > (SELECT min(emp.empno) FROM emp)
]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0])
LogicalFilter(condition=[>($1, $2)])
LogicalJoin(condition=[true], joinType=[left])
LogicalAggregate(group=[{0}], agg#0=[MAX($1)])
LogicalProject(DEPTNO=[$7], EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{}], EXPR$0=[MIN($0)])
LogicalProject(EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testAggregateAndScalarSubQueryInSelect">
<Resource name="sql">
<![CDATA[select deptno,
max(emp.empno) > (SELECT min(emp.empno) FROM emp) as b
from emp
group by deptno
]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], B=[>($1, $2)])
LogicalJoin(condition=[true], joinType=[left])
LogicalAggregate(group=[{0}], agg#0=[MAX($1)])
LogicalProject(DEPTNO=[$7], EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{}], EXPR$0=[MIN($0)])
LogicalProject(EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testAggregateFunAndAliasInHaving1">
<Resource name="sql">
<![CDATA[select count(empno) as e
from emp
having e > 10 and count(empno) > 10]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalFilter(condition=[>($0, 10)])
LogicalAggregate(group=[{}], E=[COUNT()])
LogicalProject(EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testAggregateFunAndAliasInHaving2">
<Resource name="sql">
<![CDATA[select count(empno) as e
from emp
having e > 10 or count(empno) < 5]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalFilter(condition=[SEARCH($0, Sarg[(-∞..5), (10..+∞)])])
LogicalAggregate(group=[{}], E=[COUNT()])
LogicalProject(EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testAggregateFunctionForStructInput">
<Resource name="sql">
<![CDATA[select collect(skill) as collect_skill,
count(skill) as count_skill, count(*) as count_star,
approx_count_distinct(skill) as approx_count_distinct_skill,
max(skill) as max_skill, min(skill) as min_skill,
any_value(skill) as any_value_skill
from sales.dept_nested]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(COLLECT_SKILL=[$0], COUNT_SKILL=[$1], COUNT_STAR=[$1], APPROX_COUNT_DISTINCT_SKILL=[$2], MAX_SKILL=[ROW($3.TYPE, $3.DESC, ROW($3.OTHERS.A, $3.OTHERS.B))], MIN_SKILL=[ROW($4.TYPE, $4.DESC, ROW($4.OTHERS.A, $4.OTHERS.B))], ANY_VALUE_SKILL=[ROW($5.TYPE, $5.DESC, ROW($5.OTHERS.A, $5.OTHERS.B))])
LogicalAggregate(group=[{}], COLLECT_SKILL=[COLLECT($0)], COUNT_SKILL=[COUNT()], APPROX_COUNT_DISTINCT_SKILL=[COUNT(APPROXIMATE DISTINCT $0)], MAX_SKILL=[MAX($0)], MIN_SKILL=[MIN($0)], ANY_VALUE_SKILL=[ANY_VALUE($0)])
LogicalProject(SKILL=[ROW($2.TYPE, $2.DESC, ROW($2.OTHERS.A, $2.OTHERS.B))])
LogicalTableScan(table=[[CATALOG, SALES, DEPT_NESTED]])
]]>
</Resource>
</TestCase>
<TestCase name="testAggregateFunctionForStructInputByName">
<Resource name="sql">
<![CDATA[select collect(skill) as collect_skill,
count(skill) as count_skill, count(*) as count_star,
approx_count_distinct(skill) as approx_count_distinct_skill,
max(skill) as max_skill, min(skill) as min_skill,
any_value(skill) as any_value_skill
from sales.dept_nested group by name]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(COLLECT_SKILL=[$1], COUNT_SKILL=[$2], COUNT_STAR=[$2], APPROX_COUNT_DISTINCT_SKILL=[$3], MAX_SKILL=[ROW($4.TYPE, $4.DESC, ROW($4.OTHERS.A, $4.OTHERS.B))], MIN_SKILL=[ROW($5.TYPE, $5.DESC, ROW($5.OTHERS.A, $5.OTHERS.B))], ANY_VALUE_SKILL=[ROW($6.TYPE, $6.DESC, ROW($6.OTHERS.A, $6.OTHERS.B))])
LogicalAggregate(group=[{0}], COLLECT_SKILL=[COLLECT($1)], COUNT_SKILL=[COUNT()], APPROX_COUNT_DISTINCT_SKILL=[COUNT(APPROXIMATE DISTINCT $1)], MAX_SKILL=[MAX($1)], MIN_SKILL=[MIN($1)], ANY_VALUE_SKILL=[ANY_VALUE($1)])
LogicalProject(NAME=[$1], SKILL=[ROW($2.TYPE, $2.DESC, ROW($2.OTHERS.A, $2.OTHERS.B))])
LogicalTableScan(table=[[CATALOG, SALES, DEPT_NESTED]])
]]>
</Resource>
</TestCase>
<TestCase name="testAggregateNoGroup">
<Resource name="sql">
<![CDATA[select sum(deptno) from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{}], EXPR$0=[SUM($0)])
LogicalProject(DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testAggregateWithSameDigestInSubQueries">
<Resource name="sql">
<![CDATA[select
CASE WHEN job IN ('810000', '820000') THEN job
ELSE 'error'
END AS job_name,
count(empno)
FROM emp
where job <> '' or job IN ('810000', '820000')
GROUP by deptno, job]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(JOB_NAME=[CASE(SEARCH($1, Sarg['810000', '820000']:CHAR(6)), $1, 'error':VARCHAR(10))], EXPR$1=[$2])
LogicalAggregate(group=[{0, 1}], EXPR$1=[COUNT()])
LogicalProject(DEPTNO=[$7], JOB=[$2], EMPNO=[$0])
LogicalFilter(condition=[OR(<>($2, ''), =($2, '810000'), =($2, '820000'))])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testAliasInHaving">
<Resource name="plan">
<![CDATA[
LogicalFilter(condition=[>($0, 1)])
LogicalAggregate(group=[{}], E=[COUNT()])
LogicalProject(EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select count(empno) as e from emp having e > 1]]>
</Resource>
</TestCase>
<TestCase name="testAliasList">
<Resource name="sql">
<![CDATA[select a + b from (
select deptno, 1 as uno, name from dept
) as d(a, b, c)
where c like 'X%']]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[+($0, $1)])
LogicalFilter(condition=[LIKE($2, 'X%')])
LogicalProject(DEPTNO=[$0], UNO=[1], NAME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testAliasList2">
<Resource name="sql">
<![CDATA[select * from (
select a, b, c from (values (1, 2, 3)) as t (c, b, a)
) join dept on dept.deptno = c
order by c + a]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(A=[$0], B=[$1], C=[$2], DEPTNO=[$3], NAME=[$4])
LogicalSort(sort0=[$5], dir0=[ASC])
LogicalProject(A=[$0], B=[$1], C=[$2], DEPTNO=[$3], NAME=[$4], EXPR$5=[+($2, $0)])
LogicalJoin(condition=[=($3, $2)], joinType=[inner])
LogicalProject(A=[$2], B=[$1], C=[$0])
LogicalValues(tuples=[[{ 1, 2, 3 }]])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testAliasUnnestArrayPlanWithDoubleColumn">
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], E=[$5], EMPNO=[$6.EMPNO])
LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{2, 3}])
LogicalTableScan(table=[[CATALOG, SALES, DEPT_NESTED_EXPANDED]])
Uncollect
LogicalProject(ADMINS=[$cor0.ADMINS], EMPLOYEES=[$cor0.EMPLOYEES])
LogicalValues(tuples=[[{ 0 }]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select d.deptno, e, k.empno
from dept_nested_expanded as d CROSS JOIN
UNNEST(d.admins, d.employees) as t(e, k)]]>
</Resource>
</TestCase>
<TestCase name="testAliasUnnestArrayPlanWithSingleColumn">
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], EMPNO=[$5.EMPNO])
LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{2}])
LogicalTableScan(table=[[CATALOG, SALES, DEPT_NESTED_EXPANDED]])
Uncollect
LogicalProject(EMPLOYEES=[$cor0.EMPLOYEES])
LogicalValues(tuples=[[{ 0 }]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select d.deptno, employee.empno
from dept_nested_expanded as d,
UNNEST(d.employees) as t(employee)]]>
</Resource>
</TestCase>
<TestCase name="testAliasWithinGroupingSets">
<Resource name="sql">
<![CDATA[SELECT empno / 2 AS x
FROM emp
GROUP BY ROLLUP(x)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{0}], groups=[[{0}, {}]])
LogicalProject(X=[/($0, 2)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testAllValueList">
<Resource name="sql">
<![CDATA[select empno from emp where deptno > all (10, 20)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0])
LogicalFilter(condition=[AND(>($7, 10), >($7, 20))])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testAnyValueAggregateFunctionGroupBy">
<Resource name="sql">
<![CDATA[SELECT any_value(empno) as anyempno FROM emp AS e group by e.sal]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ANYEMPNO=[$1])
LogicalAggregate(group=[{0}], ANYEMPNO=[ANY_VALUE($1)])
LogicalProject(SAL=[$5], EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testAnyValueAggregateFunctionNoGroupBy">
<Resource name="sql">
<![CDATA[SELECT any_value(empno) as anyempno FROM emp AS e]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{}], ANYEMPNO=[ANY_VALUE($0)])
LogicalProject(EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testArgMaxFunction">
<Resource name="sql">
<![CDATA[select arg_max(ename, deptno)
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{}], EXPR$0=[ARG_MAX($0, $1)])
LogicalProject(ENAME=[$1], DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testArgMaxFunctionWithWinAgg">
<Resource name="sql">
<![CDATA[select job,
arg_max(ename, deptno) over (partition by job order by sal)
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(JOB=[$2], EXPR$1=[ARG_MAX($1, $7) OVER (PARTITION BY $2 ORDER BY $5)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testArgMinFunction">
<Resource name="sql">
<![CDATA[select arg_min(ename, deptno)
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{}], EXPR$0=[ARG_MIN($0, $1)])
LogicalProject(ENAME=[$1], DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testArgMinFunctionWithWinAgg">
<Resource name="sql">
<![CDATA[select job,
arg_min(ename, deptno) over (partition by job order by sal)
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(JOB=[$2], EXPR$1=[ARG_MIN($1, $7) OVER (PARTITION BY $2 ORDER BY $5)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testArrayElementDoublyNestedPrimitive">
<Resource name="sql">
<![CDATA[select dn.employees[0]['detail']['skills'][0]['type']
from sales.dept_nested dn]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[ITEM(ITEM(ITEM(ITEM(ITEM($3, 0), 'detail'), 'skills'), 0), 'type')])
LogicalTableScan(table=[[CATALOG, SALES, DEPT_NESTED]])
]]>
</Resource>
</TestCase>
<TestCase name="testArrayElementDoublyNestedStruct">
<Resource name="sql">
<![CDATA[select dn.employees[0]['detail']['skills'][0]
from sales.dept_nested dn]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[ROW(ITEM(ITEM(ITEM(ITEM($3, 0), 'detail'), 'skills'), 0).TYPE, ITEM(ITEM(ITEM(ITEM($3, 0), 'detail'), 'skills'), 0).DESC, ROW(ITEM(ITEM(ITEM(ITEM($3, 0), 'detail'), 'skills'), 0).OTHERS.A, ITEM(ITEM(ITEM(ITEM($3, 0), 'detail'), 'skills'), 0).OTHERS.B))])
LogicalTableScan(table=[[CATALOG, SALES, DEPT_NESTED]])
]]>
</Resource>
</TestCase>
<TestCase name="testArrayElementNestedPrimitive">
<Resource name="sql">
<![CDATA[select dn.employees[0]['empno']
from sales.dept_nested dn]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[ITEM(ITEM($3, 0), 'empno')])
LogicalTableScan(table=[[CATALOG, SALES, DEPT_NESTED]])
]]>
</Resource>
</TestCase>
<TestCase name="testArrayElementThreeTimesNestedStruct">
<Resource name="sql">
<![CDATA[select dn.employees[0]['detail']['skills'][0]['others']
from sales.dept_nested dn]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[ROW(ITEM(ITEM(ITEM(ITEM($3, 0), 'detail'), 'skills'), 0).OTHERS.A, ITEM(ITEM(ITEM(ITEM($3, 0), 'detail'), 'skills'), 0).OTHERS.B)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT_NESTED]])
]]>
</Resource>
</TestCase>
<TestCase name="testArrayOfRecord">
<Resource name="sql">
<![CDATA[select employees[1].detail.skills[2+3].desc from dept_nested]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[ITEM(ITEM($3, 1).DETAIL.SKILLS, +(2, 3)).DESC])
LogicalTableScan(table=[[CATALOG, SALES, DEPT_NESTED]])
]]>
</Resource>
</TestCase>
<TestCase name="testCase">
<Resource name="plan">
<![CDATA[
LogicalValues(tuples=[[{ 1 }]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[values (case 'a' when 'a' then 1 end)]]>
</Resource>
</TestCase>
<TestCase name="testCaseAliasWithinGroupingSets">
<Resource name="sql">
<![CDATA[SELECT empno,
CASE
WHEN ename in ('Fred','Eric') THEN 'CEO'
ELSE 'Other'
END AS derived_col
FROM emp
GROUP BY GROUPING SETS ((empno, derived_col),(empno))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}]])
LogicalProject(EMPNO=[$0], DERIVED_COL=[CASE(SEARCH($1, Sarg['Eric', 'Fred']:CHAR(4)), 'CEO ', 'Other')])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testCaseWithinGroupingSets">
<Resource name="sql">
<![CDATA[SELECT empno,
CASE WHEN ename IN ('Fred','Eric') THEN 'Manager' ELSE 'Other' END
FROM emp
GROUP BY GROUPING SETS (
(empno, CASE WHEN ename IN ('Fred','Eric') THEN 'Manager' ELSE 'Other' END),
(empno)
)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}]])
LogicalProject(EMPNO=[$0], EXPR$1=[CASE(SEARCH($1, Sarg['Eric', 'Fred']:CHAR(4)), 'Manager', 'Other ')])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testCharLength">
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[CHAR_LENGTH('foo')])
LogicalValues(tuples=[[{ 0 }]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[values (character_length('foo'))]]>
</Resource>
</TestCase>
<TestCase name="testCoalesceOnNullableField">
<Resource name="sql">
<![CDATA[select coalesce(mgr, 0) from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[CASE(IS NOT NULL($3), CAST($3):INTEGER NOT NULL, 0)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testCollectionTable">
<Resource name="sql">
<![CDATA[select * from table(ramp(3))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(I=[$0])
LogicalTableFunctionScan(invocation=[RAMP(3)], rowType=[RecordType(INTEGER I)])
]]>
</Resource>
</TestCase>
<TestCase name="testCollectionTableWithCursorParam">
<Resource name="sql">
<![CDATA[select * from table(dedup(cursor(select ename from emp), cursor(select name from dept), 'NAME'))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(NAME=[$0])
LogicalTableFunctionScan(invocation=[DEDUP(CAST($0):CURSOR NOT NULL, CAST($1):CURSOR NOT NULL, 'NAME')], rowType=[RecordType(VARCHAR(1024) NAME)])
LogicalProject(ENAME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalProject(NAME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testCollectionTableWithLateral">
<Resource name="sql">
<![CDATA[select * from dept, lateral table(ramp(dept.deptno))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], NAME=[$1], I=[$2])
LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{0}])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
LogicalTableFunctionScan(invocation=[RAMP($cor0.DEPTNO)], rowType=[RecordType(INTEGER I)])
]]>
</Resource>
</TestCase>
<TestCase name="testCollectionTableWithLateral2">
<Resource name="sql">
<![CDATA[select * from dept, lateral table(ramp(deptno))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], NAME=[$1], I=[$2])
LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{0}])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
LogicalTableFunctionScan(invocation=[RAMP($cor0.DEPTNO)], rowType=[RecordType(INTEGER I)])
]]>
</Resource>
</TestCase>
<TestCase name="testCollectionTableWithLateral3">
<Resource name="sql">
<![CDATA[select * from dept, lateral table(DEDUP(dept.deptno, dept.name))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], NAME=[$1], NAME0=[$2])
LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{0, 1}])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
LogicalTableFunctionScan(invocation=[DEDUP($cor0.DEPTNO, $cor0.NAME)], rowType=[RecordType(VARCHAR(1024) NAME)])
]]>
</Resource>
</TestCase>
<TestCase name="testCompositeInUncorrelatedSubQueryRex">
<Resource name="sql">
<![CDATA[select empno from emp where (empno, deptno) in (select deptno - 10, deptno from dept)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0])
LogicalFilter(condition=[IN($0, $7, {
LogicalProject(EXPR$0=[-($0, 10)], DEPTNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
})])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testCompositeOfCountRange">
<Resource name="sql">
<![CDATA[select COMPOSITE(deptno)
from dept]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[COMPOSITE($0)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testConditionOffByOne">
<Resource name="sql">
<![CDATA[SELECT * FROM emp
JOIN dept on emp.deptno + 0 = dept.deptno]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO0=[$9], NAME=[$10])
LogicalJoin(condition=[=($7, $9)], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testConditionOffByOneReversed">
<Resource name="sql">
<![CDATA[SELECT * FROM emp
JOIN dept on dept.deptno = emp.deptno + 0]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO0=[$9], NAME=[$10])
LogicalJoin(condition=[=($9, $7)], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testConvertFunc">
<Resource name="sql">
<![CDATA[select convert(ename, latin1, utf8) as new_ename
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(NEW_ENAME=[CONVERT($1, 'LATIN1', 'UTF8')])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testCorrelateSortWithLimit">
<Resource name="sql">
<![CDATA[SELECT deptno, ename
FROM
(SELECT DISTINCT deptno FROM emp) t1,
LATERAL (
SELECT ename, sal
FROM emp
WHERE deptno = t1.deptno
ORDER BY sal
DESC LIMIT 3
)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], ENAME=[$1])
LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{0}])
LogicalAggregate(group=[{0}])
LogicalProject(DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalSort(sort0=[$1], dir0=[DESC], fetch=[3])
LogicalProject(ENAME=[$1], SAL=[$5])
LogicalFilter(condition=[=($7, $cor0.DEPTNO)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testCorrelatedArraySubQuery">
<Resource name="sql">
<![CDATA[select *,
array (select * from emp
where deptno = dept.deptno) as empset
from dept]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], NAME=[$1], EMPSET=[$2])
LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{0}])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
Collect(field=[EXPR$0])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalFilter(condition=[=($7, $cor0.DEPTNO)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testCorrelatedArraySubQueryRex">
<Resource name="sql">
<![CDATA[select *,
array (select * from emp
where deptno = dept.deptno) as empset
from dept]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], NAME=[$1], EMPSET=[ARRAY({
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalFilter(condition=[=($7, $cor0.DEPTNO)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
})])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testCorrelatedForOuterFields">
<Resource name="sql">
<![CDATA[SELECT ARRAY(SELECT dept.deptno)
FROM emp
LEFT OUTER JOIN dept
ON emp.empno = dept.deptno]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[$11])
LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{9}])
LogicalJoin(condition=[=($0, $9)], joinType=[left])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
Collect(field=[EXPR$0])
LogicalProject(DEPTNO=[$cor0.DEPTNO0])
LogicalValues(tuples=[[{ 0 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testCorrelatedMapSubQuery">
<Resource name="sql">
<![CDATA[select *,
map (select empno, job
from emp where deptno = dept.deptno) as jobMap
from dept]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], NAME=[$1], JOBMAP=[$2])
LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{0}])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
Collect(field=[EXPR$0])
LogicalProject(EMPNO=[$0], JOB=[$2])
LogicalFilter(condition=[=($7, $cor0.DEPTNO)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testCorrelatedMapSubQueryRex">
<Resource name="sql">
<![CDATA[select *,
map (select empno, job
from emp where deptno = dept.deptno) as jobMap
from dept]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], NAME=[$1], JOBMAP=[MAP({
LogicalProject(EMPNO=[$0], JOB=[$2])
LogicalFilter(condition=[=($7, $cor0.DEPTNO)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
})])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testCorrelatedScalarSubQueryInSelectList">
<Resource name="planNotExpanded">
<![CDATA[
LogicalProject(variablesSet=[[$cor0]], DEPTNO=[$0], I0=[$SCALAR_QUERY({
LogicalAggregate(group=[{}], EXPR$0=[MIN($0)])
LogicalProject($f0=[1])
LogicalFilter(condition=[>($0, $cor0.DEPTNO)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
})], I1=[$SCALAR_QUERY({
LogicalAggregate(group=[{}], EXPR$0=[MIN($0)])
LogicalProject($f0=[0])
LogicalFilter(condition=[AND(=($7, $cor0.DEPTNO), =($1, 'SMITH'), >($cor0.DEPTNO, 0))])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
})])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
<Resource name="planExpanded">
<![CDATA[
LogicalProject(DEPTNO=[$0], I0=[$2], I1=[$3])
LogicalCorrelate(correlation=[$cor1], joinType=[left], requiredColumns=[{0}])
LogicalCorrelate(correlation=[$cor0], joinType=[left], requiredColumns=[{0}])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
LogicalAggregate(group=[{}], EXPR$0=[MIN($0)])
LogicalProject($f0=[1])
LogicalFilter(condition=[>($0, $cor0.DEPTNO)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{}], EXPR$0=[MIN($0)])
LogicalProject($f0=[0])
LogicalFilter(condition=[AND(=($7, $cor1.DEPTNO), =($1, 'SMITH'), >($cor1.DEPTNO, 0))])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select deptno,
(select min(1) from emp where empno > d.deptno) as i0,
(select min(0) from emp where deptno = d.deptno and ename = 'SMITH' and d.deptno > 0) as i1
from dept as d]]>
</Resource>
</TestCase>
<TestCase name="testCorrelatedSubQueryInAggregate">
<Resource name="sql">
<![CDATA[SELECT SUM(
(select char_length(name) from dept
where dept.deptno = emp.empno))
FROM emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{}], EXPR$0=[SUM($0)])
LogicalProject($f0=[$SCALAR_QUERY({
LogicalProject(EXPR$0=[CHAR_LENGTH($1)])
LogicalFilter(condition=[=($0, $cor0.EMPNO)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
})])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testCorrelatedSubQueryInJoin">
<Resource name="sql">
<![CDATA[select *
from emp as e
join dept as d using (deptno)
where d.name = (
select max(name)
from dept as d2
where d2.deptno = d.deptno)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$7], EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], SLACKER=[$8], NAME=[$10])
LogicalFilter(condition=[=($10, $SCALAR_QUERY({
LogicalAggregate(group=[{}], EXPR$0=[MAX($0)])
LogicalProject(NAME=[$1])
LogicalFilter(condition=[=($0, $cor0.DEPTNO0)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
}))], variablesSet=[[$cor0]])
LogicalJoin(condition=[=($7, $9)], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testCorrelationAggregateGroupSets">
<Resource name="sql">
<![CDATA[select sum(e1.empno)
from emp e1, dept d1
where e1.deptno = d1.deptno
and e1.sal > (select avg(e2.sal) from emp e2
where e2.deptno = d1.deptno group by cube(comm, mgr))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{}], EXPR$0=[SUM($0)])
LogicalProject(EMPNO=[$0])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO0=[$9], NAME=[$10], DEPTNO1=[CAST($11):INTEGER], $f1=[CAST($12):INTEGER])
LogicalJoin(condition=[AND(=($9, $11), >($5, $12))], joinType=[inner])
LogicalJoin(condition=[=($7, $9)], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
LogicalAggregate(group=[{0}], agg#0=[SINGLE_VALUE($1)])
LogicalProject(DEPTNO=[$2], EXPR$0=[$3])
LogicalAggregate(group=[{0, 1, 2}], groups=[[{0, 1, 2}, {0, 2}, {1, 2}, {2}]], EXPR$0=[AVG($3)])
LogicalProject(COMM=[$6], MGR=[$3], DEPTNO=[$7], SAL=[$5])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testCorrelationCollectionTableInSubQuery">
<Resource name="planExpanded">
<![CDATA[
LogicalProject(DEPTNO=[$7], EXPR$1=[$9])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], $f0=[$9])
LogicalCorrelate(correlation=[$cor0], joinType=[left], requiredColumns=[{7}])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{}], agg#0=[SINGLE_VALUE($0)])
LogicalProject(NAME=[$0])
LogicalTableFunctionScan(invocation=[DEDUP($cor0.DEPTNO, $cor0.DEPTNO)], rowType=[RecordType(VARCHAR(1024) NAME)])
]]>
</Resource>
<Resource name="planNotExpanded">
<![CDATA[
LogicalProject(variablesSet=[[$cor0]], DEPTNO=[$7], EXPR$1=[$SCALAR_QUERY({
LogicalProject(NAME=[$0])
LogicalTableFunctionScan(invocation=[DEDUP($cor0.DEPTNO, $cor0.DEPTNO)], rowType=[RecordType(VARCHAR(1024) NAME)])
})])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select e.deptno,
(select * from table(DEDUP(e.deptno, e.deptno)))
from emp e]]>
</Resource>
</TestCase>
<TestCase name="testCorrelationExistsAndFilter">
<Resource name="sql">
<![CDATA[SELECT e1.empno
FROM emp e1, dept d1 where e1.deptno = d1.deptno
and e1.deptno < 10 and d1.deptno < 15
and exists (select * from emp e2 where e1.empno = e2.empno)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO0=[$9], NAME=[$10], EMPNO0=[CAST($11):INTEGER], $f1=[CAST($12):BOOLEAN])
LogicalJoin(condition=[=($0, $11)], joinType=[inner])
LogicalJoin(condition=[=($7, $9)], joinType=[inner])
LogicalFilter(condition=[<($7, 10)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalFilter(condition=[<($0, 15)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
LogicalAggregate(group=[{0}], agg#0=[MIN($1)])
LogicalProject(EMPNO=[$0], $f0=[true])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testCorrelationExistsAndFilterRex">
<Resource name="sql">
<![CDATA[SELECT e1.empno
FROM emp e1, dept d1 where e1.deptno = d1.deptno
and e1.deptno < 10 and d1.deptno < 15
and exists (select * from emp e2 where e1.empno = e2.empno)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO0=[$9], NAME=[$10], EMPNO0=[CAST($11):INTEGER], $f1=[CAST($12):BOOLEAN])
LogicalJoin(condition=[=($0, $11)], joinType=[inner])
LogicalJoin(condition=[=($7, $9)], joinType=[inner])
LogicalFilter(condition=[<($7, 10)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalFilter(condition=[<($0, 15)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
LogicalAggregate(group=[{0}], agg#0=[MIN($1)])
LogicalProject(EMPNO=[$0], $f0=[true])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testCorrelationExistsAndFilterThetaRex">
<Resource name="sql">
<![CDATA[SELECT e1.empno
FROM emp e1, dept d1 where e1.deptno = d1.deptno
and e1.deptno < 10 and d1.deptno < 15
and exists (select * from emp e2 where e1.empno < e2.empno)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO0=[$9], NAME=[$10], EMPNO0=[CAST($11):INTEGER], $f1=[CAST($12):BOOLEAN])
LogicalJoin(condition=[=($0, $11)], joinType=[inner])
LogicalJoin(condition=[=($7, $9)], joinType=[inner])
LogicalFilter(condition=[<($7, 10)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalFilter(condition=[<($0, 15)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
LogicalAggregate(group=[{0}], agg#0=[MIN($1)])
LogicalProject(EMPNO0=[$9], $f0=[true])
LogicalJoin(condition=[<($9, $0)], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0}])
LogicalProject(EMPNO=[$0])
LogicalJoin(condition=[=($7, $9)], joinType=[inner])
LogicalFilter(condition=[<($7, 10)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalFilter(condition=[<($0, 15)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testCorrelationExistsWithSubQuery">
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$7], DEPTNO0=[$9])
LogicalFilter(condition=[EXISTS({
LogicalFilter(condition=[AND(=($7, $cor2.DEPTNO0), =($7, $cor2.DEPTNO0), OR(=($7, $cor2.DEPTNO0), =($7, $cor2.DEPTNO0)))])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
})], variablesSet=[[$cor2]])
LogicalJoin(condition=[true], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select emp.deptno, dept.deptno
from emp, dept
where exists (select * from emp
where emp.deptno = dept.deptno
and emp.deptno = dept.deptno
and emp.deptno in (dept.deptno, dept.deptno))]]>
</Resource>
</TestCase>
<TestCase name="testCorrelationInProjectionWithCorrelatedProjection">
<Resource name="sql">
<![CDATA[select cardinality(arr) from (
select array(select e.deptno) arr from (
select deptno, ename from emp) e)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(variablesSet=[[$cor0]], EXPR$0=[CARDINALITY(ARRAY({
LogicalProject(DEPTNO=[$cor0.DEPTNO])
LogicalValues(tuples=[[{ 0 }]])
}))])
LogicalProject(DEPTNO=[$7], ENAME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testCorrelationInProjectionWithProjection">
<Resource name="sql">
<![CDATA[select array(select e.deptno)
from (select deptno, ename from emp) e]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(variablesSet=[[$cor0]], EXPR$0=[ARRAY({
LogicalProject(DEPTNO=[$cor0.DEPTNO])
LogicalValues(tuples=[[{ 0 }]])
})])
LogicalProject(DEPTNO=[$7], ENAME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testCorrelationInProjectionWithScan">
<Resource name="sql">
<![CDATA[select array(select e.deptno) from emp e]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(variablesSet=[[$cor0]], EXPR$0=[ARRAY({
LogicalProject(DEPTNO=[$cor0.DEPTNO])
LogicalValues(tuples=[[{ 0 }]])
})])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testCorrelationInWithSubQuery">
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$7])
LogicalFilter(condition=[IN($7, {
LogicalProject(DEPTNO=[$0])
LogicalFilter(condition=[AND(=($cor0.DEPTNO, $0), =($cor0.DEPTNO, $0))])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
})], variablesSet=[[$cor0]])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select deptno
from emp
where deptno in (select deptno
from dept
where emp.deptno = dept.deptno
and emp.deptno = dept.deptno)]]>
</Resource>
</TestCase>
<TestCase name="testCorrelationJoin">
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], NAME=[$1], EMPSET=[$2])
LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{0}])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
Collect(field=[EXPR$0])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalFilter(condition=[=($7, $cor0.DEPTNO)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select *,
multiset(select * from emp where deptno=dept.deptno) as empset
from dept]]>
</Resource>
</TestCase>
<TestCase name="testCorrelationJoinRex">
<Resource name="sql">
<![CDATA[select *,
multiset(select * from emp where deptno=dept.deptno) as empset
from dept]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], NAME=[$1], EMPSET=[MULTISET({
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalFilter(condition=[=($7, $cor0.DEPTNO)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
})])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testCorrelationLateralSubQuery">
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], ENAME=[$1])
LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{0}])
LogicalAggregate(group=[{0}])
LogicalProject(DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalSort(sort0=[$1], dir0=[DESC], fetch=[3])
LogicalProject(ENAME=[$1], SAL=[$5])
LogicalFilter(condition=[AND(OR(=($7, $cor0.DEPTNO), =($7, $cor0.DEPTNO)), =($7, $cor0.DEPTNO))])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[SELECT deptno, ename
FROM
(SELECT DISTINCT deptno FROM emp) t1,
LATERAL (
SELECT ename, sal
FROM emp
WHERE deptno IN (t1.deptno, t1.deptno)
AND deptno = t1.deptno
ORDER BY sal
DESC LIMIT 3)]]>
</Resource>
</TestCase>
<TestCase name="testCorrelationMultiScalarAggregate">
<Resource name="sql">
<![CDATA[select sum(e1.empno)
from emp e1, dept d1
where e1.deptno = d1.deptno
and e1.sal > (select avg(e2.sal) from emp e2
where e2.deptno = d1.deptno)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{}], EXPR$0=[SUM($0)])
LogicalProject(EMPNO=[$0])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO0=[$9], NAME=[$10], DEPTNO1=[CAST($11):INTEGER], EXPR$0=[CAST($12):INTEGER])
LogicalJoin(condition=[AND(=($9, $11), >($5, $12))], joinType=[inner])
LogicalJoin(condition=[=($7, $9)], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
LogicalAggregate(group=[{0}], EXPR$0=[AVG($1)])
LogicalProject(DEPTNO=[$7], SAL=[$5])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testCorrelationNotExistsAndFilter">
<Resource name="sql">
<![CDATA[SELECT e1.empno
FROM emp e1, dept d1 where e1.deptno = d1.deptno
and e1.deptno < 10 and d1.deptno < 15
and not exists (select * from emp e2 where e1.empno = e2.empno)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0])
LogicalFilter(condition=[IS NULL($12)])
LogicalJoin(condition=[=($0, $11)], joinType=[left])
LogicalJoin(condition=[=($7, $9)], joinType=[inner])
LogicalFilter(condition=[<($7, 10)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalFilter(condition=[<($0, 15)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
LogicalAggregate(group=[{0}], agg#0=[MIN($1)])
LogicalProject(EMPNO=[$0], $f0=[true])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testCorrelationScalarAggAndFilter">
<Resource name="sql">
<![CDATA[SELECT e1.empno
FROM emp e1, dept d1 where e1.deptno = d1.deptno
and e1.deptno < 10 and d1.deptno < 15
and e1.sal > (select avg(sal) from emp e2 where e1.empno = e2.empno)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO0=[$9], NAME=[$10], EMPNO0=[CAST($11):INTEGER], EXPR$0=[CAST($12):INTEGER])
LogicalJoin(condition=[AND(=($0, $11), >($5, $12))], joinType=[inner])
LogicalJoin(condition=[=($7, $9)], joinType=[inner])
LogicalFilter(condition=[<($7, 10)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalFilter(condition=[<($0, 15)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
LogicalAggregate(group=[{0}], EXPR$0=[AVG($1)])
LogicalProject(EMPNO=[$0], SAL=[$5])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testCorrelationScalarAggAndFilterRex">
<Resource name="sql">
<![CDATA[SELECT e1.empno
FROM emp e1, dept d1 where e1.deptno = d1.deptno
and e1.deptno < 10 and d1.deptno < 15
and e1.sal > (select avg(sal) from emp e2 where e1.empno = e2.empno)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0])
LogicalFilter(condition=[AND(=($7, $9), <($7, 10), <($9, 15), >($5, $SCALAR_QUERY({
LogicalAggregate(group=[{}], EXPR$0=[AVG($0)])
LogicalProject(SAL=[$5])
LogicalFilter(condition=[=($cor0.EMPNO, $0)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
})))], variablesSet=[[$cor0]])
LogicalJoin(condition=[true], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testCountNoGroup">
<Resource name="sql">
<![CDATA[select count(*), sum(sal)
from emp
where empno > 10]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{}], EXPR$0=[COUNT()], EXPR$1=[SUM($0)])
LogicalProject(SAL=[$5])
LogicalFilter(condition=[>($0, 10)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testCrossJoinLateral1">
<Resource name="sql">
<![CDATA[select * from (values (4,5)) as t(c,d)
cross join lateral
(select c,a*c as f from (values 2) as s(a)
where c+d=a*c)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(C=[$0], D=[$1], C0=[$2], F=[$3])
LogicalProject(C=[$0], D=[$1], C0=[$4], F=[$5])
LogicalCorrelate(correlation=[$cor3], joinType=[inner], requiredColumns=[{2, 3}])
LogicalProject(C=[$0], D=[$1], C0=[$0], $f3=[+($0, $1)])
LogicalValues(tuples=[[{ 4, 5 }]])
LogicalProject(C=[$cor3.C], F=[*($0, $cor3.C)])
LogicalFilter(condition=[=($cor3.$f3, *($0, $cor3.C))])
LogicalValues(tuples=[[{ 2 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testCrossJoinLateral2">
<Resource name="sql">
<![CDATA[select * from (values 4) as t (c)
cross join lateral
(select * from (
select f1+b1 from (values 2) as foo(f1)
join
(select c+1 from (values 3)) as bar(b1)
on f1=b1
) as r(n) where c=n)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(C=[$0], N=[$1])
LogicalProject(C=[$0], N=[$3])
LogicalCorrelate(correlation=[$cor1], joinType=[inner], requiredColumns=[{1, 2}])
LogicalProject(C=[$0], C0=[$0], $f2=[+($0, 1)])
LogicalValues(tuples=[[{ 4 }]])
LogicalProject(N=[$0])
LogicalFilter(condition=[=($cor1.C, $0)])
LogicalProject(EXPR$0=[+($0, $1)])
LogicalJoin(condition=[=($0, $1)], joinType=[inner])
LogicalValues(tuples=[[{ 2 }]])
LogicalProject(EXPR$0=[$cor1.$f2])
LogicalValues(tuples=[[{ 3 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testCrossJoinTemporalTable1">
<Resource name="sql">
<![CDATA[select stream *
from orders
cross join lateral (
select * from products_temporal for system_time
as of orders.rowtime
where orders.productid = products_temporal.productid)
]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalDelta
LogicalProject(ROWTIME=[$0], PRODUCTID=[$1], ORDERID=[$2], PRODUCTID0=[$3], NAME=[$4], SUPPLIERID=[$5], SYS_START=[$6], SYS_END=[$7], SYS_START_LOCAL_TIMESTAMP=[$8], SYS_END_LOCAL_TIMESTAMP=[$9])
LogicalCorrelate(correlation=[$cor1], joinType=[inner], requiredColumns=[{0, 1}])
LogicalTableScan(table=[[CATALOG, SALES, ORDERS]])
LogicalProject(PRODUCTID=[$0], NAME=[$1], SUPPLIERID=[$2], SYS_START=[$3], SYS_END=[$4], SYS_START_LOCAL_TIMESTAMP=[$5], SYS_END_LOCAL_TIMESTAMP=[$6])
LogicalFilter(condition=[=($cor1.PRODUCTID, $0)])
LogicalSnapshot(period=[$cor1.ROWTIME])
LogicalTableScan(table=[[CATALOG, SALES, PRODUCTS_TEMPORAL]])
]]>
</Resource>
</TestCase>
<TestCase name="testCrossJoinTemporalTable2">
<Resource name="sql">
<![CDATA[select stream *
from orders
cross join lateral (
select * from products_temporal for system_time
as of TIMESTAMP '2011-01-02 00:00:00'
where orders.productid = products_temporal.productid)
]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalDelta
LogicalProject(ROWTIME=[$0], PRODUCTID=[$1], ORDERID=[$2], PRODUCTID0=[$3], NAME=[$4], SUPPLIERID=[$5], SYS_START=[$6], SYS_END=[$7], SYS_START_LOCAL_TIMESTAMP=[$8], SYS_END_LOCAL_TIMESTAMP=[$9])
LogicalJoin(condition=[=($1, $10)], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, ORDERS]])
LogicalProject(PRODUCTID=[$0], NAME=[$1], SUPPLIERID=[$2], SYS_START=[$3], SYS_END=[$4], SYS_START_LOCAL_TIMESTAMP=[$5], SYS_END_LOCAL_TIMESTAMP=[$6], PRODUCTID7=[$0])
LogicalSnapshot(period=[2011-01-02 00:00:00])
LogicalTableScan(table=[[CATALOG, SALES, PRODUCTS_TEMPORAL]])
]]>
</Resource>
</TestCase>
<TestCase name="testCrossJoinTemporalTable3">
<Resource name="sql">
<![CDATA[select stream *
from orders
cross join lateral (
select * from products_temporal for system_time
as of orders.rowtime
where products_temporal.productid > 1)
]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalDelta
LogicalProject(ROWTIME=[$0], PRODUCTID=[$1], ORDERID=[$2], PRODUCTID0=[$3], NAME=[$4], SUPPLIERID=[$5], SYS_START=[$6], SYS_END=[$7], SYS_START_LOCAL_TIMESTAMP=[$8], SYS_END_LOCAL_TIMESTAMP=[$9])
LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{0}])
LogicalTableScan(table=[[CATALOG, SALES, ORDERS]])
LogicalProject(PRODUCTID=[$0], NAME=[$1], SUPPLIERID=[$2], SYS_START=[$3], SYS_END=[$4], SYS_START_LOCAL_TIMESTAMP=[$5], SYS_END_LOCAL_TIMESTAMP=[$6])
LogicalFilter(condition=[>($0, 1)])
LogicalSnapshot(period=[$cor0.ROWTIME])
LogicalTableScan(table=[[CATALOG, SALES, PRODUCTS_TEMPORAL]])
]]>
</Resource>
</TestCase>
<TestCase name="testCube">
<Resource name="sql">
<![CDATA[select 1
from (values (1, 2, 3, 4)) as t(a, b, c, d)
group by cube(a, b)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[1])
LogicalAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}, {1}, {}]])
LogicalProject(A=[$0], B=[$1])
LogicalValues(tuples=[[{ 1, 2, 3, 4 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testCustomColumnResolving">
<Resource name="sql">
<![CDATA[select k0 from struct.t]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(K0=[$0])
LogicalTableScan(table=[[CATALOG, STRUCT, T]])
]]>
</Resource>
</TestCase>
<TestCase name="testCustomColumnResolving2">
<Resource name="sql">
<![CDATA[select c2 from struct.t]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(C2=[$7])
LogicalTableScan(table=[[CATALOG, STRUCT, T]])
]]>
</Resource>
</TestCase>
<TestCase name="testCustomColumnResolving3">
<Resource name="sql">
<![CDATA[select f1.c2 from struct.t]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(C2=[$7])
LogicalTableScan(table=[[CATALOG, STRUCT, T]])
]]>
</Resource>
</TestCase>
<TestCase name="testCustomColumnResolving4">
<Resource name="sql">
<![CDATA[select c1 from struct.t order by f0.c1]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(C1=[$0])
LogicalSort(sort0=[$1], dir0=[ASC])
LogicalProject(C1=[$1], "F0"."C1"=[$6])
LogicalTableScan(table=[[CATALOG, STRUCT, T]])
]]>
</Resource>
</TestCase>
<TestCase name="testCustomColumnResolving5">
<Resource name="sql">
<![CDATA[select count(c1) from struct.t group by f0.c1]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[$1])
LogicalAggregate(group=[{0}], EXPR$0=[COUNT()])
LogicalProject("F0"."C1"=[$6], "C1"=[$1])
LogicalTableScan(table=[[CATALOG, STRUCT, T]])
]]>
</Resource>
</TestCase>
<TestCase name="testCustomColumnResolvingWithSelectFieldNameDotStar">
<Resource name="sql">
<![CDATA[select f1.* from struct.t]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject("F1"."A0"=[$2], "F1"."C0"=[$5], "F1"."C2"=[$7])
LogicalTableScan(table=[[CATALOG, STRUCT, T]])
]]>
</Resource>
</TestCase>
<TestCase name="testCustomColumnResolvingWithSelectStar">
<Resource name="sql">
<![CDATA[select * from struct.t]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject("K0"=[$0], "C1"=[$1], "F1"."A0"=[$2], "F2"."A0"=[$3], "F0"."C0"=[$4], "F1"."C0"=[$5], "F0"."C1"=[$6], "F1"."C2"=[$7], "F2"."C3"=[$8])
LogicalTableScan(table=[[CATALOG, STRUCT, T]])
]]>
</Resource>
</TestCase>
<TestCase name="testDelete">
<Resource name="sql">
<![CDATA[delete from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMP]], operation=[DELETE], flattened=[true])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testDeleteBind">
<Resource name="sql">
<![CDATA[delete from emp where deptno = ?]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMP]], operation=[DELETE], flattened=[true])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalFilter(condition=[=($7, ?0)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testDeleteBindExtendedColumn">
<Resource name="sql">
<![CDATA[delete from emp(enddate TIMESTAMP) where enddate < ?]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMP]], operation=[DELETE], flattened=[true])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], ENDDATE=[$9])
LogicalFilter(condition=[<($9, ?0)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testDeleteBindExtendedColumnModifiableView">
<Resource name="sql">
<![CDATA[delete from EMP_MODIFIABLEVIEW2(note VARCHAR)
where note = ?]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMP_MODIFIABLEVIEW2]], operation=[DELETE], flattened=[true])
LogicalProject(ENAME=[$0], EMPNO=[$1], JOB=[$2], DEPTNO=[$3], SLACKER=[$4], SAL=[$5], EXTRA=[$6], HIREDATE=[$7], MGR=[$8], COMM=[$9], NOTE=[$10])
LogicalFilter(condition=[=($10, ?0)])
LogicalTableScan(table=[[CATALOG, SALES, EMP_MODIFIABLEVIEW2]])
]]>
</Resource>
</TestCase>
<TestCase name="testDeleteBindModifiableView">
<Resource name="sql">
<![CDATA[delete from EMP_MODIFIABLEVIEW2 where empno = ?]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMP_MODIFIABLEVIEW2]], operation=[DELETE], flattened=[true])
LogicalProject(ENAME=[$0], EMPNO=[$1], JOB=[$2], DEPTNO=[$3], SLACKER=[$4], SAL=[$5], EXTRA=[$6], HIREDATE=[$7], MGR=[$8], COMM=[$9])
LogicalFilter(condition=[=($1, ?0)])
LogicalTableScan(table=[[CATALOG, SALES, EMP_MODIFIABLEVIEW2]])
]]>
</Resource>
</TestCase>
<TestCase name="testDeleteWhere">
<Resource name="sql">
<![CDATA[delete from emp where deptno = 10]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMP]], operation=[DELETE], flattened=[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]])
]]>
</Resource>
</TestCase>
<TestCase name="testDoNotPushDownJoinCondition">
<Resource name="sql">
<![CDATA[select *
from emp as e
join dept as d on e.deptno + 20 = d.deptno / 2]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO0=[$9], NAME=[$10])
LogicalJoin(condition=[=(+($7, 20), /($9, 2))], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testDotAfterParenthesizedIdentifier">
<Resource name="sql">
<![CDATA[select (home_address).city from emp_address]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[$1.CITY])
LogicalTableScan(table=[[CATALOG, SALES, EMP_ADDRESS]])
]]>
</Resource>
</TestCase>
<TestCase name="testDotLiteralAfterNestedRow">
<Resource name="sql">
<![CDATA[select ((1,2),(3,4,5))."EXPR$1"."EXPR$2" from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[ROW(ROW(1, 2), ROW(3, 4, 5)).EXPR$1.EXPR$2])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testDotLiteralAfterRow">
<Resource name="sql">
<![CDATA[select row(1,2)."EXPR$1" from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[ROW(1, 2).EXPR$1])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testDuplicateColumnsInSubQuery">
<Resource name="sql">
<![CDATA[select "e" from (
select empno as "e", deptno as d, 1 as "e0" from EMP)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(e=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testDuplicateGroupingSets">
<Resource name="sql">
<![CDATA[select sum(sal) from emp
group by sal,
grouping sets (deptno,
grouping sets ((deptno, ename), ename),
(ename)),
()]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[$3])
LogicalUnion(all=[true])
LogicalAggregate(group=[{0, 1, 2}], groups=[[{0, 1, 2}, {0, 1}, {0, 2}]], EXPR$0=[SUM($0)])
LogicalProject(SAL=[$5], DEPTNO=[$7], ENAME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0, 1, 2}], groups=[[{0, 2}]], EXPR$0=[SUM($0)])
LogicalProject(SAL=[$5], DEPTNO=[$7], ENAME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testDynStarInExistSubQ">
<Resource name="sql">
<![CDATA[select *
from SALES.REGION where exists (select * from SALES.NATION)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(R_REGIONKEY=[$0], R_NAME=[$1], R_COMMENT=[$2])
LogicalFilter(condition=[IS NOT NULL($3)])
LogicalJoin(condition=[true], joinType=[left])
LogicalTableScan(table=[[CATALOG, SALES, REGION]])
LogicalAggregate(group=[{}], agg#0=[MIN($0)])
LogicalProject($f0=[true])
LogicalTableScan(table=[[CATALOG, SALES, NATION]])
]]>
</Resource>
</TestCase>
<TestCase name="testDynamicNestedColumn">
<Resource name="sql">
<![CDATA[select t3.fake_q1['fake_col2'] as fake2
from (
select t2.fake_col as fake_q1
from SALES.CUSTOMER as t2) as t3]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(FAKE2=[ITEM($0, 'fake_col2')])
LogicalTableScan(table=[[CATALOG, SALES, CUSTOMER]])
]]>
</Resource>
</TestCase>
<TestCase name="testDynamicParameterDoubleCast">
<Resource name="sql">
<![CDATA[SELECT CAST(CAST(? AS INTEGER) AS CHAR)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[CAST(?0):CHAR(1)])
LogicalValues(tuples=[[{ 0 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testDynamicParameterSortWithTrim">
<Resource name="sql">
<![CDATA[select ename from (select * from emp order by sal limit ? offset ?) a]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ENAME=[$0])
LogicalSort(sort0=[$1], dir0=[ASC], offset=[?1], fetch=[?0])
LogicalProject(ENAME=[$1], SAL=[$5])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testDynamicSchemaUnnest">
<Resource name="sql">
<![CDATA[select t1.c_nationkey, t3.fake_col3
from SALES.CUSTOMER as t1,
lateral (select t2 as fake_col3
from unnest(t1.fake_col) as t2) as t3]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(C_NATIONKEY=[$1], FAKE_COL3=[$2])
LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{0}])
LogicalTableScan(table=[[CATALOG, SALES, CUSTOMER]])
LogicalProject(FAKE_COL3=[$0])
Uncollect
LogicalProject(FAKE_COL=[$cor0.FAKE_COL])
LogicalValues(tuples=[[{ 0 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testDynamicStarInJoinAndSubQ">
<Resource name="sql">
<![CDATA[select * from (select * from SALES.NATION T1, SALES.CUSTOMER T2 where T1.n_nationkey = T2.c_nationkey)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(**=[$1], **0=[$3])
LogicalFilter(condition=[=($0, $2)])
LogicalJoin(condition=[true], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, NATION]])
LogicalTableScan(table=[[CATALOG, SALES, CUSTOMER]])
]]>
</Resource>
</TestCase>
<TestCase name="testDynamicStarInTableJoin">
<Resource name="sql">
<![CDATA[select * from (select * from SALES.NATION) T1, (SELECT * from SALES.CUSTOMER) T2 where T1.n_nationkey = T2.c_nationkey]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(**=[$0], **0=[$1])
LogicalFilter(condition=[=(ITEM($0, 'N_NATIONKEY'), ITEM($1, 'C_NATIONKEY'))])
LogicalJoin(condition=[true], joinType=[inner])
LogicalProject(**=[$0])
LogicalTableScan(table=[[CATALOG, SALES, NATION]])
LogicalProject(**=[$0])
LogicalTableScan(table=[[CATALOG, SALES, CUSTOMER]])
]]>
</Resource>
</TestCase>
<TestCase name="testElement">
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[ELEMENT($SLICE($9))])
LogicalJoin(condition=[true], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
Collect(field=[EXPR$0])
LogicalValues(tuples=[[{ 5 }]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select element(multiset[5]) from emp]]>
</Resource>
</TestCase>
<TestCase name="testElementInValues">
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[ELEMENT($SLICE($0))])
Collect(field=[EXPR$0])
LogicalValues(tuples=[[{ 5 }]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[values element(multiset[5])]]>
</Resource>
</TestCase>
<TestCase name="testExists">
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalFilter(condition=[IS NOT NULL($9)])
LogicalJoin(condition=[true], joinType=[left])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{}], agg#0=[MIN($0)])
LogicalProject($f0=[true])
LogicalFilter(condition=[=($0, 55)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select*from emp
where exists (select 1 from dept where deptno=55)]]>
</Resource>
</TestCase>
<TestCase name="testExistsCorrelated">
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalFilter(condition=[IS NOT NULL($9)])
LogicalCorrelate(correlation=[$cor0], joinType=[left], requiredColumns=[{7}])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{}], agg#0=[MIN($0)])
LogicalProject($f0=[true])
LogicalFilter(condition=[=($cor0.DEPTNO, $0)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select*from emp where exists (
select 1 from dept where emp.deptno=dept.deptno)]]>
</Resource>
</TestCase>
<TestCase name="testExistsCorrelatedDecorrelate">
<Resource name="sql">
<![CDATA[select*from emp where exists (
select 1 from dept where emp.deptno=dept.deptno)]]>
</Resource>
<Resource name="plan">
<![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], DEPTNO0=[CAST($9):INTEGER], $f1=[CAST($10):BOOLEAN])
LogicalJoin(condition=[=($7, $9)], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0}], agg#0=[MIN($1)])
LogicalProject(DEPTNO=[$0], $f0=[true])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testExistsCorrelatedDecorrelateRex">
<Resource name="sql">
<![CDATA[select*from emp where exists (
select 1 from dept where emp.deptno=dept.deptno)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalFilter(condition=[EXISTS({
LogicalFilter(condition=[=($cor0.DEPTNO, $0)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
})], variablesSet=[[$cor0]])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testExistsCorrelatedLimit">
<Resource name="sql">
<![CDATA[select*from emp where exists (
select 1 from dept where emp.deptno=dept.deptno limit 1)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalFilter(condition=[IS NOT NULL($9)])
LogicalCorrelate(correlation=[$cor0], joinType=[left], requiredColumns=[{7}])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{}], agg#0=[MIN($0)])
LogicalProject($f0=[true])
LogicalSort(fetch=[1])
LogicalProject(EXPR$0=[1])
LogicalFilter(condition=[=($cor0.DEPTNO, $0)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testExistsCorrelatedLimitDecorrelate">
<Resource name="sql">
<![CDATA[select*from emp where exists (
select 1 from dept where emp.deptno=dept.deptno limit 1)]]>
</Resource>
<Resource name="plan">
<![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], $f0=[$9])
LogicalFilter(condition=[IS NOT NULL($9)])
LogicalCorrelate(correlation=[$cor0], joinType=[left], requiredColumns=[{7}])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{}], agg#0=[MIN($0)])
LogicalProject($f0=[true])
LogicalSort(fetch=[1])
LogicalProject(EXPR$0=[1])
LogicalFilter(condition=[=($cor0.DEPTNO, $0)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testExistsCorrelatedLimitDecorrelateRex">
<Resource name="sql">
<![CDATA[select*from emp where exists (
select 1 from dept where emp.deptno=dept.deptno limit 1)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalFilter(condition=[EXISTS({
LogicalSort(fetch=[1])
LogicalProject(EXPR$0=[1])
LogicalFilter(condition=[=($cor0.DEPTNO, $0)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
})], variablesSet=[[$cor0]])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testExistsDecorrelateComplexCorrelationPredicate">
<Resource name="sql">
<![CDATA[select e1.empno from empnullables e1 where exists (
select 1 from empnullables e2 where COALESCE(e1.ename,'M')=COALESCE(e2.ename,'M'))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0])
LogicalFilter(condition=[IS NOT NULL($9)])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], $f0=[$11])
LogicalJoin(condition=[=($9, $10)], joinType=[left])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], $f9=[CASE(IS NOT NULL($1), $1, 'M':VARCHAR(20))])
LogicalTableScan(table=[[CATALOG, SALES, EMPNULLABLES]])
LogicalAggregate(group=[{0}], agg#0=[MIN($1)])
LogicalProject($f9=[CASE(IS NOT NULL($1), CAST($1):VARCHAR(20) NOT NULL, 'M':VARCHAR(20))], $f0=[true])
LogicalTableScan(table=[[CATALOG, SALES, EMPNULLABLES]])
]]>
</Resource>
</TestCase>
<TestCase name="testExplicitTable">
<Resource name="sql">
<![CDATA[table emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testFakeStar">
<Resource name="sql">
<![CDATA[SELECT * FROM (VALUES (0, 0)) AS T(A, "*")]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(A=[$0], *=[$1])
LogicalValues(tuples=[[{ 0, 0 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testFetch">
<Resource name="sql">
<![CDATA[select empno from emp fetch next 5 rows only]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalSort(fetch=[5])
LogicalProject(EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testFetchWithDynamicParameter">
<Resource name="sql">
<![CDATA[select empno from emp fetch next ? rows only]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalSort(fetch=[?0])
LogicalProject(EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testFlattenRecords">
<Resource name="sql">
<![CDATA[select employees[1] from dept_nested]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[ROW(ITEM($3, 1).EMPNO, ITEM($3, 1).ENAME, ROW(ITEM($3, 1).DETAIL.SKILLS))])
LogicalTableScan(table=[[CATALOG, SALES, DEPT_NESTED]])
]]>
</Resource>
</TestCase>
<TestCase name="testFunctionExprInOver">
<Resource name="sql">
<![CDATA[select ename, row_number() over(partition by char_length(ename)
order by deptno desc) as rn
from emp
where deptno = 10]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ENAME=[$1], RN=[ROW_NUMBER() OVER (PARTITION BY CHAR_LENGTH($1) ORDER BY $7 DESC)])
LogicalFilter(condition=[=($7, 10)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testFunctionWithStructInput">
<Resource name="sql">
<![CDATA[select json_type(skill)
from sales.dept_nested]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[JSON_TYPE(ROW($2.TYPE, $2.DESC, ROW($2.OTHERS.A, $2.OTHERS.B)))])
LogicalTableScan(table=[[CATALOG, SALES, DEPT_NESTED]])
]]>
</Resource>
</TestCase>
<TestCase name="testGroup">
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{0}])
LogicalProject(DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select deptno from emp group by deptno]]>
</Resource>
</TestCase>
<TestCase name="testGroupAlias">
<Resource name="sql">
<![CDATA[select "$f2", max(x), max(x + 1)
from (values (1, 2)) as t("$f2", x)
group by "$f2"]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{0}], EXPR$1=[MAX($1)], EXPR$2=[MAX($2)])
LogicalProject($f2=[$0], X=[$1], $f3=[+($1, 1)])
LogicalValues(tuples=[[{ 1, 2 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testGroupBug281">
<Resource name="plan">
<![CDATA[
LogicalProject(NAME=[$0])
LogicalAggregate(group=[{0}])
LogicalProject(NAME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select name from (select name from dept group by name)]]>
</Resource>
</TestCase>
<TestCase name="testGroupBug281b">
<Resource name="plan">
<![CDATA[
LogicalProject(NAME=[$0], FOO=[$2])
LogicalAggregate(group=[{0, 1}], FOO=[COUNT()])
LogicalProject(NAME=[$1], DEPTNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select name, foo from (
select deptno, name, count(deptno) as foo
from dept
group by name, deptno, name)]]>
</Resource>
</TestCase>
<TestCase name="testGroupByAlias">
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{0}])
LogicalProject(D=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select empno as d from emp group by d]]>
</Resource>
</TestCase>
<TestCase name="testGroupByAliasEqualToColumnName">
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{0, 1}])
LogicalProject(EMPNO=[$0], DEPTNO=[$1])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select empno, ename as deptno from emp group by empno, deptno]]>
</Resource>
</TestCase>
<TestCase name="testGroupByAliasOfSubExpressionsInProject">
<Resource name="plan">
<![CDATA[
LogicalProject(D=[$0], EXPR$1=[+($0, $1)])
LogicalAggregate(group=[{0, 1}])
LogicalProject(D=[+($7, $0)], MGR=[$3])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select deptno+empno as d, deptno+empno+mgr
from emp group by d,mgr]]>
</Resource>
</TestCase>
<TestCase name="testGroupByAll">
<Resource name="sql">
<![CDATA[SELECT deptno, job, count(*)
FROM emp
GROUP BY ALL
CUBE (deptno, job),
ROLLUP (deptno, job)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalUnion(all=[true])
LogicalAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}, {1}, {}]], EXPR$2=[COUNT()])
LogicalProject(DEPTNO=[$7], JOB=[$2])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}]], EXPR$2=[COUNT()])
LogicalProject(DEPTNO=[$7], JOB=[$2])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}]], EXPR$2=[COUNT()])
LogicalProject(DEPTNO=[$7], JOB=[$2])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0, 1}], EXPR$2=[COUNT()])
LogicalProject(DEPTNO=[$7], JOB=[$2])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0, 1}], EXPR$2=[COUNT()])
LogicalProject(DEPTNO=[$7], JOB=[$2])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0, 1}], EXPR$2=[COUNT()])
LogicalProject(DEPTNO=[$7], JOB=[$2])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0, 1}], EXPR$2=[COUNT()])
LogicalProject(DEPTNO=[$7], JOB=[$2])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testGroupByCaseIn">
<Resource name="sql">
<![CDATA[select
(CASE WHEN (deptno IN (10, 20)) THEN 0 ELSE deptno END),
min(empno) from EMP
group by (CASE WHEN (deptno IN (10, 20)) THEN 0 ELSE deptno END)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{0}], EXPR$1=[MIN($1)])
LogicalProject(EXPR$0=[CASE(SEARCH($7, Sarg[10, 20]), 0, $7)], EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testGroupByCaseSubQuery">
<Resource name="sql">
<![CDATA[SELECT CASE WHEN emp.empno IN (3) THEN 0 ELSE 1 END
FROM emp
GROUP BY (CASE WHEN emp.empno IN (3) THEN 0 ELSE 1 END)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{0}])
LogicalProject(EXPR$0=[CASE(=($0, 3), 0, 1)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testGroupByCoalesceIn">
<Resource name="sql">
<![CDATA[select case when coalesce(ename, 'a') in ('1', '2')
then 'CKA' else 'QT' END, count(distinct deptno) from emp
group by case when coalesce(ename, 'a') in ('1', '2') then 'CKA' else 'QT' END]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{0}], EXPR$1=[COUNT(DISTINCT $1)])
LogicalProject(EXPR$0=[CASE(SEARCH($1, Sarg['1', '2']:CHAR(1)), 'CKA', 'QT ')], DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testGroupByContainsLiterals">
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{}], EXPR$0=[COUNT()])
LogicalProject($f0=[0])
LogicalAggregate(group=[{0}])
LogicalProject($f0=[SUBSTRING($1, 2, 3)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select count(*) from (
select 1 from emp group by substring(ename from 2 for 3))]]>
</Resource>
</TestCase>
<TestCase name="testGroupByCubeWithNestedColumn">
<Resource name="plan">
<![CDATA[
LogicalProject(X=[$1], unit=[$2], A=[$0], EXPR$3=[$3])
LogicalAggregate(group=[{0, 1, 2}], groups=[[{0, 1, 2}, {0, 1}, {0, 2}, {0}, {1, 2}, {1}, {2}, {}]], EXPR$3=[AVG($3)])
LogicalProject(A=[$5.SUB.A], X=[$4.X], unit=[$4.unit], $f3=[$4.Y])
LogicalTableScan(table=[[CATALOG, CUSTOMER, CONTACT_PEEK]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select
coord.x,
coord."unit",
coord_ne.sub.a,
avg(coord.y)
from
customer.contact_peek
group by
cube (coord_ne.sub.a, coord.x, coord."unit")]]>
</Resource>
</TestCase>
<TestCase name="testGroupByDistinct">
<Resource name="sql">
<![CDATA[SELECT deptno, job, count(*)
FROM emp
GROUP BY DISTINCT
CUBE (deptno, job),
ROLLUP (deptno, job)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}, {1}, {}]], EXPR$2=[COUNT()])
LogicalProject(DEPTNO=[$7], JOB=[$2])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testGroupByExpression">
<Resource name="sql">
<![CDATA[select count(*)
from emp
group by substring(ename FROM 1 FOR 1)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[$1])
LogicalAggregate(group=[{0}], EXPR$0=[COUNT()])
LogicalProject($f0=[SUBSTRING($1, 1, 1)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testGroupByNestedColumn">
<Resource name="plan">
<![CDATA[
LogicalProject(X=[$1], A=[$0], EXPR$2=[$2])
LogicalAggregate(group=[{0, 1}], EXPR$2=[AVG($2)])
LogicalProject(A=[$5.SUB.A], X=[$4.X], $f2=[$4.Y])
LogicalTableScan(table=[[CATALOG, CUSTOMER, CONTACT_PEEK]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select
coord.x,
coord_ne.sub.a,
avg(coord.y)
from
customer.contact_peek
group by
coord_ne.sub.a,
coord.x]]>
</Resource>
</TestCase>
<TestCase name="testGroupByOrdinal">
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{0}])
LogicalProject(EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select empno from emp group by 1]]>
</Resource>
</TestCase>
<TestCase name="testGroupByWithDuplicates">
<Resource name="sql">
<![CDATA[select sum(sal) from emp group by (), ()]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{}], EXPR$0=[SUM($0)])
LogicalProject(SAL=[$5])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testGroupEmpty">
<Resource name="sql">
<![CDATA[select sum(deptno) from emp group by ()]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{}], EXPR$0=[SUM($0)])
LogicalProject(DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testGroupEmptyYieldLiteral">
<Resource name="sql">
<![CDATA[select 42 from emp group by ()]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[42])
LogicalAggregate(group=[{}])
LogicalProject($f0=[0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testGroupExpressionsInsideAndOut">
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[+($0, 4)], EXPR$1=[$1], EXPR$2=[$2], EXPR$3=[*(2, $3)])
LogicalAggregate(group=[{0}], EXPR$1=[SUM($1)], EXPR$2=[SUM($2)], agg#2=[COUNT()])
LogicalProject(DEPTNO=[$7], SAL=[$5], $f2=[+(3, $5)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select
deptno + 4, sum(sal), sum(3 + sal), 2 * count(sal)
from emp group by deptno]]>
</Resource>
</TestCase>
<TestCase name="testGroupJustOneAgg">
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{0}], SUM_SAL=[SUM($1)])
LogicalProject(DEPTNO=[$7], SAL=[$5])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select deptno, sum(sal) as sum_sal from emp group by deptno]]>
</Resource>
</TestCase>
<TestCase name="testGroupingFunction">
<Resource name="sql">
<![CDATA[select
deptno, grouping(deptno), count(*), grouping(empno)
from emp
group by rollup(empno, deptno)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$1], EXPR$1=[$2], EXPR$2=[$3], EXPR$3=[$4])
LogicalAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}, {}]], EXPR$1=[GROUPING($1)], EXPR$2=[COUNT()], EXPR$3=[GROUPING($0)])
LogicalProject(EMPNO=[$0], DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testGroupingFunctionWithGroupBy">
<Resource name="sql">
<![CDATA[select
deptno, grouping(deptno), count(*), grouping(empno)
from emp
group by empno, deptno
order by 2]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalSort(sort0=[$1], dir0=[ASC])
LogicalProject(DEPTNO=[$1], EXPR$1=[$2], EXPR$2=[$3], EXPR$3=[$4])
LogicalAggregate(group=[{0, 1}], EXPR$1=[GROUPING($1)], EXPR$2=[COUNT()], EXPR$3=[GROUPING($0)])
LogicalProject(EMPNO=[$0], DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testGroupingSets">
<Resource name="sql">
<![CDATA[select deptno, ename, sum(sal) from emp
group by grouping sets ((deptno), (ename, deptno))
order by 2]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalSort(sort0=[$1], dir0=[ASC])
LogicalAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}]], EXPR$2=[SUM($2)])
LogicalProject(DEPTNO=[$7], ENAME=[$1], SAL=[$5])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testGroupingSetsCartesianProduct">
<Resource name="sql">
<![CDATA[select 1
from (values (1, 2, 3, 4)) as t(a, b, c, d)
group by grouping sets (a, b), grouping sets (c, d)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[1])
LogicalAggregate(group=[{0, 1, 2, 3}], groups=[[{0, 2}, {0, 3}, {1, 2}, {1, 3}]])
LogicalValues(tuples=[[{ 1, 2, 3, 4 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testGroupingSetsCartesianProduct2">
<Resource name="sql">
<![CDATA[select 1
from (values (1, 2, 3, 4)) as t(a, b, c, d)
group by grouping sets (a, (a, b)), grouping sets (c), d]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[1])
LogicalAggregate(group=[{0, 1, 2, 3}], groups=[[{0, 1, 2, 3}, {0, 2, 3}]])
LogicalValues(tuples=[[{ 1, 2, 3, 4 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testGroupingSetsProduct">
<Resource name="sql">
<![CDATA[select 1
from (values (0, 1, 2, 3, 4)) as t(a, b, c, x, y)
group by grouping sets ((a, b), c), grouping sets ((x, y), ())]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[1])
LogicalAggregate(group=[{0, 1, 2, 3, 4}], groups=[[{0, 1, 3, 4}, {0, 1}, {2, 3, 4}, {2}]])
LogicalValues(tuples=[[{ 0, 1, 2, 3, 4 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testGroupingSetsRepeated">
<Resource name="sql">
<![CDATA[select deptno, group_id()
from emp
group by grouping sets (deptno, (), job, (deptno, job), deptno,
job, deptno)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], EXPR$1=[$2])
LogicalUnion(all=[true])
LogicalProject(DEPTNO=[$0], JOB=[$1], EXPR$1=[0:BIGINT])
LogicalAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}, {1}, {}]])
LogicalProject(DEPTNO=[$7], JOB=[$2])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalProject(DEPTNO=[$0], JOB=[$1], EXPR$1=[1:BIGINT])
LogicalAggregate(group=[{0, 1}], groups=[[{0}, {1}]])
LogicalProject(DEPTNO=[$7], JOB=[$2])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalProject(DEPTNO=[$0], JOB=[$1], EXPR$1=[2:BIGINT])
LogicalAggregate(group=[{0, 1}], groups=[[{0}]])
LogicalProject(DEPTNO=[$7], JOB=[$2])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testGroupingSetsRepeatedNoGroupId">
<Resource name="sql">
<![CDATA[select deptno, job
from emp
group by grouping sets (deptno, (), job, (deptno, job), deptno,
job, deptno)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalUnion(all=[true])
LogicalAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}, {1}, {}]])
LogicalProject(DEPTNO=[$7], JOB=[$2])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0, 1}], groups=[[{0}, {1}]])
LogicalProject(DEPTNO=[$7], JOB=[$2])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0, 1}], groups=[[{0}]])
LogicalProject(DEPTNO=[$7], JOB=[$2])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testGroupingSetsWith">
<Resource name="sql">
<![CDATA[with t(a, b, c, d) as (values (1, 2, 3, 4))
select 1 from t
group by rollup(a, b), rollup(c, d)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[1])
LogicalAggregate(group=[{0, 1, 2, 3}], groups=[[{0, 1, 2, 3}, {0, 1, 2}, {0, 1}, {0, 2, 3}, {0, 2}, {0}, {2, 3}, {2}, {}]])
LogicalValues(tuples=[[{ 1, 2, 3, 4 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testGroupingSetsWithCube">
<Resource name="sql">
<![CDATA[select deptno, ename, sum(sal) from emp
group by grouping sets ( (deptno), CUBE(ename, deptno))
order by 2]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalSort(sort0=[$1], dir0=[ASC])
LogicalUnion(all=[true])
LogicalAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}, {1}, {}]], EXPR$2=[SUM($2)])
LogicalProject(DEPTNO=[$7], ENAME=[$1], SAL=[$5])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0, 1}], groups=[[{0}]], EXPR$2=[SUM($2)])
LogicalProject(DEPTNO=[$7], ENAME=[$1], SAL=[$5])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testGroupingSetsWithGroupId">
<Resource name="sql">
<![CDATA[select deptno, group_id()
from emp
group by grouping sets (deptno, (), job)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], EXPR$1=[0:BIGINT])
LogicalAggregate(group=[{0, 1}], groups=[[{0}, {1}, {}]])
LogicalProject(DEPTNO=[$7], JOB=[$2])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testGroupingSetsWithNestedColumn">
<Resource name="plan">
<![CDATA[
LogicalProject(X=[$1], unit=[$2], A=[$0], EXPR$3=[$3])
LogicalAggregate(group=[{0, 1, 2}], groups=[[{0, 1, 2}, {1, 2}]], EXPR$3=[AVG($3)])
LogicalProject(A=[$5.SUB.A], X=[$4.X], unit=[$4.unit], $f3=[$4.Y])
LogicalTableScan(table=[[CATALOG, CUSTOMER, CONTACT_PEEK]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select
coord.x,
coord."unit",
coord_ne.sub.a,
avg(coord.y)
from
customer.contact_peek
group by
grouping sets (
(coord_ne.sub.a, coord.x, coord."unit"),
(coord.x, coord."unit")
)]]>
</Resource>
</TestCase>
<TestCase name="testGroupingSetsWithRollup">
<Resource name="sql">
<![CDATA[select deptno, ename, sum(sal) from emp
group by grouping sets ( rollup(deptno), (ename, deptno))
order by 2]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalSort(sort0=[$1], dir0=[ASC])
LogicalAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}, {}]], EXPR$2=[SUM($2)])
LogicalProject(DEPTNO=[$7], ENAME=[$1], SAL=[$5])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testGroupingSetsWithRollupCube">
<Resource name="sql">
<![CDATA[select deptno, ename, sum(sal) from emp
group by grouping sets ( CUBE(deptno), ROLLUP(ename, deptno))
order by 2]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalSort(sort0=[$1], dir0=[ASC])
LogicalUnion(all=[true])
LogicalAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}, {1}, {}]], EXPR$2=[SUM($2)])
LogicalProject(DEPTNO=[$7], ENAME=[$1], SAL=[$5])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0, 1}], groups=[[{}]], EXPR$2=[SUM($2)])
LogicalProject(DEPTNO=[$7], ENAME=[$1], SAL=[$5])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testGrpByColFromStarInSubQuery">
<Resource name="sql">
<![CDATA[SELECT n.n_nationkey AS col from (SELECT * FROM SALES.NATION) as n group by n.n_nationkey]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{0}])
LogicalProject(COL=[ITEM($0, 'N_NATIONKEY')])
LogicalTableScan(table=[[CATALOG, SALES, NATION]])
]]>
</Resource>
</TestCase>
<TestCase name="testHaving">
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[$0])
LogicalFilter(condition=[>($1, 10)])
LogicalAggregate(group=[{}], EXPR$0=[SUM($0)], agg#1=[SUM($1)])
LogicalProject($f0=[+($5, $5)], SAL=[$5])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select sum(sal + sal) from emp having sum(sal) > 10]]>
</Resource>
</TestCase>
<TestCase name="testHavingAggrFunctionIn">
<Resource name="sql">
<![CDATA[select deptno
from emp
group by deptno
having sum(case when deptno in (1, 2) then 0 else 1 end) +
sum(case when deptno in (3, 4) then 0 else 1 end) > 10]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0])
LogicalFilter(condition=[>(+($1, $2), 10)])
LogicalAggregate(group=[{0}], agg#0=[SUM($1)], agg#1=[SUM($2)])
LogicalProject(DEPTNO=[$7], $f1=[CASE(SEARCH($7, Sarg[1, 2]), 0, 1)], $f2=[CASE(SEARCH($7, Sarg[3, 4]), 0, 1)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testHavingInSubQueryWithAggrFunction">
<Resource name="sql">
<![CDATA[select sal
from emp
group by sal
having sal in (
select deptno
from dept
group by deptno
having sum(deptno) > 0)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(SAL=[$0])
LogicalJoin(condition=[=($0, $1)], joinType=[inner])
LogicalAggregate(group=[{0}])
LogicalProject(SAL=[$5])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0}])
LogicalProject(DEPTNO=[$0])
LogicalFilter(condition=[>($1, 0)])
LogicalAggregate(group=[{0}], agg#0=[SUM($0)])
LogicalProject(DEPTNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testHopTable">
<Resource name="sql">
<![CDATA[select stream hop_start(rowtime, interval '1' hour, interval '3' hour) as rowtime,
count(*) as c
from orders
group by hop(rowtime, interval '1' hour, interval '3' hour)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalDelta
LogicalProject(ROWTIME=[$0], C=[$1])
LogicalAggregate(group=[{0}], C=[COUNT()])
LogicalProject($f0=[$HOP($0, 3600000:INTERVAL HOUR, 10800000:INTERVAL HOUR)])
LogicalTableScan(table=[[CATALOG, SALES, ORDERS]])
]]>
</Resource>
</TestCase>
<TestCase name="testIdenticalExpressionInSubQuery">
<Resource name="sql">
<![CDATA[select deptno
from EMP
where deptno in (1, 2) or deptno in (1, 2)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$7])
LogicalFilter(condition=[OR(=($7, 1), =($7, 2), =($7, 1), =($7, 2))])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testImplicitJoinExpandAndDecorrelation">
<Resource name="planExpanded">
<![CDATA[
LogicalProject(DEPTNO=[$9], SAL=[$7])
LogicalProject(DEPTNO=[$0], NAME=[$1], EMPNO=[$2], ENAME=[$3], JOB=[$4], MGR=[$5], HIREDATE=[$6], SAL=[$7], COMM=[$8], DEPTNO0=[$9], SLACKER=[$10], DEPTNO1=[CAST($11):INTEGER], EXPR$0=[CAST($12):INTEGER])
LogicalJoin(condition=[AND(=($0, $11), <($7, $12))], joinType=[inner])
LogicalJoin(condition=[=($9, $0)], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0}], EXPR$0=[AVG($1)])
LogicalProject(DEPTNO=[$7], SAL=[$5])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="planNotExpanded">
<![CDATA[
LogicalProject(DEPTNO=[$9], SAL=[$7])
LogicalFilter(condition=[AND(=($9, $0), <($7, $SCALAR_QUERY({
LogicalAggregate(group=[{}], EXPR$0=[AVG($0)])
LogicalProject(SAL=[$5])
LogicalFilter(condition=[=($7, $cor0.DEPTNO)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
})))], variablesSet=[[$cor0]])
LogicalJoin(condition=[true], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[SELECT emp.deptno, emp.sal
FROM dept, emp WHERE emp.deptno = dept.deptno AND emp.sal < (
SELECT AVG(emp.sal)
FROM emp
WHERE emp.deptno = dept.deptno
)]]>
</Resource>
</TestCase>
<TestCase name="testInToSemiJoin">
<Resource name="sql">
<![CDATA[SELECT empno
FROM emp AS e
WHERE cast(e.empno as bigint) in (130, 131, 132, 133, 134)]]>
</Resource>
<Resource name="planNotConverted">
<![CDATA[
LogicalProject(EMPNO=[$0])
LogicalFilter(condition=[OR(=(CAST($0):BIGINT NOT NULL, 130), =(CAST($0):BIGINT NOT NULL, 131), =(CAST($0):BIGINT NOT NULL, 132), =(CAST($0):BIGINT NOT NULL, 133), =(CAST($0):BIGINT NOT NULL, 134))])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="planConverted">
<![CDATA[
LogicalProject(EMPNO=[$0])
LogicalJoin(condition=[=($9, $10)], joinType=[inner])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], EMPNO0=[CAST($0):BIGINT NOT NULL])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0}])
LogicalValues(tuples=[[{ 130 }, { 131 }, { 132 }, { 133 }, { 134 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testInToSemiJoinWithNewProject">
<Resource name="sql">
<![CDATA[SELECT * FROM (
SELECT '20210101' AS dt, deptno
FROM emp
GROUP BY deptno
) t
WHERE cast(deptno as varchar) in ('1')]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DT=[$0], DEPTNO=[$1])
LogicalJoin(condition=[=($2, $3)], joinType=[inner])
LogicalProject(DT=['20210101'], DEPTNO=[$0], DEPTNO0=[CAST($0):VARCHAR NOT NULL])
LogicalAggregate(group=[{0}])
LogicalProject(DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0}])
LogicalValues(tuples=[[{ '1' }]])
]]>
</Resource>
</TestCase>
<TestCase name="testInUncorrelatedSubQuery">
<Resource name="sql">
<![CDATA[select empno from emp where deptno in (select deptno from dept)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0])
LogicalJoin(condition=[=($7, $9)], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0}])
LogicalProject(DEPTNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testInUncorrelatedSubQueryInHavingRex">
<Resource name="sql">
<![CDATA[select sum(sal) as s
from emp
group by deptno
having count(*) > 2
and deptno in (
select case when true then deptno else null end from emp)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(S=[$1])
LogicalFilter(condition=[AND(>($2, 2), IN($0, {
LogicalProject(EXPR$0=[CAST($7):INTEGER])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
}))])
LogicalAggregate(group=[{0}], S=[SUM($1)], agg#1=[COUNT()])
LogicalProject(DEPTNO=[$7], SAL=[$5])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testInUncorrelatedSubQueryInSelect">
<Resource name="sql">
<![CDATA[select name, deptno in (
select case when true then deptno else null end from emp)
from dept]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(NAME=[$1], EXPR$1=[OR(AND(IS NOT NULL($6), <>($2, 0)), AND(<($3, $2), null, <>($2, 0), IS NULL($6)))])
LogicalJoin(condition=[=($4, $5)], joinType=[left])
LogicalProject(DEPTNO=[$0], NAME=[$1], $f0=[$2], $f1=[$3], DEPTNO0=[$0])
LogicalJoin(condition=[true], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
LogicalAggregate(group=[{}], agg#0=[COUNT()], agg#1=[COUNT($0)])
LogicalProject(EXPR$0=[CAST($7):INTEGER], $f1=[true])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0}], agg#0=[MIN($1)])
LogicalProject(EXPR$0=[CAST($7):INTEGER], $f1=[true])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testInUncorrelatedSubQueryInSelectRex">
<Resource name="sql">
<![CDATA[select name, deptno in (
select case when true then deptno else null end from emp)
from dept]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(NAME=[$1], EXPR$1=[IN($0, {
LogicalProject(EXPR$0=[CAST($7):INTEGER])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
})])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testInUncorrelatedSubQueryRex">
<Resource name="sql">
<![CDATA[select empno from emp where deptno in (select deptno from dept)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0])
LogicalFilter(condition=[IN($7, {
LogicalProject(DEPTNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
})])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testInValueListLong">
<Resource name="sql">
<![CDATA[select empno from emp where deptno in (10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0])
LogicalJoin(condition=[=($7, $9)], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0}])
LogicalValues(tuples=[[{ 10 }, { 20 }, { 30 }, { 40 }, { 50 }, { 60 }, { 70 }, { 80 }, { 90 }, { 100 }, { 110 }, { 120 }, { 130 }, { 140 }, { 150 }, { 160 }, { 170 }, { 180 }, { 190 }, { 200 }, { 210 }, { 220 }, { 230 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testInValueListShort">
<Resource name="sql">
<![CDATA[select empno from emp where deptno in (10, 20)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0])
LogicalFilter(condition=[OR(=($7, 10), =($7, 20))])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testInWithConstantList">
<Resource name="sql">
<![CDATA[1 in (1,2,3)]]>
</Resource>
<Resource name="plan">
<![CDATA[
OR(=(1, 1), =(1, 2), =(1, 3))
]]>
</Resource>
</TestCase>
<TestCase name="testInsert">
<Resource name="sql">
<![CDATA[insert into empnullables (deptno, empno, ename)
values (10, 150, 'Fred')]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMPNULLABLES]], operation=[INSERT], flattened=[true])
LogicalProject(EMPNO=[$1], ENAME=[$2], JOB=[null:VARCHAR(10)], MGR=[null:INTEGER], HIREDATE=[null:TIMESTAMP(0)], SAL=[null:INTEGER], COMM=[null:INTEGER], DEPTNO=[$0], SLACKER=[null:BOOLEAN])
LogicalValues(tuples=[[{ 10, 150, 'Fred' }]])
]]>
</Resource>
</TestCase>
<TestCase name="testInsertBind">
<Resource name="sql">
<![CDATA[insert into empnullables (deptno, empno, ename)
values (?, ?, ?)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMPNULLABLES]], operation=[INSERT], flattened=[true])
LogicalProject(EMPNO=[?1], ENAME=[?2], JOB=[null:VARCHAR(10)], MGR=[null:INTEGER], HIREDATE=[null:TIMESTAMP(0)], SAL=[null:INTEGER], COMM=[null:INTEGER], DEPTNO=[?0], SLACKER=[null:BOOLEAN])
LogicalValues(tuples=[[{ 0 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testInsertBindExtendedColumn">
<Resource name="sql">
<![CDATA[insert into empdefaults(updated TIMESTAMP)
(ename, deptno, empno, updated, sal)
values ('Fred', 456, 44, ?, 999999)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMPDEFAULTS]], operation=[INSERT], flattened=[true])
LogicalProject(EMPNO=[44], ENAME=['Fred'], JOB=[null:VARCHAR(10)], MGR=[null:INTEGER], HIREDATE=[null:TIMESTAMP(0)], SAL=[999999], COMM=[null:INTEGER], DEPTNO=[456], SLACKER=[null:BOOLEAN], UPDATED=[?0])
LogicalValues(tuples=[[{ 0 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testInsertBindExtendedColumnModifiableView">
<Resource name="sql">
<![CDATA[insert into EMP_MODIFIABLEVIEW2(updated TIMESTAMP)
(ename, deptno, empno, updated, sal)
values ('Fred', 20, 44, ?, 999999)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[SALES, EMPDEFAULTS]], operation=[INSERT], flattened=[true])
LogicalFilter(condition=[=($7, 20)])
LogicalProject(EMPNO=[44], ENAME=['Fred':VARCHAR(20)], JOB=[null:VARCHAR(10)], MGR=[null:INTEGER], HIREDATE=[null:TIMESTAMP(0)], SAL=[999999], COMM=[null:INTEGER], DEPTNO=[20], SLACKER=[null:BOOLEAN], EXTRA=[null:BOOLEAN], UPDATED=[?0])
LogicalValues(tuples=[[{ 0 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testInsertBindModifiableView">
<Resource name="sql">
<![CDATA[insert into EMP_MODIFIABLEVIEW (empno, job) values (?, ?)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[SALES, EMPDEFAULTS]], operation=[INSERT], flattened=[true])
LogicalProject(EMPNO=[CAST(?0):INTEGER NOT NULL], ENAME=['Bob':VARCHAR(20)], JOB=[?1], MGR=[null:INTEGER], HIREDATE=[null:TIMESTAMP(0)], SAL=[555], COMM=[null:INTEGER], DEPTNO=[20], SLACKER=[null:BOOLEAN])
LogicalValues(tuples=[[{ 0 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testInsertBindSubset">
<Resource name="sql">
<![CDATA[insert into empnullables
values (?, ?)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMPNULLABLES]], operation=[INSERT], flattened=[true])
LogicalProject(EMPNO=[?0], ENAME=[?1], JOB=[null:VARCHAR(10)], MGR=[null:INTEGER], HIREDATE=[null:TIMESTAMP(0)], SAL=[null:INTEGER], COMM=[null:INTEGER], DEPTNO=[null:INTEGER], SLACKER=[null:BOOLEAN])
LogicalValues(tuples=[[{ 0 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testInsertBindSubsetModifiableView">
<Resource name="sql">
<![CDATA[insert into EMP_MODIFIABLEVIEW values (?, ?)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[SALES, EMPDEFAULTS]], operation=[INSERT], flattened=[true])
LogicalProject(EMPNO=[CAST(?0):INTEGER NOT NULL], ENAME=[CAST(?1):VARCHAR(20) NOT NULL], JOB=[null:VARCHAR(10)], MGR=[null:INTEGER], HIREDATE=[null:TIMESTAMP(0)], SAL=[555], COMM=[null:INTEGER], DEPTNO=[20], SLACKER=[null:BOOLEAN])
LogicalValues(tuples=[[{ 0 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testInsertBindSubsetWithCustomInitializerExpressionFactory">
<Resource name="sql">
<![CDATA[insert into empdefaults values (?)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMPDEFAULTS]], operation=[INSERT], flattened=[true])
LogicalProject(EMPNO=[?0], ENAME=['Bob'], JOB=[null:VARCHAR(10)], MGR=[null:INTEGER], HIREDATE=[null:TIMESTAMP(0)], SAL=[555], COMM=[null:INTEGER], DEPTNO=[null:INTEGER], SLACKER=[null:BOOLEAN])
LogicalValues(tuples=[[{ 0 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testInsertBindWithCustomInitializerExpressionFactory">
<Resource name="sql">
<![CDATA[insert into empdefaults (deptno) values (?)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMPDEFAULTS]], operation=[INSERT], flattened=[true])
LogicalProject(EMPNO=[123], ENAME=['Bob'], JOB=[null:VARCHAR(10)], MGR=[null:INTEGER], HIREDATE=[null:TIMESTAMP(0)], SAL=[555], COMM=[null:INTEGER], DEPTNO=[?0], SLACKER=[null:BOOLEAN])
LogicalValues(tuples=[[{ 0 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testInsertExtendedColumn">
<Resource name="sql">
<![CDATA[insert into empdefaults(updated TIMESTAMP)
(ename, deptno, empno, updated, sal)
values ('Fred', 456, 44, timestamp '2017-03-12 13:03:05', 999999)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMPDEFAULTS]], operation=[INSERT], flattened=[true])
LogicalProject(EMPNO=[$2], ENAME=[$0], JOB=[null:VARCHAR(10)], MGR=[null:INTEGER], HIREDATE=[null:TIMESTAMP(0)], SAL=[$4], COMM=[null:INTEGER], DEPTNO=[$1], SLACKER=[null:BOOLEAN], UPDATED=[$3])
LogicalValues(tuples=[[{ 'Fred', 456, 44, 2017-03-12 13:03:05, 999999 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testInsertExtendedColumnModifiableView">
<Resource name="sql">
<![CDATA[insert into EMP_MODIFIABLEVIEW2(updated TIMESTAMP)
(ename, deptno, empno, updated, sal)
values ('Fred', 20, 44, timestamp '2017-03-12 13:03:05', 999999)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[SALES, EMPDEFAULTS]], operation=[INSERT], flattened=[true])
LogicalFilter(condition=[=($7, 20)])
LogicalProject(EMPNO=[$2], ENAME=[$0], JOB=[null:VARCHAR(10)], MGR=[null:INTEGER], HIREDATE=[null:TIMESTAMP(0)], SAL=[CAST($4):INTEGER], COMM=[null:INTEGER], DEPTNO=[CAST($1):INTEGER], SLACKER=[null:BOOLEAN], EXTRA=[null:BOOLEAN], UPDATED=[CAST($3):TIMESTAMP(0)])
LogicalValues(tuples=[[{ 'Fred', 20, 44, 2017-03-12 13:03:05, 999999 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testInsertModifiableView">
<Resource name="sql">
<![CDATA[insert into EMP_MODIFIABLEVIEW (EMPNO, ENAME, JOB) values (34625, 'nom', 'accountant')]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[SALES, EMPDEFAULTS]], operation=[INSERT], flattened=[true])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[CAST($2):VARCHAR(10)], MGR=[null:INTEGER], HIREDATE=[null:TIMESTAMP(0)], SAL=[555], COMM=[null:INTEGER], DEPTNO=[20], SLACKER=[null:BOOLEAN])
LogicalValues(tuples=[[{ 34625, 'nom', 'accountant' }]])
]]>
</Resource>
</TestCase>
<TestCase name="testInsertSubset">
<Resource name="sql">
<![CDATA[insert into empnullables
values (50, 'Fred')]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMPNULLABLES]], operation=[INSERT], flattened=[true])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[null:VARCHAR(10)], MGR=[null:INTEGER], HIREDATE=[null:TIMESTAMP(0)], SAL=[null:INTEGER], COMM=[null:INTEGER], DEPTNO=[null:INTEGER], SLACKER=[null:BOOLEAN])
LogicalValues(tuples=[[{ 50, 'Fred' }]])
]]>
</Resource>
</TestCase>
<TestCase name="testInsertSubsetModifiableView">
<Resource name="sql">
<![CDATA[insert into EMP_MODIFIABLEVIEW values (10, 'Fred')]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[SALES, EMPDEFAULTS]], operation=[INSERT], flattened=[true])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[null:VARCHAR(10)], MGR=[null:INTEGER], HIREDATE=[null:TIMESTAMP(0)], SAL=[555], COMM=[null:INTEGER], DEPTNO=[20], SLACKER=[null:BOOLEAN])
LogicalValues(tuples=[[{ 10, 'Fred' }]])
]]>
</Resource>
</TestCase>
<TestCase name="testInsertSubsetView">
<Resource name="sql">
<![CDATA[insert into empnullables_20
values (10, 'Fred')]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMPNULLABLES]], operation=[INSERT], flattened=[true])
LogicalFilter(condition=[>($5, 1000)])
LogicalProject(EMPNO=[$0], ENAME=[CAST($1):VARCHAR(20)], JOB=[null:VARCHAR(10)], MGR=[null:INTEGER], HIREDATE=[null:TIMESTAMP(0)], SAL=[null:INTEGER], COMM=[null:INTEGER], DEPTNO=[20], SLACKER=[null:BOOLEAN])
LogicalValues(tuples=[[{ 10, 'Fred' }]])
]]>
</Resource>
</TestCase>
<TestCase name="testInsertSubsetWithCustomInitializerExpressionFactory">
<Resource name="sql">
<![CDATA[insert into empdefaults values (100)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMPDEFAULTS]], operation=[INSERT], flattened=[true])
LogicalProject(EMPNO=[$0], ENAME=['Bob'], JOB=[null:VARCHAR(10)], MGR=[null:INTEGER], HIREDATE=[null:TIMESTAMP(0)], SAL=[555], COMM=[null:INTEGER], DEPTNO=[null:INTEGER], SLACKER=[null:BOOLEAN])
LogicalValues(tuples=[[{ 100 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testInsertView">
<Resource name="sql">
<![CDATA[insert into empnullables_20 (empno, ename)
values (150, 'Fred')]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMPNULLABLES]], operation=[INSERT], flattened=[true])
LogicalFilter(condition=[>($5, 1000)])
LogicalProject(EMPNO=[$0], ENAME=[CAST($1):VARCHAR(20)], JOB=[null:VARCHAR(10)], MGR=[null:INTEGER], HIREDATE=[null:TIMESTAMP(0)], SAL=[null:INTEGER], COMM=[null:INTEGER], DEPTNO=[20], SLACKER=[null:BOOLEAN])
LogicalValues(tuples=[[{ 150, 'Fred' }]])
]]>
</Resource>
</TestCase>
<TestCase name="testInsertViewWithCustomColumnResolving">
<Resource name="sql">
<![CDATA[insert into struct.t_10 (f0.c0, f1.c2, c1, k0,
f1.a0, f2.a0, f0.c1, f2.c3)
values (?, ?, ?, ?, ?, ?, ?, ?)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, STRUCT, T]], operation=[INSERT], flattened=[true])
LogicalFilter(condition=[=($4, 10)])
LogicalProject("K0"=[CAST(?3):VARCHAR(20) NOT NULL], "C1"=[CAST(?2):VARCHAR(20) NOT NULL], "F1"."A0"=[CAST(?4):INTEGER NOT NULL], "F2"."A0"=[CAST(?5):BOOLEAN NOT NULL], "F0"."C0"=[CAST(?0):INTEGER NOT NULL], "F1"."C0"=[null:INTEGER], "F0"."C1"=[CAST(?6):INTEGER NOT NULL], "F1"."C2"=[CAST(?1):INTEGER NOT NULL], "F2"."C3"=[CAST(?7):INTEGER NOT NULL])
LogicalValues(tuples=[[{ 0 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testInsertWithCustomColumnResolving">
<Resource name="sql">
<![CDATA[insert into struct.t values (?, ?, ?, ?, ?, ?, ?, ?, ?)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, STRUCT, T]], operation=[INSERT], flattened=[true])
LogicalProject("K0"=[?0], "C1"=[?1], "F1"."A0"=[?2], "F2"."A0"=[?3], "F0"."C0"=[?4], "F1"."C0"=[?5], "F0"."C1"=[?6], "F1"."C2"=[?7], "F2"."C3"=[?8])
LogicalValues(tuples=[[{ 0 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testInsertWithCustomColumnResolving2">
<Resource name="sql">
<![CDATA[insert into struct.t_nullables (f0.c0, f1.c2, c1)
values (?, ?, ?)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, STRUCT, T_NULLABLES]], operation=[INSERT], flattened=[true])
LogicalProject("K0"=[null:VARCHAR(20)], "C1"=[?2], "F1"."A0"=[null:INTEGER], "F2"."A0"=[null:BOOLEAN], "F0"."C0"=[?0], "F1"."C0"=[null:INTEGER], "F0"."C1"=[null:INTEGER], "F1"."C2"=[?1], "F2"."C3"=[null:INTEGER])
LogicalValues(tuples=[[{ 0 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testInsertWithCustomInitializerExpressionFactory">
<Resource name="sql">
<![CDATA[insert into empdefaults (deptno) values (300)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMPDEFAULTS]], operation=[INSERT], flattened=[true])
LogicalProject(EMPNO=[123], ENAME=['Bob'], JOB=[null:VARCHAR(10)], MGR=[null:INTEGER], HIREDATE=[null:TIMESTAMP(0)], SAL=[555], COMM=[null:INTEGER], DEPTNO=[$0], SLACKER=[null:BOOLEAN])
LogicalValues(tuples=[[{ 300 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testInsertWithLimit">
<Resource name="sql">
<![CDATA[insert into empnullables (empno, ename)
select deptno, ename from emp order by ename limit 10]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMPNULLABLES]], operation=[INSERT], flattened=[true])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[null:VARCHAR(10)], MGR=[null:INTEGER], HIREDATE=[null:TIMESTAMP(0)], SAL=[null:INTEGER], COMM=[null:INTEGER], DEPTNO=[null:INTEGER], SLACKER=[null:BOOLEAN])
LogicalSort(sort0=[$1], dir0=[ASC], fetch=[10])
LogicalProject(DEPTNO=[$7], ENAME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testInsertWithSort">
<Resource name="sql">
<![CDATA[insert into empnullables (empno, ename)
select deptno, ename from emp order by ename]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMPNULLABLES]], operation=[INSERT], flattened=[true])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[null:VARCHAR(10)], MGR=[null:INTEGER], HIREDATE=[null:TIMESTAMP(0)], SAL=[null:INTEGER], COMM=[null:INTEGER], DEPTNO=[null:INTEGER], SLACKER=[null:BOOLEAN])
LogicalSort(sort0=[$1], dir0=[ASC])
LogicalProject(DEPTNO=[$7], ENAME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testIntegerLiteral">
<Resource name="sql">
<![CDATA[select 1 from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[1])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testInterval">
<Resource name="sql">
<![CDATA[values(cast(interval '1' hour as interval hour to second))]]>
</Resource>
<Resource name="plan">
<![CDATA[
ProjectRel(EXPR$0=[$0])
ProjectRel(EXPR$0=[3600000])
OneRowRel
]]>
</Resource>
</TestCase>
<TestCase name="testIntervalExpression">
<Resource name="sql">
<![CDATA[select interval mgr hour as h from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(H=[*($3, 3600000:INTERVAL HOUR)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testIntervalLiteralHourToMinute">
<Resource name="sql">
<![CDATA[select
cast(empno as Integer) * (INTERVAL '1:1' HOUR TO MINUTE)
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[*($0, 3660000:INTERVAL HOUR TO MINUTE)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testIntervalLiteralYearToMonth">
<Resource name="sql">
<![CDATA[select
cast(empno as Integer) * (INTERVAL '1-1' YEAR TO MONTH)
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[*($0, 13:INTERVAL YEAR TO MONTH)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testIsDistinctFrom">
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[AND(OR(IS NOT NULL($0), IS NOT NULL($1)), IS NOT TRUE(=($0, $1)))])
LogicalValues(tuples=[[{ null, 1 }, { 2, null }]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select empno is distinct from deptno
from (values (cast(null as int), 1),
(2, cast(null as int))) as emp(empno, deptno)]]>
</Resource>
</TestCase>
<TestCase name="testIsNotDistinctFrom">
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[OR(AND(IS NULL($0), IS NULL($1)), IS TRUE(=($0, $1)))])
LogicalValues(tuples=[[{ null, 1 }, { 2, null }]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select empno is not distinct from deptno
from (values (cast(null as int), 1),
(2, cast(null as int))) as emp(empno, deptno)]]>
</Resource>
</TestCase>
<TestCase name="testJoinExpandAndDecorrelation">
<Resource name="planExpanded">
<![CDATA[
LogicalProject(DEPTNO=[$9], SAL=[$7])
LogicalJoin(condition=[AND(=($9, $0), <($7, $0))], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], EXPR$0=[$10])
LogicalJoin(condition=[=($0, $9)], joinType=[left])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0}], EXPR$0=[AVG($1)])
LogicalProject(DEPTNO=[$7], SAL=[$5])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="planNotExpanded">
<![CDATA[
LogicalProject(DEPTNO=[$9], SAL=[$7])
LogicalJoin(condition=[AND(=($9, $0), <($7, $SCALAR_QUERY({
LogicalAggregate(group=[{}], EXPR$0=[AVG($0)])
LogicalProject(SAL=[$5])
LogicalFilter(condition=[=($7, $cor0.DEPTNO)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
})))], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[SELECT emp.deptno, emp.sal
FROM dept
JOIN emp ON emp.deptno = dept.deptno AND emp.sal < (
SELECT AVG(emp.sal)
FROM emp
WHERE emp.deptno = dept.deptno
)]]>
</Resource>
</TestCase>
<TestCase name="testJoinLateralTableWithConditionCorrelated">
<Resource name="sql">
<![CDATA[select deptno, r.num from dept join
lateral table(ramp(dept.deptno)) as r(num)
on deptno=num]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], NUM=[$2])
LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{0}])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
LogicalFilter(condition=[=($cor0.DEPTNO, $0)])
LogicalTableFunctionScan(invocation=[RAMP($cor0.DEPTNO)], rowType=[RecordType(INTEGER I)])
]]>
</Resource>
</TestCase>
<TestCase name="testJoinNatural">
<Resource name="sql">
<![CDATA[SELECT * FROM emp NATURAL JOIN dept]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$7], EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], SLACKER=[$8], NAME=[$10])
LogicalJoin(condition=[=($7, $9)], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testJoinNaturalMultipleCommonColumn">
<Resource name="sql">
<![CDATA[SELECT *
FROM emp
NATURAL JOIN (SELECT deptno, name AS ename FROM dept) AS d]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ENAME=[$1], DEPTNO=[$7], EMPNO=[$0], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], SLACKER=[$8])
LogicalJoin(condition=[AND(=($1, $10), =($7, $9))], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalProject(DEPTNO=[$0], ENAME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testJoinNaturalNoCommonColumn">
<Resource name="sql">
<![CDATA[SELECT *
FROM emp NATURAL JOIN (SELECT deptno AS foo, name FROM dept) AS d]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], FOO=[$9], NAME=[$10])
LogicalJoin(condition=[true], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalProject(FOO=[$0], NAME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testJoinOn">
<Resource name="sql">
<![CDATA[SELECT * FROM emp
JOIN dept on emp.deptno = dept.deptno]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO0=[$9], NAME=[$10])
LogicalJoin(condition=[=($7, $9)], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testJoinOnExists">
<Resource name="sql">
<![CDATA[select * from emp left join dept
on emp.empno = 1
or exists (select deptno from emp where empno > dept.deptno + 5)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO0=[$9], NAME=[$10])
LogicalJoin(condition=[OR(=($0, 1), EXISTS({
LogicalFilter(condition=[>($0, +($cor0.DEPTNO0, 5))])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
}))], joinType=[left])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testJoinOnExpression">
<Resource name="sql">
<![CDATA[SELECT * FROM emp
JOIN dept on emp.deptno + 1 = dept.deptno - 2]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO0=[$10], NAME=[$11])
LogicalJoin(condition=[=($9, $12)], joinType=[inner])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], $f9=[+($7, 1)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalProject(DEPTNO=[$0], NAME=[$1], $f2=[-($0, 2)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testJoinOnIn">
<Resource name="sql">
<![CDATA[select * from emp join dept
on emp.deptno = dept.deptno and emp.empno in (1, 3)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO0=[$9], NAME=[$10])
LogicalJoin(condition=[AND(=($7, $9), SEARCH($0, Sarg[1, 3]))], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testJoinOnInSubQuery">
<Resource name="sql">
<![CDATA[select * from emp left join dept
on emp.empno = 1
or dept.deptno in (select deptno from emp where empno > 5)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO0=[$9], NAME=[$10])
LogicalJoin(condition=[OR(=($0, 1), IN($9, {
LogicalProject(DEPTNO=[$7])
LogicalFilter(condition=[>($0, 5)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
}))], joinType=[left])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testJoinTemporalTableOnColumnReference1">
<Resource name="sql">
<![CDATA[select stream *
from orders
join products_temporal for system_time as of orders.rowtime
on orders.productid = products_temporal.productid]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalDelta
LogicalProject(ROWTIME=[$0], PRODUCTID=[$1], ORDERID=[$2], PRODUCTID0=[$3], NAME=[$4], SUPPLIERID=[$5], SYS_START=[$6], SYS_END=[$7], SYS_START_LOCAL_TIMESTAMP=[$8], SYS_END_LOCAL_TIMESTAMP=[$9])
LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{0, 1}])
LogicalTableScan(table=[[CATALOG, SALES, ORDERS]])
LogicalFilter(condition=[=($cor0.PRODUCTID, $0)])
LogicalSnapshot(period=[$cor0.ROWTIME])
LogicalTableScan(table=[[CATALOG, SALES, PRODUCTS_TEMPORAL]])
]]>
</Resource>
</TestCase>
<TestCase name="testJoinTemporalTableOnColumnReference2">
<Resource name="sql">
<![CDATA[select stream *
from orders
join VIRTUALCOLUMNS.VC_T1 for system_time as of orders.rowtime
on orders.productid = VIRTUALCOLUMNS.VC_T1.a]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalDelta
LogicalProject(ROWTIME=[$0], PRODUCTID=[$1], ORDERID=[$2], A=[$3], B=[$4], C=[$5], D=[$6], E=[$7])
LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{0, 1}])
LogicalTableScan(table=[[CATALOG, SALES, ORDERS]])
LogicalFilter(condition=[=($cor0.PRODUCTID, $0)])
LogicalSnapshot(period=[$cor0.ROWTIME])
LogicalProject(A=[$0], B=[$1], C=[$2], D=[$3], $f4=[+($0, 1)])
LogicalTableScan(table=[[CATALOG, VIRTUALCOLUMNS, VC_T1]])
]]>
</Resource>
</TestCase>
<TestCase name="testJoinTemporalTableOnSpecificTime1">
<Resource name="sql">
<![CDATA[select stream *
from orders,
products_temporal for system_time as of
TIMESTAMP '2011-01-02 00:00:00']]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalDelta
LogicalProject(ROWTIME=[$0], PRODUCTID=[$1], ORDERID=[$2], PRODUCTID0=[$3], NAME=[$4], SUPPLIERID=[$5], SYS_START=[$6], SYS_END=[$7], SYS_START_LOCAL_TIMESTAMP=[$8], SYS_END_LOCAL_TIMESTAMP=[$9])
LogicalJoin(condition=[true], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, ORDERS]])
LogicalSnapshot(period=[2011-01-02 00:00:00])
LogicalTableScan(table=[[CATALOG, SALES, PRODUCTS_TEMPORAL]])
]]>
</Resource>
</TestCase>
<TestCase name="testJoinTemporalTableOnSpecificTime2">
<Resource name="sql">
<![CDATA[select stream *
from orders,
VIRTUALCOLUMNS.VC_T1 for system_time as of
TIMESTAMP '2011-01-02 00:00:00']]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalDelta
LogicalProject(ROWTIME=[$0], PRODUCTID=[$1], ORDERID=[$2], A=[$3], B=[$4], C=[$5], D=[$6], E=[$7])
LogicalJoin(condition=[true], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, ORDERS]])
LogicalSnapshot(period=[2011-01-02 00:00:00])
LogicalProject(A=[$0], B=[$1], C=[$2], D=[$3], $f4=[+($0, 1)])
LogicalTableScan(table=[[CATALOG, VIRTUALCOLUMNS, VC_T1]])
]]>
</Resource>
</TestCase>
<TestCase name="testJoinTemporalTableOnSpecificTimestampWithLocalTimeZone">
<Resource name="sql">
<![CDATA[select stream *
from orders,
products_temporal for system_time as of
TIMESTAMP WITH LOCAL TIME ZONE '2011-01-02 00:00:00']]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalDelta
LogicalProject(ROWTIME=[$0], PRODUCTID=[$1], ORDERID=[$2], PRODUCTID0=[$3], NAME=[$4], SUPPLIERID=[$5], SYS_START=[$6], SYS_END=[$7], SYS_START_LOCAL_TIMESTAMP=[$8], SYS_END_LOCAL_TIMESTAMP=[$9])
LogicalJoin(condition=[true], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, ORDERS]])
LogicalSnapshot(period=[2011-01-02 00:00:00:TIMESTAMP_WITH_LOCAL_TIME_ZONE(0)])
LogicalTableScan(table=[[CATALOG, SALES, PRODUCTS_TEMPORAL]])
]]>
</Resource>
</TestCase>
<TestCase name="testJoinUnnest">
<Resource name="sql">
<![CDATA[select*from dept as d, unnest(multiset[d.deptno * 2])]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], NAME=[$1], EXPR$0=[$2])
LogicalProject(DEPTNO=[$0], NAME=[$1], EXPR$0=[$3])
LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{2}])
LogicalProject(DEPTNO=[$0], NAME=[$1], $f2=[*($0, 2)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
Uncollect
LogicalProject(EXPR$0=[$SLICE($0)])
Collect(field=[EXPR$0])
LogicalUnion(all=[true])
LogicalProject(EXPR$0=[$cor0.$f2])
LogicalValues(tuples=[[{ 0 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testJoinUnnestRex">
<Resource name="sql">
<![CDATA[select*from dept as d, unnest(multiset[d.deptno * 2])]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], NAME=[$1], EXPR$0=[$2])
LogicalProject(DEPTNO=[$0], NAME=[$1], EXPR$0=[$3])
LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{2}])
LogicalProject(DEPTNO=[$0], NAME=[$1], $f2=[*($0, 2)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
Uncollect
LogicalProject(EXPR$0=[$SLICE($0)])
Collect(field=[EXPR$0])
LogicalUnion(all=[true])
LogicalProject(EXPR$0=[$cor0.$f2])
LogicalValues(tuples=[[{ 0 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testJoinUsing">
<Resource name="sql">
<![CDATA[SELECT * FROM emp JOIN dept USING (deptno)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$7], EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], SLACKER=[$8], NAME=[$10])
LogicalJoin(condition=[=($7, $9)], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testJoinUsingCompound">
<Resource name="sql">
<![CDATA[SELECT * FROM emp LEFT JOIN (SELECT *, deptno * 5 as empno FROM dept) USING (deptno,empno)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$7], EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], SLACKER=[$8], NAME=[$10])
LogicalJoin(condition=[AND(=($7, $9), =($0, $11))], joinType=[left])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalProject(DEPTNO=[$0], NAME=[$1], EMPNO=[*($0, 5)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testJoinUsingDynamicTable">
<Resource name="sql">
<![CDATA[select * from SALES.NATION t1
join SALES.NATION t2
using (n_nationkey)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(**=[$1], **0=[$3])
LogicalJoin(condition=[=($0, $2)], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, NATION]])
LogicalTableScan(table=[[CATALOG, SALES, NATION]])
]]>
</Resource>
</TestCase>
<TestCase name="testJoinUsingThreeWay">
<Resource name="sql">
<![CDATA[select *
from emp as e
join dept as d using (deptno)
join emp as e2 using (empno)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], DEPTNO=[$7], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], SLACKER=[$8], NAME=[$10], ENAME0=[$12], JOB0=[$13], MGR0=[$14], HIREDATE0=[$15], SAL0=[$16], COMM0=[$17], DEPTNO1=[$18], SLACKER0=[$19])
LogicalJoin(condition=[=($0, $11)], joinType=[inner])
LogicalJoin(condition=[=($7, $9)], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testJoinUsingWithAggregate">
<Resource name="sql">
<![CDATA[select deptno, count(*)
from emp
full join dept using (deptno)
group by deptno]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], EXPR$1=[$1])
LogicalAggregate(group=[{0}], EXPR$1=[COUNT()])
LogicalProject($f0=[COALESCE($7, $9)])
LogicalJoin(condition=[=($7, $9)], joinType=[full])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testJoinUsingWithGroupingSets">
<Resource name="sql">
<![CDATA[select deptno, grouping(deptno),
grouping(deptno, job), count(*)
from emp
join dept using (deptno)
group by grouping sets ((deptno), (deptno, job))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], EXPR$1=[$2], EXPR$2=[$3], EXPR$3=[$4])
LogicalAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}]], EXPR$1=[GROUPING($0)], EXPR$2=[GROUPING($0, $1)], EXPR$3=[COUNT()])
LogicalProject($f0=[$7], JOB=[$2])
LogicalJoin(condition=[=($7, $9)], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testJoinUsingWithMultipleJoin">
<Resource name="sql">
<![CDATA[SELECT deptno, ename
FROM emp JOIN dept using (deptno)
JOIN (values ('Calcite', 200)) as s(ename, salary) using (ename)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$7], ENAME=[$1])
LogicalJoin(condition=[=($1, $11)], joinType=[inner])
LogicalJoin(condition=[=($7, $9)], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
LogicalValues(tuples=[[{ 'Calcite', 200 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testJoinUsingWithUnqualifiedCommonColumn">
<Resource name="sql">
<![CDATA[SELECT deptno, name
FROM emp JOIN dept using (deptno)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$7], NAME=[$10])
LogicalJoin(condition=[=($7, $9)], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testJoinUsingWithUnqualifiedNestedCommonColumn">
<Resource name="sql">
<![CDATA[select (coord).x from
customer.contact_peek t1
join customer.contact_peek t2
using (coord)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[COALESCE(ROW($4, $5, $6), ROW($14, $15, $16)).X])
LogicalJoin(condition=[AND(AND(=($4, $14), =($5, $15)), =($6, $16))], joinType=[inner])
LogicalProject(CONTACTNO=[$0], FNAME=[$1], LNAME=[$2], EMAIL=[$3], X=[$4.X], Y=[$4.Y], unit=[$4.unit], M=[$5.M], A=[$5.SUB.A], B=[$5.SUB.B])
LogicalTableScan(table=[[CATALOG, CUSTOMER, CONTACT_PEEK]])
LogicalProject(CONTACTNO=[$0], FNAME=[$1], LNAME=[$2], EMAIL=[$3], X=[$4.X], Y=[$4.Y], unit=[$4.unit], M=[$5.M], A=[$5.SUB.A], B=[$5.SUB.B])
LogicalTableScan(table=[[CATALOG, CUSTOMER, CONTACT_PEEK]])
]]>
</Resource>
</TestCase>
<TestCase name="testJoinWithOnConditionQuery">
<Resource name="sql">
<![CDATA[SELECT emp.deptno, emp.sal
FROM dept
JOIN emp
ON (SELECT AVG(emp.sal) > 0 FROM emp)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$9], SAL=[$7])
LogicalJoin(condition=[$11], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
LogicalJoin(condition=[true], joinType=[left])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{}], agg#0=[SINGLE_VALUE($0)])
LogicalProject(EXPR$0=[>($0, 0)])
LogicalAggregate(group=[{}], agg#0=[AVG($0)])
LogicalProject(SAL=[$5])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testJoinWithUnion">
<Resource name="sql">
<![CDATA[select grade
from (select empno from emp union select deptno from dept),
salgrade]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(GRADE=[$1])
LogicalJoin(condition=[true], joinType=[inner])
LogicalUnion(all=[false])
LogicalProject(EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalProject(DEPTNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
LogicalTableScan(table=[[CATALOG, SALES, SALGRADE]])
]]>
</Resource>
</TestCase>
<TestCase name="testJsonArray">
<Resource name="sql">
<![CDATA[select json_array(ename, ename)
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[JSON_ARRAY(FLAG(ABSENT_ON_NULL), $1, $1)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testJsonArrayAgg1">
<Resource name="sql">
<![CDATA[select json_arrayagg(ename)
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{}], EXPR$0=[JSON_ARRAYAGG_ABSENT_ON_NULL($0)])
LogicalProject(ENAME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testJsonArrayAgg2">
<Resource name="sql">
<![CDATA[select json_arrayagg(ename order by ename)
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{}], EXPR$0=[JSON_ARRAYAGG_ABSENT_ON_NULL($0) WITHIN GROUP ([0])])
LogicalProject(ENAME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testJsonArrayAgg3">
<Resource name="sql">
<![CDATA[select json_arrayagg(ename order by ename null on null)
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{}], EXPR$0=[JSON_ARRAYAGG_NULL_ON_NULL($0) WITHIN GROUP ([0])])
LogicalProject(ENAME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testJsonArrayAgg4">
<Resource name="sql">
<![CDATA[select json_arrayagg(ename null on null) within group (order by ename)
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{}], EXPR$0=[JSON_ARRAYAGG_NULL_ON_NULL($0) WITHIN GROUP ([0])])
LogicalProject(ENAME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testJsonDepth">
<Resource name="sql">
<![CDATA[select json_depth(ename)
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[JSON_DEPTH($1)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testJsonExists">
<Resource name="sql">
<![CDATA[select json_exists(ename, 'lax $')
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[JSON_EXISTS($1, 'lax $')])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testJsonKeys">
<Resource name="sql">
<![CDATA[select json_keys(ename, 'strict $')
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[JSON_KEYS($1, 'strict $')])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testJsonLength">
<Resource name="sql">
<![CDATA[select json_length(ename, 'strict $')
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[JSON_LENGTH($1, 'strict $')])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testJsonNestedJsonArrayAggConstructor">
<Resource name="sql">
<![CDATA[select
json_object(
'k2' :
json_arrayagg(
json_object(
ename :
deptno)))
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[JSON_OBJECT(FLAG(NULL_ON_NULL), 'k2', JSON_TYPE($0))])
LogicalAggregate(group=[{}], agg#0=[JSON_ARRAYAGG_ABSENT_ON_NULL($0)])
LogicalProject($f0=[JSON_TYPE(JSON_OBJECT(FLAG(NULL_ON_NULL), $1, $7))])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testJsonNestedJsonArrayConstructor">
<Resource name="sql">
<![CDATA[select
json_array(
json_object(
'key1' :
json_object(
'key2' :
ename)),
json_array(12, 'hello', deptno))
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[JSON_ARRAY(FLAG(ABSENT_ON_NULL), JSON_TYPE(JSON_OBJECT(FLAG(NULL_ON_NULL), 'key1', JSON_TYPE(JSON_OBJECT(FLAG(NULL_ON_NULL), 'key2', $1)))), JSON_TYPE(JSON_ARRAY(FLAG(ABSENT_ON_NULL), 12, 'hello', $7)))])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testJsonNestedJsonObjectAggConstructor">
<Resource name="sql">
<![CDATA[select
json_object(
'k2' :
json_objectagg(
ename :
json_object(
'k1' :
deptno)))
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[JSON_OBJECT(FLAG(NULL_ON_NULL), 'k2', JSON_TYPE($0))])
LogicalAggregate(group=[{}], agg#0=[JSON_OBJECTAGG_NULL_ON_NULL($0, $1)])
LogicalProject(ENAME=[$1], $f1=[JSON_TYPE(JSON_OBJECT(FLAG(NULL_ON_NULL), 'k1', $7))])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testJsonNestedJsonObjectConstructor">
<Resource name="sql">
<![CDATA[select
json_object(
'key1' :
json_object(
'key2' :
ename)),
json_object(
'key3' :
json_array(12, 'hello', deptno))
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[JSON_OBJECT(FLAG(NULL_ON_NULL), 'key1', JSON_TYPE(JSON_OBJECT(FLAG(NULL_ON_NULL), 'key2', $1)))], EXPR$1=[JSON_OBJECT(FLAG(NULL_ON_NULL), 'key3', JSON_TYPE(JSON_ARRAY(FLAG(ABSENT_ON_NULL), 12, 'hello', $7)))])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testJsonObject">
<Resource name="sql">
<![CDATA[select json_object(ename: deptno, ename: deptno)
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[JSON_OBJECT(FLAG(NULL_ON_NULL), $1, $7, $1, $7)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testJsonObjectAgg">
<Resource name="sql">
<![CDATA[select json_objectagg(ename: deptno)
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{}], EXPR$0=[JSON_OBJECTAGG_NULL_ON_NULL($0, $1)])
LogicalProject(ENAME=[$1], DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testJsonPredicate">
<Resource name="sql">
<![CDATA[select
ename is json,
ename is json value,
ename is json object,
ename is json array,
ename is json scalar,
ename is not json,
ename is not json value,
ename is not json object,
ename is not json array,
ename is not json scalar
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[IS JSON VALUE($1)], EXPR$1=[IS JSON VALUE($1)], EXPR$2=[IS JSON OBJECT($1)], EXPR$3=[IS JSON ARRAY($1)], EXPR$4=[IS JSON SCALAR($1)], EXPR$5=[IS NOT JSON VALUE($1)], EXPR$6=[IS NOT JSON VALUE($1)], EXPR$7=[IS NOT JSON OBJECT($1)], EXPR$8=[IS NOT JSON ARRAY($1)], EXPR$9=[IS NOT JSON SCALAR($1)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testJsonPretty">
<Resource name="sql">
<![CDATA[select json_pretty(ename)
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[JSON_PRETTY($1)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testJsonQuery">
<Resource name="sql">
<![CDATA[select json_query(ename, 'lax $')
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[JSON_QUERY($1, 'lax $', FLAG(WITHOUT_ARRAY), FLAG(SqlJsonQueryEmptyOrErrorBehavior[NULL]), FLAG(SqlJsonQueryEmptyOrErrorBehavior[NULL]))])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testJsonType">
<Resource name="sql">
<![CDATA[select json_type(ename)
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[JSON_TYPE($1)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testJsonValue">
<Resource name="sql">
<![CDATA[select json_value(ename, 'lax $')
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[JSON_VALUE($1, 'lax $')])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testJsonValueExpressionOperator">
<Resource name="sql">
<![CDATA[select ename format json,
ename format json encoding utf8,
ename format json encoding utf16,
ename format json encoding utf32
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[FORMAT JSON($1)], EXPR$1=[FORMAT JSON($1)], EXPR$2=[FORMAT JSON($1)], EXPR$3=[FORMAT JSON($1)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testLateral">
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO0=[$9], NAME=[$10])
LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{7}])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalProject(DEPTNO=[$0], NAME=[$1])
LogicalFilter(condition=[=($cor0.DEPTNO, $0)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select * from emp,
LATERAL (select * from dept where emp.deptno=dept.deptno)]]>
</Resource>
</TestCase>
<TestCase name="testLateralDecorrelate">
<Resource name="sql">
<![CDATA[select * from emp,
LATERAL (select * from dept where emp.deptno=dept.deptno)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO0=[$9], NAME=[$10])
LogicalJoin(condition=[=($7, $11)], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalProject(DEPTNO=[$0], NAME=[$1], DEPTNO2=[$0])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testLateralDecorrelateRex">
<Resource name="sql">
<![CDATA[select * from emp,
LATERAL (select * from dept where emp.deptno=dept.deptno)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO0=[$9], NAME=[$10])
LogicalJoin(condition=[=($7, $11)], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalProject(DEPTNO=[$0], NAME=[$1], DEPTNO2=[$0])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testLateralDecorrelateThetaRex">
<Resource name="sql">
<![CDATA[select * from emp,
LATERAL (select * from dept where emp.deptno < dept.deptno)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO0=[$9], NAME=[$10])
LogicalJoin(condition=[=($7, $11)], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalProject(DEPTNO=[$0], NAME=[$1], DEPTNO0=[$2])
LogicalJoin(condition=[<($2, $0)], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
LogicalAggregate(group=[{0}])
LogicalProject(DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testLeftJoinLateral1">
<Resource name="sql">
<![CDATA[select * from (values 4) as t(c)
left join lateral
(select c,a*c from (values 2) as s(a)) as r(d,c)
using(c)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(C=[$0], D=[$1])
LogicalCorrelate(correlation=[$cor0], joinType=[left], requiredColumns=[{0}])
LogicalValues(tuples=[[{ 4 }]])
LogicalFilter(condition=[=($cor0.C, $1)])
LogicalProject(C=[$cor0.C], EXPR$1=[*($0, $cor0.C)])
LogicalValues(tuples=[[{ 2 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testLeftJoinLateral2">
<Resource name="sql">
<![CDATA[select * from (values 4) as t(c)
natural left join lateral
(select c,a*c from (values 2) as s(a)) as r(d,c)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(C=[$0], D=[$1])
LogicalCorrelate(correlation=[$cor0], joinType=[left], requiredColumns=[{0}])
LogicalValues(tuples=[[{ 4 }]])
LogicalFilter(condition=[=($cor0.C, $1)])
LogicalProject(C=[$cor0.C], EXPR$1=[*($0, $cor0.C)])
LogicalValues(tuples=[[{ 2 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testLeftJoinLateral3">
<Resource name="sql">
<![CDATA[select * from (values 4) as t(c)
left join lateral
(select c,a*c from (values 2) as s(a)) as r(d,c)
on t.c=r.c]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(C=[$0], D=[$1], C0=[$2])
LogicalCorrelate(correlation=[$cor0], joinType=[left], requiredColumns=[{0}])
LogicalValues(tuples=[[{ 4 }]])
LogicalFilter(condition=[=($cor0.C, $1)])
LogicalProject(C=[$cor0.C], EXPR$1=[*($0, $cor0.C)])
LogicalValues(tuples=[[{ 2 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testLeftJoinLateral4">
<Resource name="sql">
<![CDATA[select * from (values (4,5)) as t(c,d)
left join lateral
(select c,a*c from (values 2) as s(a)) as r(d,c)
on t.c+t.d=r.c]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(C=[$0], D=[$1], D0=[$2], C0=[$3])
LogicalProject(C=[$0], D=[$1], C0=[$4], EXPR$1=[$5])
LogicalCorrelate(correlation=[$cor0], joinType=[left], requiredColumns=[{2, 3}])
LogicalProject(C=[$0], D=[$1], $f2=[+($0, $1)], C0=[$0])
LogicalValues(tuples=[[{ 4, 5 }]])
LogicalFilter(condition=[=($cor0.$f2, $1)])
LogicalProject(C=[$cor0.C], EXPR$1=[*($0, $cor0.C)])
LogicalValues(tuples=[[{ 2 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testLeftJoinLateral5">
<Resource name="sql">
<![CDATA[select * from (values 4) as t (c)
left join lateral
(select f1+b1 from (values 2) as foo(f1)
join
(select c+1 from (values 3)) as bar(b1)
on f1=b1)
as r(n) on c=n]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(C=[$0], N=[$1])
LogicalProject(C=[$0], EXPR$0=[$3])
LogicalCorrelate(correlation=[$cor0], joinType=[left], requiredColumns=[{1, 2}])
LogicalProject(C=[$0], C0=[$0], $f2=[+($0, 1)])
LogicalValues(tuples=[[{ 4 }]])
LogicalFilter(condition=[=($cor0.C, $0)])
LogicalProject(EXPR$0=[+($0, $1)])
LogicalJoin(condition=[=($0, $1)], joinType=[inner])
LogicalValues(tuples=[[{ 2 }]])
LogicalProject(EXPR$0=[$cor0.$f2])
LogicalValues(tuples=[[{ 3 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testMatchRecognize1">
<Resource name="sql">
<![CDATA[select *
from emp match_recognize
(
partition by job, sal
order by job asc, sal desc, empno
pattern (strt down+ up+)
define
down as down.mgr < PREV(down.mgr),
up as up.mgr > prev(up.mgr)) as mr]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalMatch(partition=[[2, 5]], order=[[2, 5 DESC, 0]], outputFields=[[EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO, SLACKER]], allRows=[false], after=[FLAG(SKIP TO NEXT ROW)], pattern=[(('STRT', PATTERN_QUANTIFIER('DOWN', 1, -1, false)), PATTERN_QUANTIFIER('UP', 1, -1, false))], isStrictStarts=[false], isStrictEnds=[false], subsets=[[]], patternDefinitions=[[<(PREV(DOWN.$3, 0), PREV(DOWN.$3, 1)), >(PREV(UP.$3, 0), PREV(UP.$3, 1))]], inputFields=[[EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO, SLACKER]])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testMatchRecognizeIn">
<Resource name="sql">
<![CDATA[select *
from emp match_recognize
(
partition by job, sal
order by job asc, sal desc, empno
pattern (strt down+ up+)
define
down as down.mgr in (0, 1),
up as up.mgr > prev(up.mgr)) as mr]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalMatch(partition=[[2, 5]], order=[[2, 5 DESC, 0]], outputFields=[[EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO, SLACKER]], allRows=[false], after=[FLAG(SKIP TO NEXT ROW)], pattern=[(('STRT', PATTERN_QUANTIFIER('DOWN', 1, -1, false)), PATTERN_QUANTIFIER('UP', 1, -1, false))], isStrictStarts=[false], isStrictEnds=[false], subsets=[[]], patternDefinitions=[[OR(=(PREV(DOWN.$3, 0), 0), =(PREV(DOWN.$3, 0), 1)), >(PREV(UP.$3, 0), PREV(UP.$3, 1))]], inputFields=[[EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO, SLACKER]])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testMatchRecognizeMeasures1">
<Resource name="sql">
<![CDATA[select *
from emp match_recognize (
partition by job, sal
order by job asc, sal desc
measures MATCH_NUMBER() as match_num,
CLASSIFIER() as var_match,
STRT.mgr as start_nw,
LAST(DOWN.mgr) as bottom_nw,
LAST(up.mgr) as end_nw
pattern (strt down+ up+)
define
down as down.mgr < PREV(down.mgr),
up as up.mgr > prev(up.mgr)) as mr]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(JOB=[$0], SAL=[$1], MATCH_NUM=[$2], VAR_MATCH=[$3], START_NW=[$4], BOTTOM_NW=[$5], END_NW=[$6])
LogicalMatch(partition=[[2, 5]], order=[[2, 5 DESC]], outputFields=[[JOB, SAL, MATCH_NUM, VAR_MATCH, START_NW, BOTTOM_NW, END_NW]], allRows=[false], after=[FLAG(SKIP TO NEXT ROW)], pattern=[(('STRT', PATTERN_QUANTIFIER('DOWN', 1, -1, false)), PATTERN_QUANTIFIER('UP', 1, -1, false))], isStrictStarts=[false], isStrictEnds=[false], subsets=[[]], patternDefinitions=[[<(PREV(DOWN.$3, 0), PREV(DOWN.$3, 1)), >(PREV(UP.$3, 0), PREV(UP.$3, 1))]], inputFields=[[EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO, SLACKER]])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testMatchRecognizeMeasures2">
<Resource name="sql">
<![CDATA[select *
from emp match_recognize (
partition by job
order by sal
measures MATCH_NUMBER() as match_num,
CLASSIFIER() as var_match,
STRT.mgr as start_nw,
LAST(DOWN.mgr) as bottom_nw,
LAST(up.mgr) as end_nw
pattern (strt down+ up+)
define
down as down.mgr < PREV(down.mgr),
up as up.mgr > prev(up.mgr)) as mr]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(JOB=[$0], MATCH_NUM=[$1], VAR_MATCH=[$2], START_NW=[$3], BOTTOM_NW=[$4], END_NW=[$5])
LogicalMatch(partition=[[2]], order=[[5]], outputFields=[[JOB, MATCH_NUM, VAR_MATCH, START_NW, BOTTOM_NW, END_NW]], allRows=[false], after=[FLAG(SKIP TO NEXT ROW)], pattern=[(('STRT', PATTERN_QUANTIFIER('DOWN', 1, -1, false)), PATTERN_QUANTIFIER('UP', 1, -1, false))], isStrictStarts=[false], isStrictEnds=[false], subsets=[[]], patternDefinitions=[[<(PREV(DOWN.$3, 0), PREV(DOWN.$3, 1)), >(PREV(UP.$3, 0), PREV(UP.$3, 1))]], inputFields=[[EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO, SLACKER]])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testMatchRecognizeMeasures3">
<Resource name="sql">
<![CDATA[select *
from emp match_recognize (
partition by job
order by sal
measures MATCH_NUMBER() as match_num,
CLASSIFIER() as var_match,
STRT.mgr as start_nw,
LAST(DOWN.mgr) as bottom_nw,
LAST(up.mgr) as end_nw
ALL ROWS PER MATCH
pattern (strt down+ up+)
define
down as down.mgr < PREV(down.mgr),
up as up.mgr > prev(up.mgr)) as mr]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(JOB=[$0], SAL=[$1], EMPNO=[$2], ENAME=[$3], MGR=[$4], HIREDATE=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], MATCH_NUM=[$9], VAR_MATCH=[$10], START_NW=[$11], BOTTOM_NW=[$12], END_NW=[$13])
LogicalMatch(partition=[[2]], order=[[5]], outputFields=[[JOB, SAL, EMPNO, ENAME, MGR, HIREDATE, COMM, DEPTNO, SLACKER, MATCH_NUM, VAR_MATCH, START_NW, BOTTOM_NW, END_NW]], allRows=[true], after=[FLAG(SKIP TO NEXT ROW)], pattern=[(('STRT', PATTERN_QUANTIFIER('DOWN', 1, -1, false)), PATTERN_QUANTIFIER('UP', 1, -1, false))], isStrictStarts=[false], isStrictEnds=[false], subsets=[[]], patternDefinitions=[[<(PREV(DOWN.$3, 0), PREV(DOWN.$3, 1)), >(PREV(UP.$3, 0), PREV(UP.$3, 1))]], inputFields=[[EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO, SLACKER]])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testMatchRecognizePatternSkip1">
<Resource name="sql">
<![CDATA[select *
from emp match_recognize
(
after match skip to next row
pattern (strt down+ up+)
define
down as down.mgr < PREV(down.mgr),
up as up.mgr > NEXT(up.mgr)
) mr]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalMatch(partition=[[]], order=[[]], outputFields=[[EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO, SLACKER]], allRows=[false], after=[FLAG(SKIP TO NEXT ROW)], pattern=[(('STRT', PATTERN_QUANTIFIER('DOWN', 1, -1, false)), PATTERN_QUANTIFIER('UP', 1, -1, false))], isStrictStarts=[false], isStrictEnds=[false], subsets=[[]], patternDefinitions=[[<(PREV(DOWN.$3, 0), PREV(DOWN.$3, 1)), >(PREV(UP.$3, 0), NEXT(PREV(UP.$3, 0), 1))]], inputFields=[[EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO, SLACKER]])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testMatchRecognizePrevDown">
<Resource name="sql">
<![CDATA[SELECT *
FROM emp
MATCH_RECOGNIZE (
MEASURES
STRT.mgr AS start_mgr,
LAST(DOWN.mgr) AS up_days,
LAST(UP.mgr) AS total_days
PATTERN (STRT DOWN+ UP+)
DEFINE
DOWN AS DOWN.mgr < PREV(DOWN.mgr),
UP AS UP.mgr > PREV(DOWN.mgr)
) AS T]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(START_MGR=[$0], UP_DAYS=[$1], TOTAL_DAYS=[$2])
LogicalMatch(partition=[[]], order=[[]], outputFields=[[START_MGR, UP_DAYS, TOTAL_DAYS]], allRows=[false], after=[FLAG(SKIP TO NEXT ROW)], pattern=[(('STRT', PATTERN_QUANTIFIER('DOWN', 1, -1, false)), PATTERN_QUANTIFIER('UP', 1, -1, false))], isStrictStarts=[false], isStrictEnds=[false], subsets=[[]], patternDefinitions=[[<(PREV(DOWN.$3, 0), PREV(DOWN.$3, 1)), >(PREV(UP.$3, 0), LAST(DOWN.$3, 1))]], inputFields=[[EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO, SLACKER]])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testMatchRecognizePrevLast">
<Resource name="sql">
<![CDATA[SELECT *
FROM emp
MATCH_RECOGNIZE (
MEASURES
STRT.mgr AS start_mgr,
LAST(DOWN.mgr) AS bottom_mgr,
LAST(UP.mgr) AS end_mgr
ONE ROW PER MATCH
PATTERN (STRT DOWN+ UP+)
DEFINE
DOWN AS DOWN.mgr < PREV(DOWN.mgr),
UP AS UP.mgr > PREV(LAST(DOWN.mgr, 1), 1)
) AS T]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(START_MGR=[$0], BOTTOM_MGR=[$1], END_MGR=[$2])
LogicalMatch(partition=[[]], order=[[]], outputFields=[[START_MGR, BOTTOM_MGR, END_MGR]], allRows=[false], after=[FLAG(SKIP TO NEXT ROW)], pattern=[(('STRT', PATTERN_QUANTIFIER('DOWN', 1, -1, false)), PATTERN_QUANTIFIER('UP', 1, -1, false))], isStrictStarts=[false], isStrictEnds=[false], subsets=[[]], patternDefinitions=[[<(PREV(DOWN.$3, 0), PREV(DOWN.$3, 1)), >(PREV(UP.$3, 0), PREV(LAST(DOWN.$3, 1), 1))]], inputFields=[[EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO, SLACKER]])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testMatchRecognizeSubset1">
<Resource name="sql">
<![CDATA[select *
from emp match_recognize
(
after match skip to down
pattern (strt down+ up+)
subset stdn = (strt, down)
define
down as down.mgr < PREV(down.mgr),
up as up.mgr > NEXT(up.mgr)
) mr]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalMatch(partition=[[]], order=[[]], outputFields=[[EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO, SLACKER]], allRows=[false], after=[SKIP TO LAST('DOWN')], pattern=[(('STRT', PATTERN_QUANTIFIER('DOWN', 1, -1, false)), PATTERN_QUANTIFIER('UP', 1, -1, false))], isStrictStarts=[false], isStrictEnds=[false], subsets=[[[DOWN, STRT]]], patternDefinitions=[[<(PREV(DOWN.$3, 0), PREV(DOWN.$3, 1)), >(PREV(UP.$3, 0), NEXT(PREV(UP.$3, 0), 1))]], inputFields=[[EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO, SLACKER]])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testMeasureRef">
<Resource name="sql">
<![CDATA[select deptno, aggregate(count_plus_100) as c
from empm
group by deptno]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{0}], C=[AGGREGATE($1)])
LogicalProject(DEPTNO=[$7], COUNT_PLUS_100=[$9])
LogicalTableScan(table=[[CATALOG, SALES, EMPM]])
]]>
</Resource>
</TestCase>
<TestCase name="testModeFunction">
<Resource name="sql">
<![CDATA[select mode(deptno)
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{}], EXPR$0=[MODE($0)])
LogicalProject(DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testModeFunctionWithWinAgg">
<Resource name="sql">
<![CDATA[select deptno, ename,
mode(job) over (partition by deptno order by ename)
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$7], ENAME=[$1], EXPR$2=[MODE($2) OVER (PARTITION BY $7 ORDER BY $1)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testModifiableViewDdlExtend">
<Resource name="sql">
<![CDATA[select extra from EMP_MODIFIABLEVIEW2]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXTRA=[$6])
LogicalTableScan(table=[[CATALOG, SALES, EMP_MODIFIABLEVIEW2]])
]]>
</Resource>
</TestCase>
<TestCase name="testModifiableViewExtend">
<Resource name="sql">
<![CDATA[select *
from EMP_MODIFIABLEVIEW extend (x varchar(5) not null)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], SLACKER=[$7], X=[$8])
LogicalTableScan(table=[[CATALOG, SALES, EMP_MODIFIABLEVIEW]])
]]>
</Resource>
</TestCase>
<TestCase name="testModifiableViewExtendExpression">
<Resource name="sql">
<![CDATA[select empno + x
from EMP_MODIFIABLEVIEW extend (x int not null)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[+($0, $8)])
LogicalTableScan(table=[[CATALOG, SALES, EMP_MODIFIABLEVIEW]])
]]>
</Resource>
</TestCase>
<TestCase name="testModifiableViewExtendSubset">
<Resource name="sql">
<![CDATA[select x, empno
from EMP_MODIFIABLEVIEW extend (x varchar(5) not null)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(X=[$8], EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP_MODIFIABLEVIEW]])
]]>
</Resource>
</TestCase>
<TestCase name="testMultiAnd">
<Resource name="sql">
<![CDATA[select * from emp
where deptno < 10
and deptno > 5
and (deptno = 8 or empno < 100)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalFilter(condition=[AND(<($7, 10), >($7, 5), OR(=($7, 8), <($0, 100)))])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testMultiCorrelationInProjectionWithProjection">
<Resource name="sql">
<![CDATA[select cardinality(array(select e.deptno)), array(select e.ename)[0]
from (select deptno, ename from emp) e]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(variablesSet=[[$cor0]], EXPR$0=[CARDINALITY(ARRAY({
LogicalProject(DEPTNO=[$cor0.DEPTNO])
LogicalValues(tuples=[[{ 0 }]])
}))], EXPR$1=[ITEM(ARRAY({
LogicalProject(ENAME=[$cor0.ENAME])
LogicalValues(tuples=[[{ 0 }]])
}), 0)])
LogicalProject(DEPTNO=[$7], ENAME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testMultiset">
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=['a'], EXPR$1=[$SLICE($2)])
LogicalJoin(condition=[true], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
Collect(field=[EXPR$0])
LogicalValues(tuples=[[{ 10 }]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select 'a',multiset[10] from dept]]>
</Resource>
</TestCase>
<TestCase name="testMultisetOfColumns">
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=['abc'], EXPR$1=[$SLICE($9)])
LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{5, 7}])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
Collect(field=[EXPR$0])
LogicalUnion(all=[true])
LogicalProject(EXPR$0=[$cor0.DEPTNO])
LogicalValues(tuples=[[{ 0 }]])
LogicalProject(EXPR$0=[$cor0.SAL])
LogicalValues(tuples=[[{ 0 }]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select 'abc',multiset[deptno,sal] from emp]]>
</Resource>
</TestCase>
<TestCase name="testMultisetOfColumnsRex">
<Resource name="sql">
<![CDATA[select 'abc',multiset[deptno,sal] from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=['abc'], EXPR$1=[$SLICE($9)])
LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{5, 7}])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
Collect(field=[EXPR$0])
LogicalUnion(all=[true])
LogicalProject(EXPR$0=[$cor0.DEPTNO])
LogicalValues(tuples=[[{ 0 }]])
LogicalProject(EXPR$0=[$cor0.SAL])
LogicalValues(tuples=[[{ 0 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testMultisetSubQuery">
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[$1])
LogicalJoin(condition=[true], joinType=[inner])
LogicalValues(tuples=[[{ true }]])
Collect(field=[EXPR$0])
LogicalProject(DEPTNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select multiset(select deptno from dept) from (values(true))]]>
</Resource>
</TestCase>
<TestCase name="testNestedAggregates">
<Resource name="sql">
<![CDATA[SELECT
avg(sum(sal) + 2 * min(empno) + 3 * avg(empno))
over (partition by deptno)
from emp
group by deptno]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[CAST(/(SUM(+(+($1, *(2, $2)), *(3, $3))) OVER (PARTITION BY $0), COUNT(+(+($1, *(2, $2)), *(3, $3))) OVER (PARTITION BY $0))):INTEGER NOT NULL])
LogicalAggregate(group=[{0}], agg#0=[SUM($1)], agg#1=[MIN($2)], agg#2=[AVG($2)])
LogicalProject(DEPTNO=[$7], SAL=[$5], EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testNestedColumnType">
<Resource name="plan">
<![CDATA[
LogicalProject(ZIP=[$3])
LogicalFilter(condition=[=($2, 'abc')])
LogicalProject(EMPNO=[$0], STREET=[$1.STREET], CITY=[$1.CITY], ZIP=[$1.ZIP], STATE=[$1.STATE], STREET5=[$2.STREET], CITY6=[$2.CITY], ZIP7=[$2.ZIP], STATE8=[$2.STATE])
LogicalTableScan(table=[[CATALOG, SALES, EMP_ADDRESS]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select empa.home_address.zip
from sales.emp_address empa
where empa.home_address.city = 'abc']]>
</Resource>
</TestCase>
<TestCase name="testNestedCorrelations">
<Resource name="sql">
<![CDATA[select *
from (select 2+deptno d2, 3+deptno d3 from emp) e
where exists (select 1 from (select deptno+1 d1 from dept) d
where d1=e.d2 and exists (select 2 from (select deptno+4 d4, deptno+5 d5, deptno+6 d6 from dept)
where d4=d.d1 and d5=d.d1 and d6=e.d3))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(D2=[$0], D3=[$1])
LogicalFilter(condition=[IS NOT NULL($2)])
LogicalCorrelate(correlation=[$cor3], joinType=[left], requiredColumns=[{0, 1}])
LogicalProject(D2=[+(2, $7)], D3=[+(3, $7)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{}], agg#0=[MIN($0)])
LogicalProject($f0=[true])
LogicalFilter(condition=[AND(=($0, $cor3.D2), IS NOT NULL($1))])
LogicalCorrelate(correlation=[$cor0], joinType=[left], requiredColumns=[{0}])
LogicalProject(D1=[+($0, 1)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
LogicalAggregate(group=[{}], agg#0=[MIN($0)])
LogicalProject($f0=[true])
LogicalFilter(condition=[AND(=($0, $cor0.D1), =($1, $cor0.D1), =($2, $cor3.D3))])
LogicalProject(D4=[+($0, 4)], D5=[+($0, 5)], D6=[+($0, 6)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testNestedCorrelationsDecorrelated">
<Resource name="sql">
<![CDATA[select *
from (select 2+deptno d2, 3+deptno d3 from emp) e
where exists (select 1 from (select deptno+1 d1 from dept) d
where d1=e.d2 and exists (select 2 from (select deptno+4 d4, deptno+5 d5, deptno+6 d6 from dept)
where d4=d.d1 and d5=d.d1 and d6=e.d3))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(D2=[$0], D3=[$1])
LogicalProject(D2=[$0], D3=[$1], D1=[CAST($2):INTEGER], D6=[$3], $f2=[CAST($4):BOOLEAN])
LogicalJoin(condition=[AND(=($0, $2), =($1, $3))], joinType=[inner])
LogicalProject(D2=[+(2, $7)], D3=[+(3, $7)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0, 1}], agg#0=[MIN($2)])
LogicalProject(D1=[$0], D6=[$2], $f0=[true])
LogicalFilter(condition=[IS NOT NULL($1)])
LogicalProject(D1=[$0], $f0=[$3], D6=[$2])
LogicalJoin(condition=[=($0, $1)], joinType=[left])
LogicalProject(D1=[+($0, 1)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
LogicalAggregate(group=[{0, 1}], agg#0=[MIN($2)])
LogicalProject(D4=[$0], D6=[$2], $f0=[true])
LogicalFilter(condition=[=($1, $0)])
LogicalProject(D4=[+($0, 4)], D5=[+($0, 5)], D6=[+($0, 6)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testNestedCorrelationsDecorrelatedRex">
<Resource name="sql">
<![CDATA[select *
from (select 2+deptno d2, 3+deptno d3 from emp) e
where exists (select 1 from (select deptno+1 d1 from dept) d
where d1=e.d2 and exists (select 2 from (select deptno+4 d4, deptno+5 d5, deptno+6 d6 from dept)
where d4=d.d1 and d5=d.d1 and d6=e.d3))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(D2=[$0], D3=[$1])
LogicalProject(D2=[$0], D3=[$1], D1=[CAST($2):INTEGER], D6=[$3], $f2=[CAST($4):BOOLEAN])
LogicalJoin(condition=[AND(=($0, $2), =($1, $3))], joinType=[inner])
LogicalProject(D2=[+(2, $7)], D3=[+(3, $7)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0, 1}], agg#0=[MIN($2)])
LogicalProject(D1=[$0], D6=[$2], $f0=[true])
LogicalFilter(condition=[IS NOT NULL($1)])
LogicalProject(D1=[$0], $f0=[$3], D6=[$2])
LogicalJoin(condition=[=($0, $1)], joinType=[left])
LogicalProject(D1=[+($0, 1)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
LogicalAggregate(group=[{0, 1}], agg#0=[MIN($2)])
LogicalProject(D4=[$0], D6=[$2], $f0=[true])
LogicalFilter(condition=[=($1, $0)])
LogicalProject(D4=[+($0, 4)], D5=[+($0, 5)], D6=[+($0, 6)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testNestedPrimitiveFieldAccess">
<Resource name="sql">
<![CDATA[select dn.skill['desc']
from sales.dept_nested dn]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[$2.DESC])
LogicalTableScan(table=[[CATALOG, SALES, DEPT_NESTED]])
]]>
</Resource>
</TestCase>
<TestCase name="testNestedStructFieldAccess">
<Resource name="sql">
<![CDATA[select dn.skill['others']
from sales.dept_nested dn]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[ROW($2.OTHERS.A, $2.OTHERS.B)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT_NESTED]])
]]>
</Resource>
</TestCase>
<TestCase name="testNestedStructPrimitiveFieldAccess">
<Resource name="sql">
<![CDATA[select dn.skill['others']['a']
from sales.dept_nested dn]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[$2.OTHERS.A])
LogicalTableScan(table=[[CATALOG, SALES, DEPT_NESTED]])
]]>
</Resource>
</TestCase>
<TestCase name="testNestedStructSingleFieldAccessWhere">
<Resource name="sql">
<![CDATA[select dn.skill
from sales.dept_single dn WHERE dn.skill.type = '']]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(SKILL=[ROW($0)])
LogicalFilter(condition=[=($0, '')])
LogicalProject(TYPE=[$0.TYPE])
LogicalTableScan(table=[[CATALOG, SALES, DEPT_SINGLE]])
]]>
</Resource>
</TestCase>
<TestCase name="testNotCaseInMoreClause">
<Resource name="sql">
<![CDATA[select empno from emp where not case when true then deptno in (10,20) when false then false else deptno in (30,40) end]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0])
LogicalFilter(condition=[CASE(true, NOT(OR(=($7, 10), =($7, 20))), false, NOT(false), NOT(OR(=($7, 30), =($7, 40))))])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testNotCaseInThreeClause">
<Resource name="sql">
<![CDATA[select empno from emp where not case when true then deptno in (10,20) else true end]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0])
LogicalFilter(condition=[CASE(true, NOT(OR(=($7, 10), =($7, 20))), NOT(true))])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testNotCaseInWithoutElse">
<Resource name="sql">
<![CDATA[select empno from emp where not case when true then deptno in (10,20) end]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0])
LogicalFilter(condition=[CASE(true, CAST(NOT(OR(=($7, 10), =($7, 20)))):BOOLEAN, null:BOOLEAN)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testNotExistsCorrelated">
<Resource name="sql">
<![CDATA[select * from emp where not exists (
select 1 from dept where emp.deptno=dept.deptno)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalFilter(condition=[NOT(IS NOT NULL($9))])
LogicalCorrelate(correlation=[$cor0], joinType=[left], requiredColumns=[{7}])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{}], agg#0=[MIN($0)])
LogicalProject($f0=[true])
LogicalFilter(condition=[=($cor0.DEPTNO, $0)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testNotInUncorrelatedSubQuery">
<Resource name="sql">
<![CDATA[select empno from emp where deptno not in (select deptno from dept)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0])
LogicalFilter(condition=[NOT(AND(IS TRUE($11), IS NOT NULL($9)))])
LogicalJoin(condition=[=($9, $10)], joinType=[left])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO0=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0}], agg#0=[MIN($1)])
LogicalProject(DEPTNO=[$0], $f1=[true])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testNotInUncorrelatedSubQueryInSelect">
<Resource name="sql">
<![CDATA[select empno, deptno not in (
select case when true then deptno else null end from dept)
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], EXPR$1=[OR(=($9, 0), AND(<($10, $9), null, IS NULL($13)), AND(IS NULL($13), >=($10, $9)))])
LogicalJoin(condition=[=($11, $12)], joinType=[left])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], $f0=[$9], $f1=[$10], DEPTNO0=[$7])
LogicalJoin(condition=[true], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{}], agg#0=[COUNT()], agg#1=[COUNT($0)])
LogicalProject(EXPR$0=[CAST($0):INTEGER], $f1=[true])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
LogicalAggregate(group=[{0}], agg#0=[MIN($1)])
LogicalProject(EXPR$0=[CAST($0):INTEGER], $f1=[true])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testNotInUncorrelatedSubQueryInSelectDeduceNotNull">
<Resource name="sql">
<![CDATA[select empno, deptno not in (
select mgr from emp where mgr > 5)
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], EXPR$1=[CAST(IS NOT TRUE($11)):BOOLEAN])
LogicalJoin(condition=[=($9, $10)], joinType=[left])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO0=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0}], agg#0=[MIN($1)])
LogicalProject(MGR=[$3], $f1=[true])
LogicalFilter(condition=[>($3, 5)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testNotInUncorrelatedSubQueryInSelectDeduceNotNull2">
<Resource name="sql">
<![CDATA[select empno, deptno not in (
select mgr from emp where mgr is not null)
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], EXPR$1=[CAST(IS NOT TRUE($11)):BOOLEAN])
LogicalJoin(condition=[=($9, $10)], joinType=[left])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO0=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0}], agg#0=[MIN($1)])
LogicalProject(MGR=[$3], $f1=[true])
LogicalFilter(condition=[IS NOT NULL($3)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testNotInUncorrelatedSubQueryInSelectDeduceNotNull3">
<Resource name="sql">
<![CDATA[select empno, deptno not in (
select mgr from emp where mgr in (
select mgr from emp where deptno = 10))
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], EXPR$1=[CAST(IS NOT TRUE($11)):BOOLEAN])
LogicalJoin(condition=[=($9, $10)], joinType=[left])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO0=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0}], agg#0=[MIN($1)])
LogicalProject(MGR=[$3], $f1=[true])
LogicalJoin(condition=[=($3, $9)], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0}])
LogicalProject(MGR=[$3])
LogicalFilter(condition=[=($7, 10)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testNotInUncorrelatedSubQueryInSelectMayBeNull">
<Resource name="sql">
<![CDATA[select empno, deptno not in (
select mgr from emp)
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], EXPR$1=[OR(=($9, 0), AND(<($10, $9), null, IS NULL($13)), AND(IS NULL($13), >=($10, $9)))])
LogicalJoin(condition=[=($11, $12)], joinType=[left])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], $f0=[$9], $f1=[$10], DEPTNO0=[$7])
LogicalJoin(condition=[true], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{}], agg#0=[COUNT()], agg#1=[COUNT($0)])
LogicalProject(MGR=[$3], $f1=[true])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0}], agg#0=[MIN($1)])
LogicalProject(MGR=[$3], $f1=[true])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testNotInUncorrelatedSubQueryInSelectNotNull">
<Resource name="sql">
<![CDATA[select empno, deptno not in (
select deptno from dept)
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], EXPR$1=[IS NOT TRUE($11)])
LogicalJoin(condition=[=($9, $10)], joinType=[left])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO0=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0}], agg#0=[MIN($1)])
LogicalProject(DEPTNO=[$0], $f1=[true])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testNotInUncorrelatedSubQueryInSelectNotNullRex">
<Resource name="sql">
<![CDATA[select empno, deptno not in (
select deptno from dept)
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], EXPR$1=[NOT(IN($7, {
LogicalProject(DEPTNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
}))])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testNotInUncorrelatedSubQueryInSelectRex">
<Resource name="sql">
<![CDATA[select empno, deptno not in (
select case when true then deptno else null end from dept)
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], EXPR$1=[NOT(IN($7, {
LogicalProject(EXPR$0=[CAST($0):INTEGER])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
}))])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testNotInUncorrelatedSubQueryRex">
<Resource name="sql">
<![CDATA[select empno from emp where deptno not in (select deptno from dept)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0])
LogicalFilter(condition=[NOT(IN($7, {
LogicalProject(DEPTNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
}))])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testNotInWithLiteral">
<Resource name="sql">
<![CDATA[SELECT *
FROM SALES.NATION
WHERE n_name NOT IN
(SELECT ''
FROM SALES.NATION)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(**=[$1])
LogicalFilter(condition=[NOT(AND(IS TRUE($4), IS NOT NULL($2)))])
LogicalJoin(condition=[=($2, $3)], joinType=[left])
LogicalProject(N_NAME=[$0], **=[$1], N_NAME0=[$0])
LogicalTableScan(table=[[CATALOG, SALES, NATION]])
LogicalAggregate(group=[{0}], agg#0=[MIN($1)])
LogicalProject(EXPR$0=[''], $f1=[true])
LogicalTableScan(table=[[CATALOG, SALES, NATION]])
]]>
</Resource>
</TestCase>
<TestCase name="testNotLike">
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[NOT(LIKE('a', 'b', 'c'))])
LogicalValues(tuples=[[{ 0 }]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[values ('a' not like 'b' escape 'c')]]>
</Resource>
</TestCase>
<TestCase name="testNotNotIn">
<Resource name="sql">
<![CDATA[select * from EMP where not (ename not in ('Fred') )]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalFilter(condition=[=($1, 'Fred')])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testNotUnique">
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalFilter(condition=[NOT(UNIQUE({
LogicalProject(EXPR$0=[1])
LogicalFilter(condition=[=($0, 55)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
}))])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select * from emp
where not unique (select 1 from dept where deptno=55)]]>
</Resource>
</TestCase>
<TestCase name="testNotUniqueCorrelated">
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalFilter(condition=[NOT(UNIQUE({
LogicalProject(EXPR$0=[1])
LogicalFilter(condition=[=($cor0.DEPTNO, $0)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
}))], variablesSet=[[$cor0]])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select * from emp where not unique (
select 1 from dept where emp.deptno=dept.deptno)]]>
</Resource>
</TestCase>
<TestCase name="testOffset">
<Resource name="sql">
<![CDATA[select empno from emp offset 10 rows]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalSort(offset=[10])
LogicalProject(EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testOffset0">
<Resource name="sql">
<![CDATA[select * from emp offset 0]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testOffsetFetch">
<Resource name="sql">
<![CDATA[select empno from emp
offset 10 rows fetch next 5 rows only]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalSort(offset=[10], fetch=[5])
LogicalProject(EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testOffsetFetchWithDynamicParameter">
<Resource name="sql">
<![CDATA[select empno from emp
offset ? rows fetch next ? rows only]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalSort(offset=[?0], fetch=[?1])
LogicalProject(EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testOffsetWithDynamicParameter">
<Resource name="sql">
<![CDATA[select empno from emp offset ? rows]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalSort(offset=[?0])
LogicalProject(EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testOrder">
<Resource name="sql">
<![CDATA[select empno from emp order by empno, empno desc]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalSort(sort0=[$0], dir0=[ASC])
LogicalProject(EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testOrderBasedRepeatFields">
<Resource name="sql">
<![CDATA[select empno from emp order by empno DESC, empno ASC]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalSort(sort0=[$0], dir0=[DESC])
LogicalProject(EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testOrderByAlias">
<Resource name="sql">
<![CDATA[select empno + 1 as x, empno - 2 as y from emp order by y]]>
</Resource>
<Resource name="plan">
<![CDATA[
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>
<TestCase name="testOrderByAliasDoesNotOverride">
<Resource name="sql">
<![CDATA[select empno + 1 as empno, empno - 2 as y
from emp order by empno + 3]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], Y=[$1])
LogicalSort(sort0=[$2], dir0=[ASC])
LogicalProject(EMPNO=[+($0, 1)], Y=[-($0, 2)], EXPR$2=[+($0, 3)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testOrderByAliasInExpr">
<Resource name="sql">
<![CDATA[select empno + 1 as x, empno - 2 as y
from emp order by y + 3]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(X=[$0], Y=[$1])
LogicalSort(sort0=[$2], dir0=[ASC])
LogicalProject(X=[+($0, 1)], Y=[-($0, 2)], EXPR$2=[+(-($0, 2), 3)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testOrderByAliasOverrides">
<Resource name="sql">
<![CDATA[select empno + 1 as empno, empno - 2 as y
from emp order by empno + 3]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], Y=[$1])
LogicalSort(sort0=[$2], dir0=[ASC])
LogicalProject(EMPNO=[+($0, 1)], Y=[-($0, 2)], EXPR$2=[+(+($0, 1), 3)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testOrderByIdenticalExpr">
<Resource name="sql">
<![CDATA[select empno + 1 from emp order by deptno asc, empno + 1 desc]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[$0])
LogicalSort(sort0=[$1], sort1=[$0], dir0=[ASC], dir1=[DESC])
LogicalProject(EXPR$0=[+($0, 1)], DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testOrderByNegativeOrdinal">
<Resource name="sql">
<![CDATA[select empno + 1, deptno, empno from emp order by -1 desc]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[$0], DEPTNO=[$1], EMPNO=[$2])
LogicalSort(sort0=[$3], dir0=[DESC])
LogicalProject(EXPR$0=[+($0, 1)], DEPTNO=[$7], EMPNO=[$0], EXPR$3=[-1])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testOrderByOrdinalDesc">
<Resource name="sql">
<![CDATA[select empno + 1, deptno, empno from emp order by 2.5 desc]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalSort(sort0=[$1], dir0=[DESC])
LogicalProject(EXPR$0=[+($0, 1)], DEPTNO=[$7], EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testOrderByOrdinalInExpr">
<Resource name="sql">
<![CDATA[select empno + 1, deptno, empno from emp order by 1 + 2 desc]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[$0], DEPTNO=[$1], EMPNO=[$2])
LogicalSort(sort0=[$3], dir0=[DESC])
LogicalProject(EXPR$0=[+($0, 1)], DEPTNO=[$7], EMPNO=[$0], EXPR$3=[+(1, 2)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testOrderByOver">
<Resource name="sql">
<![CDATA[select deptno, rank() over(partition by empno order by deptno)
from emp order by row_number() over(partition by empno order by deptno)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], EXPR$1=[$1])
LogicalSort(sort0=[$2], dir0=[ASC])
LogicalProject(DEPTNO=[$7], EXPR$1=[RANK() OVER (PARTITION BY $0 ORDER BY $7)], EXPR$2=[ROW_NUMBER() OVER (PARTITION BY $0 ORDER BY $7)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testOrderByRemoval1">
<Resource name="sql">
<![CDATA[select * from (
select empno from emp order by deptno offset 0) t
order by empno desc]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalSort(sort0=[$0], dir0=[DESC])
LogicalProject(EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testOrderByRemoval2">
<Resource name="sql">
<![CDATA[select * from (
select empno from emp order by deptno offset 1) t
order by empno desc]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalSort(sort0=[$0], dir0=[DESC])
LogicalProject(EMPNO=[$0])
LogicalSort(sort0=[$1], dir0=[ASC], offset=[1])
LogicalProject(EMPNO=[$0], DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testOrderByRemoval3">
<Resource name="sql">
<![CDATA[select * from (
select empno from emp order by deptno limit 10) t
order by empno]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalSort(sort0=[$0], dir0=[ASC])
LogicalProject(EMPNO=[$0])
LogicalSort(sort0=[$1], dir0=[ASC], fetch=[10])
LogicalProject(EMPNO=[$0], DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testOrderBySameExpr">
<Resource name="sql">
<![CDATA[select empno from emp, dept
order by sal + empno desc, sal * empno, sal + empno desc]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0])
LogicalSort(sort0=[$1], sort1=[$2], dir0=[DESC], dir1=[ASC])
LogicalProject(EMPNO=[$0], EXPR$1=[+($5, $0)], EXPR$2=[*($5, $0)])
LogicalJoin(condition=[true], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testOrderByWithIn">
<Resource name="sql">
<![CDATA[SELECT empno
FROM emp
ORDER BY
CASE WHEN empno IN (1,2) THEN 0 ELSE 1 END]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0])
LogicalSort(sort0=[$1], dir0=[ASC])
LogicalProject(EMPNO=[$0], EXPR$1=[CASE(SEARCH($0, Sarg[1, 2]), 0, 1)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testOrderByWithSubQuery">
<Resource name="sql">
<![CDATA[SELECT empno
FROM emp
ORDER BY
(SELECT empno FROM emp LIMIT 1)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0])
LogicalSort(sort0=[$1], dir0=[ASC])
LogicalProject(EMPNO=[$0], EXPR$1=[$9])
LogicalJoin(condition=[true], joinType=[left])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalSort(fetch=[1])
LogicalProject(EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testOrderDescNullsLast">
<Resource name="sql">
<![CDATA[select empno from emp order by empno desc nulls last]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalSort(sort0=[$0], dir0=[DESC-nulls-last])
LogicalProject(EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testOrderDistinct">
<Resource name="sql">
<![CDATA[select distinct empno, deptno + 1
from emp order by deptno + 1 + empno]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], EXPR$1=[$1])
LogicalSort(sort0=[$2], dir0=[ASC])
LogicalAggregate(group=[{0, 1, 2}])
LogicalProject(EMPNO=[$0], EXPR$1=[+($7, 1)], EXPR$2=[+(+($7, 1), $0)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testOrderGroup">
<Resource name="sql">
<![CDATA[select deptno, count(*)
from emp
group by deptno
order by deptno * sum(sal) desc, min(empno)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], EXPR$1=[$1])
LogicalSort(sort0=[$2], sort1=[$3], dir0=[DESC], dir1=[ASC])
LogicalProject(DEPTNO=[$0], EXPR$1=[$1], EXPR$2=[*($0, $2)], EXPR$3=[$3])
LogicalAggregate(group=[{0}], EXPR$1=[COUNT()], agg#1=[SUM($1)], agg#2=[MIN($2)])
LogicalProject(DEPTNO=[$7], SAL=[$5], EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testOrderOffsetFetch">
<Resource name="sql">
<![CDATA[select empno from emp
order by empno offset 10 rows fetch next 5 rows only]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalSort(sort0=[$0], dir0=[ASC], offset=[10], fetch=[5])
LogicalProject(EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testOrderOffsetFetchWithDynamicParameter">
<Resource name="sql">
<![CDATA[select empno from emp
order by empno offset ? rows fetch next ? rows only]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalSort(sort0=[$0], dir0=[ASC], offset=[?0], fetch=[?1])
LogicalProject(EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testOrderUnion">
<Resource name="sql">
<![CDATA[select empno, sal from emp
union all
select deptno, deptno from dept
order by sal desc, empno asc]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalSort(sort0=[$1], sort1=[$0], dir0=[DESC], dir1=[ASC])
LogicalProject(EMPNO=[$0], SAL=[$1])
LogicalUnion(all=[true])
LogicalProject(EMPNO=[$0], SAL=[$5])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalProject(DEPTNO=[$0], DEPTNO0=[$0])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testOrderUnionExprs">
<Resource name="sql">
<![CDATA[select empno, sal from emp
union all
select deptno, deptno from dept
order by empno * sal + 2]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], SAL=[$1])
LogicalSort(sort0=[$2], dir0=[ASC])
LogicalProject(EMPNO=[$0], SAL=[$1], EXPR$2=[+(*($0, $1), 2)])
LogicalUnion(all=[true])
LogicalProject(EMPNO=[$0], SAL=[$5])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalProject(DEPTNO=[$0], DEPTNO0=[$0])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testOrderUnionOrdinal">
<Resource name="sql">
<![CDATA[select empno, sal from emp
union all
select deptno, deptno from dept
order by 2]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalSort(sort0=[$1], dir0=[ASC])
LogicalProject(EMPNO=[$0], SAL=[$1])
LogicalUnion(all=[true])
LogicalProject(EMPNO=[$0], SAL=[$5])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalProject(DEPTNO=[$0], DEPTNO0=[$0])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testOverAvg">
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[CASE(>(COUNT($5) OVER (PARTITION BY $2 ORDER BY $4 ROWS 2 PRECEDING), 0), $SUM0($5) OVER (PARTITION BY $2 ORDER BY $4 ROWS 2 PRECEDING), null:INTEGER)], EXPR$1=[CAST(/(CASE(>(COUNT($5) OVER (PARTITION BY $2 ORDER BY $4 ROWS 2 PRECEDING), 0), $SUM0($5) OVER (PARTITION BY $2 ORDER BY $4 ROWS 2 PRECEDING), null:INTEGER), COUNT($5) OVER (PARTITION BY $2 ORDER BY $4 ROWS 2 PRECEDING))):INTEGER])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select sum(sal) over w1,
avg(sal) over w1
from emp
window w1 as (partition by job order by hiredate rows 2 preceding)]]>
</Resource>
</TestCase>
<TestCase name="testOverAvg2">
<Resource name="sql">
<![CDATA[select sum(sal) over w1,
avg(CAST(sal as real)) over w1
from emp
window w1 as (partition by job order by hiredate rows 2 preceding)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[CASE(>(COUNT($5) OVER (PARTITION BY $2 ORDER BY $4 ROWS 2 PRECEDING), 0), $SUM0($5) OVER (PARTITION BY $2 ORDER BY $4 ROWS 2 PRECEDING), null:INTEGER)], EXPR$1=[/(CASE(>(COUNT(CAST($5):REAL NOT NULL) OVER (PARTITION BY $2 ORDER BY $4 ROWS 2 PRECEDING), 0), $SUM0(CAST($5):REAL NOT NULL) OVER (PARTITION BY $2 ORDER BY $4 ROWS 2 PRECEDING), null:REAL), COUNT(CAST($5):REAL NOT NULL) OVER (PARTITION BY $2 ORDER BY $4 ROWS 2 PRECEDING))])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testOverCountStar">
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[COUNT($5) OVER (PARTITION BY $2 ORDER BY $4 ROWS 2 PRECEDING)], EXPR$1=[COUNT() OVER (PARTITION BY $2 ORDER BY $4 ROWS 2 PRECEDING)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select count(sal) over w1,
count(*) over w1
from emp
window w1 as (partition by job order by hiredate rows 2 preceding)]]>
</Resource>
</TestCase>
<TestCase name="testOverDefaultBracket">
<Resource name="sql">
<![CDATA[select
count(*) over (order by deptno) c1,
count(*) over (order by deptno
range unbounded preceding) c2,
count(*) over (order by deptno
range between unbounded preceding and current row) c3,
count(*) over (order by deptno
rows unbounded preceding) c4,
count(*) over (order by deptno
rows between unbounded preceding and current row) c5,
count(*) over (order by deptno
range between unbounded preceding and unbounded following) c6,
count(*) over (order by deptno
rows between unbounded preceding and unbounded following) c7
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(C1=[COUNT() OVER (ORDER BY $7)], C2=[COUNT() OVER (ORDER BY $7)], C3=[COUNT() OVER (ORDER BY $7)], C4=[COUNT() OVER (ORDER BY $7 ROWS UNBOUNDED PRECEDING)], C5=[COUNT() OVER (ORDER BY $7 ROWS UNBOUNDED PRECEDING)], C6=[COUNT() OVER (ORDER BY $7 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)], C7=[COUNT() OVER (ORDER BY $7 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testOverMultiple">
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[CASE(>(COUNT($5) OVER (PARTITION BY $2 ORDER BY $4 ROWS 2 PRECEDING), 0), $SUM0($5) OVER (PARTITION BY $2 ORDER BY $4 ROWS 2 PRECEDING), null:INTEGER)], EXPR$1=[CASE(>(COUNT($7) OVER (PARTITION BY $2 ORDER BY $4 ROWS 2 PRECEDING), 0), $SUM0($7) OVER (PARTITION BY $2 ORDER BY $4 ROWS 2 PRECEDING), null:INTEGER)], EXPR$2=[CASE(>=(COUNT() OVER (PARTITION BY $2 ORDER BY $4 ROWS 3 PRECEDING), 2), CASE(>(COUNT($7) OVER (PARTITION BY $2 ORDER BY $4 ROWS 3 PRECEDING), 0), $SUM0($7) OVER (PARTITION BY $2 ORDER BY $4 ROWS 3 PRECEDING), null:INTEGER), null:NULL)])
LogicalFilter(condition=[>(-($7, $5), 999)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select sum(sal) over w1,
sum(deptno) over w1,
sum(deptno) over w2
from emp
where deptno - sal > 999
window w1 as (partition by job order by hiredate rows 2 preceding),
w2 as (partition by job order by hiredate rows 3 preceding disallow partial),
w3 as (partition by job order by hiredate range interval '1' second preceding)]]>
</Resource>
</TestCase>
<TestCase name="testOverNullTreatmentWindow">
<Resource name="sql">
<![CDATA[select
lead(deptno, 1) over w,
lead(deptno, 2) ignore nulls over w,
lead(deptno, 3) respect nulls over w,
lead(deptno, 1) over w,
lag(deptno, 2) ignore nulls over w,
lag(deptno, 2) respect nulls over w,
first_value(deptno) over w,
first_value(deptno) ignore nulls over w,
first_value(deptno) respect nulls over w,
last_value(deptno) over w,
last_value(deptno) ignore nulls over w,
last_value(deptno) respect nulls over w
from emp
window w as (order by empno)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[LEAD($7, 1) OVER (ORDER BY $0)], EXPR$1=[LEAD($7, 2) IGNORE NULLS OVER (ORDER BY $0)], EXPR$2=[LEAD($7, 3) OVER (ORDER BY $0)], EXPR$3=[LEAD($7, 1) OVER (ORDER BY $0)], EXPR$4=[LAG($7, 2) IGNORE NULLS OVER (ORDER BY $0)], EXPR$5=[LAG($7, 2) OVER (ORDER BY $0)], EXPR$6=[FIRST_VALUE($7) OVER (ORDER BY $0)], EXPR$7=[FIRST_VALUE($7) IGNORE NULLS OVER (ORDER BY $0)], EXPR$8=[FIRST_VALUE($7) OVER (ORDER BY $0)], EXPR$9=[LAST_VALUE($7) OVER (ORDER BY $0)], EXPR$10=[LAST_VALUE($7) IGNORE NULLS OVER (ORDER BY $0)], EXPR$11=[LAST_VALUE($7) OVER (ORDER BY $0)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testOverOrderFollowingWindow">
<Resource name="sql">
<![CDATA[select
last_value(deptno) over (order by empno rows 2 following)
from emp
]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[LAST_VALUE($7) OVER (ORDER BY $0 ROWS BETWEEN CURRENT ROW AND 2 FOLLOWING)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testOverOrderWindow">
<Resource name="sql">
<![CDATA[select last_value(deptno) over (order by empno)
from emp
]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[LAST_VALUE($7) OVER (ORDER BY $0)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testPercentileCont">
<Resource name="sql">
<![CDATA[select
percentile_cont(0.25) within group (order by deptno)
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{}], EXPR$0=[PERCENTILE_CONT($0) WITHIN GROUP ([1])])
LogicalProject($f0=[0.25:DECIMAL(3, 2)], DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testPercentileContWithGroupBy">
<Resource name="sql">
<![CDATA[select deptno,
percentile_cont(0.25) within group (order by empno desc)
from emp
group by deptno]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{0}], EXPR$1=[PERCENTILE_CONT($1) WITHIN GROUP ([2 DESC])])
LogicalProject(DEPTNO=[$7], $f1=[0.25:DECIMAL(3, 2)], EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testPercentileDisc">
<Resource name="sql">
<![CDATA[select
percentile_disc(0.25) within group (order by deptno)
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{}], EXPR$0=[PERCENTILE_DISC($0) WITHIN GROUP ([1])])
LogicalProject($f0=[0.25:DECIMAL(3, 2)], DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testPercentileDiscWithGroupBy">
<Resource name="sql">
<![CDATA[select deptno,
percentile_disc(0.25) within group (order by empno)
from emp
group by deptno]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{0}], EXPR$1=[PERCENTILE_DISC($1) WITHIN GROUP ([2])])
LogicalProject(DEPTNO=[$7], $f1=[0.25:DECIMAL(3, 2)], EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testPivot">
<Resource name="sql">
<![CDATA[SELECT *
FROM (SELECT mgr, deptno, job, sal FROM emp)
PIVOT (SUM(sal) AS ss, COUNT(*)
FOR (job, deptno)
IN (('CLERK', 10) AS c10, ('MANAGER', 20) AS m20))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(MGR=[$0], C10_SS=[$1], C10=[$2], M20_SS=[$3], M20=[$4])
LogicalAggregate(group=[{0}], C10_SS=[SUM($3) FILTER $4], C10_null=[COUNT() FILTER $4], M20_SS=[SUM($3) FILTER $5], M20_null=[COUNT() FILTER $5])
LogicalProject(MGR=[$3], JOB=[$2], DEPTNO=[$7], SAL=[$5], $f4=[AND(=($2, 'CLERK'), =($7, 10))], $f5=[AND(=($2, 'MANAGER'), =($7, 20))])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testPivot2">
<Resource name="sql">
<![CDATA[SELECT *
FROM (SELECT deptno, job, sal
FROM emp)
PIVOT (SUM(sal) AS sum_sal, COUNT(*) AS "COUNT"
FOR (job) IN ('CLERK', 'MANAGER' mgr, 'ANALYST' AS "a"))
ORDER BY deptno]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalSort(sort0=[$0], dir0=[ASC])
LogicalProject(DEPTNO=[$0], 'CLERK'_SUM_SAL=[$1], 'CLERK'_COUNT=[$2], MGR_SUM_SAL=[$3], MGR_COUNT=[$4], a_SUM_SAL=[$5], a_COUNT=[$6])
LogicalAggregate(group=[{0}], 'CLERK'_SUM_SAL=[SUM($2) FILTER $3], 'CLERK'_COUNT=[COUNT() FILTER $3], MGR_SUM_SAL=[SUM($2) FILTER $4], MGR_COUNT=[COUNT() FILTER $4], a_SUM_SAL=[SUM($2) FILTER $5], a_COUNT=[COUNT() FILTER $5])
LogicalProject(DEPTNO=[$7], JOB=[$2], SAL=[$5], $f3=[=($2, 'CLERK')], $f4=[=($2, 'MANAGER')], $f5=[=($2, 'ANALYST')])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testPrevClassifier">
<Resource name="sql">
<![CDATA[SELECT *
FROM emp
MATCH_RECOGNIZE (
MEASURES
STRT.mgr AS start_mgr,
LAST(DOWN.mgr) AS up_days,
LAST(UP.mgr) AS total_days
PATTERN (STRT DOWN? UP+)
DEFINE
DOWN AS DOWN.mgr < PREV(DOWN.mgr),
UP AS CASE
WHEN PREV(CLASSIFIER()) = 'STRT'
THEN UP.mgr > 15
ELSE
UP.mgr > 20
END
) AS T]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(START_MGR=[$0], UP_DAYS=[$1], TOTAL_DAYS=[$2])
LogicalMatch(partition=[[]], order=[[]], outputFields=[[START_MGR, UP_DAYS, TOTAL_DAYS]], allRows=[false], after=[FLAG(SKIP TO NEXT ROW)], pattern=[(('STRT', PATTERN_QUANTIFIER('DOWN', 0, 1, false)), PATTERN_QUANTIFIER('UP', 1, -1, false))], isStrictStarts=[false], isStrictEnds=[false], subsets=[[]], patternDefinitions=[[<(PREV(DOWN.$3, 0), PREV(DOWN.$3, 1)), CASE(=(PREV(CLASSIFIER(), 1), 'STRT'), >(PREV(UP.$3, 0), 15), >(PREV(UP.$3, 0), 20))]], inputFields=[[EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO, SLACKER]])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testProjectAggregatesIgnoreNullsAndNot">
<Resource name="sql">
<![CDATA[select lead(sal, 4) IGNORE NULLS, lead(sal, 4) over (w)
from emp window w as (order by empno)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[IGNORE NULLS(LEAD($5, 4))], EXPR$1=[LEAD($5, 4) OVER (ORDER BY $0)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testProjectApproximateAndExactAggregates">
<Resource name="sql">
<![CDATA[SELECT empno, count(distinct ename),
approx_count_distinct(ename)
FROM emp
GROUP BY empno]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{0}], EXPR$1=[COUNT(DISTINCT $1)], EXPR$2=[COUNT(APPROXIMATE DISTINCT $1)])
LogicalProject(EMPNO=[$0], ENAME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testProjectInSubQueryWithIsTruePredicate">
<Resource name="sql">
<![CDATA[select deptno in (select deptno from empnullables) is true
from empnullables]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[IS TRUE(IN($7, {
LogicalProject(DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMPNULLABLES]])
}))])
LogicalTableScan(table=[[CATALOG, SALES, EMPNULLABLES]])
]]>
</Resource>
</TestCase>
<TestCase name="testProjectSortLimitWithCorrelateInput">
<Resource name="sql">
<![CDATA[SELECT ename||deptno FROM
(SELECT deptno, ename
FROM
(SELECT DISTINCT deptno FROM emp) t1,
LATERAL (
SELECT ename, sal
FROM emp
WHERE deptno = t1.deptno)
ORDER BY ename DESC
LIMIT 3)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[||($1, CAST($0):VARCHAR NOT NULL)])
LogicalSort(sort0=[$1], dir0=[DESC], fetch=[3])
LogicalProject(DEPTNO=[$0], ENAME=[$1])
LogicalJoin(condition=[=($0, $3)], joinType=[inner])
LogicalAggregate(group=[{0}])
LogicalProject(DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalProject(ENAME=[$1], SAL=[$5], DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testPushDownJoinCondition">
<Resource name="sql">
<![CDATA[select *
from emp as e
join dept as d on e.deptno + 20 = d.deptno / 2]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO0=[$10], NAME=[$11])
LogicalJoin(condition=[=($9, $12)], joinType=[inner])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], $f9=[+($7, 20)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalProject(DEPTNO=[$0], NAME=[$1], $f2=[/($0, 2)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testPushDownJoinConditionWithProjectMerge">
<Resource name="sql">
<![CDATA[select * from
(select empno, deptno from emp) a
join dept b
on a.deptno + 20 = b.deptno]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], DEPTNO=[$1], DEPTNO0=[$3], NAME=[$4])
LogicalJoin(condition=[=($2, $3)], joinType=[inner])
LogicalProject(EMPNO=[$0], DEPTNO=[$7], $f2=[+($7, 20)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testQualifyInCorrelatedSubQuery">
<Resource name="sql">
<![CDATA[SELECT *
FROM emp
WHERE EXISTS(
SELECT name
FROM dept
QUALIFY RANK() OVER (PARTITION BY name
ORDER BY dept.deptno DESC) = emp.deptno
)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalFilter(condition=[IS NOT NULL($9)])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], $f0=[$11])
LogicalJoin(condition=[=($9, $10)], joinType=[left])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO0=[CAST($7):BIGINT NOT NULL])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0}], agg#0=[MIN($1)])
LogicalProject(DEPTNO0=[$2], $f0=[true])
LogicalFilter(condition=[$1])
LogicalProject(NAME=[$1], QualifyExpression=[=(RANK() OVER (PARTITION BY $1 ORDER BY $0 DESC), $2)], DEPTNO0=[$2])
LogicalJoin(condition=[true], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
LogicalAggregate(group=[{0}])
LogicalProject(DEPTNO0=[CAST($7):BIGINT NOT NULL])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testQualifyInDdl">
<Resource name="sql">
<![CDATA[INSERT INTO dept(deptno, name)
SELECT DISTINCT empno, ename
FROM emp
WHERE deptno > 5
QUALIFY RANK() OVER (PARTITION BY ename
ORDER BY slacker DESC) = 1]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, DEPT]], operation=[INSERT], flattened=[true])
LogicalAggregate(group=[{0, 1}])
LogicalProject(EMPNO=[$0], ENAME=[$1])
LogicalFilter(condition=[$2])
LogicalProject(EMPNO=[$0], ENAME=[$1], QualifyExpression=[=(RANK() OVER (PARTITION BY $1 ORDER BY $8 DESC), 1)])
LogicalFilter(condition=[>($7, 5)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testQualifyInSubQuery">
<Resource name="sql">
<![CDATA[SELECT *
FROM (
SELECT DISTINCT empno, ename, deptno
FROM emp
QUALIFY RANK() OVER (PARTITION BY ename
ORDER BY deptno DESC) = 1)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], DEPTNO=[$2])
LogicalAggregate(group=[{0, 1, 2}])
LogicalProject(EMPNO=[$0], ENAME=[$1], DEPTNO=[$2])
LogicalFilter(condition=[$3])
LogicalProject(EMPNO=[$0], ENAME=[$1], DEPTNO=[$7], QualifyExpression=[=(RANK() OVER (PARTITION BY $1 ORDER BY $7 DESC), 1)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testQualifyWithDerivedColumn">
<Resource name="sql">
<![CDATA[SELECT empno, ename, deptno, SUBSTRING(ename,1,1) as DERIVED_COLUMN FROM emp QUALIFY ROW_NUMBER() OVER (PARTITION BY deptno
ORDER BY DERIVED_COLUMN) = 1]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], DEPTNO=[$2], DERIVED_COLUMN=[$3])
LogicalFilter(condition=[$4])
LogicalProject(EMPNO=[$0], ENAME=[$1], DEPTNO=[$7], DERIVED_COLUMN=[SUBSTRING($1, 1, 1)], QualifyExpression=[=(ROW_NUMBER() OVER (PARTITION BY $7 ORDER BY SUBSTRING($1, 1, 1)), 1)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testQualifyWithEverything">
<Resource name="sql">
<![CDATA[SELECT DISTINCT empno, ename, deptno,
RANK() OVER (PARTITION BY ename
ORDER BY deptno DESC) as rank_val
FROM emp
WHERE sal > 1000
QUALIFY rank_val = (SELECT COUNT(*) FROM emp)
ORDER BY deptno
LIMIT 5]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalSort(sort0=[$2], dir0=[ASC], fetch=[5])
LogicalAggregate(group=[{0, 1, 2, 3}])
LogicalProject(EMPNO=[$0], ENAME=[$1], DEPTNO=[$2], RANK_VAL=[$3])
LogicalFilter(condition=[$5])
LogicalProject(EMPNO=[$0], ENAME=[$1], DEPTNO=[$2], RANK_VAL=[$3], EXPR$0=[$4], QualifyExpression=[=($3, $4)])
LogicalJoin(condition=[true], joinType=[left])
LogicalProject(EMPNO=[$0], ENAME=[$1], DEPTNO=[$7], RANK_VAL=[RANK() OVER (PARTITION BY $1 ORDER BY $7 DESC)])
LogicalFilter(condition=[>($5, 1000)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{}], EXPR$0=[COUNT()])
LogicalProject($f0=[0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testQualifyWithMultipleReferences">
<Resource name="sql">
<![CDATA[SELECT empno, ename, deptno + 1 as derived_deptno,
ROW_NUMBER() over (partition by ename order by deptno) as row_num
FROM emp
QUALIFY row_num = derived_deptno]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], DERIVED_DEPTNO=[$2], ROW_NUM=[$3])
LogicalFilter(condition=[$4])
LogicalProject(EMPNO=[$0], ENAME=[$1], DERIVED_DEPTNO=[+($7, 1)], ROW_NUM=[ROW_NUMBER() OVER (PARTITION BY $1 ORDER BY $7)], QualifyExpression=[=(ROW_NUMBER() OVER (PARTITION BY $1 ORDER BY $7), CAST(+($7, 1)):BIGINT NOT NULL)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testQualifyWithReferences">
<Resource name="sql">
<![CDATA[SELECT empno, ename, deptno,
ROW_NUMBER() over (partition by ename order by deptno) as row_num
FROM emp
QUALIFY row_num = 1]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], DEPTNO=[$2], ROW_NUM=[$3])
LogicalFilter(condition=[$4])
LogicalProject(EMPNO=[$0], ENAME=[$1], DEPTNO=[$7], ROW_NUM=[ROW_NUMBER() OVER (PARTITION BY $1 ORDER BY $7)], QualifyExpression=[=(ROW_NUMBER() OVER (PARTITION BY $1 ORDER BY $7), 1)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testQualifyWithSubQueryFilter">
<Resource name="sql">
<![CDATA[SELECT empno, ename, deptno,
RANK() OVER (PARTITION BY ename
ORDER BY deptno DESC) as rank_val
FROM emp
QUALIFY rank_val = (SELECT COUNT(*) FROM emp)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], DEPTNO=[$2], RANK_VAL=[$3])
LogicalFilter(condition=[$5])
LogicalProject(EMPNO=[$0], ENAME=[$1], DEPTNO=[$2], RANK_VAL=[$3], EXPR$0=[$4], QualifyExpression=[=($3, $4)])
LogicalJoin(condition=[true], joinType=[left])
LogicalProject(EMPNO=[$0], ENAME=[$1], DEPTNO=[$7], RANK_VAL=[RANK() OVER (PARTITION BY $1 ORDER BY $7 DESC)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{}], EXPR$0=[COUNT()])
LogicalProject($f0=[0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testQualifyWithWindowClause">
<Resource name="sql">
<![CDATA[SELECT empno, ename, SUM(deptno) OVER myWindow as sumDeptNo
FROM emp
WINDOW myWindow AS (PARTITION BY ename ORDER BY empno)
QUALIFY sumDeptNo = 1]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], SUMDEPTNO=[$2])
LogicalFilter(condition=[$3])
LogicalProject(EMPNO=[$0], ENAME=[$1], SUMDEPTNO=[SUM($7) OVER (PARTITION BY $1 ORDER BY $0)], QualifyExpression=[=(SUM($7) OVER (PARTITION BY $1 ORDER BY $0), 1)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testQualifyWithoutReferences">
<Resource name="sql">
<![CDATA[SELECT empno, ename, deptno
FROM emp
QUALIFY ROW_NUMBER() over (partition by ename order by deptno) = 1]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], DEPTNO=[$2])
LogicalFilter(condition=[$3])
LogicalProject(EMPNO=[$0], ENAME=[$1], DEPTNO=[$7], QualifyExpression=[=(ROW_NUMBER() OVER (PARTITION BY $1 ORDER BY $7), 1)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testQualifyWithoutReferencesAndFilter">
<Resource name="sql">
<![CDATA[SELECT empno, ename, deptno
FROM emp
WHERE deptno > 5
QUALIFY ROW_NUMBER() over (partition by ename order by deptno) = 1]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], DEPTNO=[$2])
LogicalFilter(condition=[$3])
LogicalProject(EMPNO=[$0], ENAME=[$1], DEPTNO=[$7], QualifyExpression=[=(ROW_NUMBER() OVER (PARTITION BY $1 ORDER BY $7), 1)])
LogicalFilter(condition=[>($7, 5)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testReduceConstExpr">
<Resource name="sql">
<![CDATA[select sum(case when 'y' = 'n' then ename else 0.1 end) from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{}], EXPR$0=[SUM($0)])
LogicalProject($f0=[0.1:DECIMAL(19, 9)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testReferDynamicStarInSelectOB">
<Resource name="sql">
<![CDATA[select n_nationkey, n_name
from (select * from SALES.NATION)
order by n_regionkey]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(N_NATIONKEY=[$0], N_NAME=[$1])
LogicalSort(sort0=[$2], dir0=[ASC])
LogicalProject(N_NATIONKEY=[ITEM($0, 'N_NATIONKEY')], N_NAME=[ITEM($0, 'N_NAME')], EXPR$2=[ITEM($0, 'N_REGIONKEY')])
LogicalTableScan(table=[[CATALOG, SALES, NATION]])
]]>
</Resource>
</TestCase>
<TestCase name="testReferDynamicStarInSelectWhereGB">
<Resource name="sql">
<![CDATA[select n_regionkey, count(*) as cnt from (select * from SALES.NATION) where n_nationkey > 5 group by n_regionkey]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{0}], CNT=[COUNT()])
LogicalProject(N_REGIONKEY=[ITEM($0, 'N_REGIONKEY')])
LogicalFilter(condition=[>(ITEM($0, 'N_NATIONKEY'), 5)])
LogicalProject(**=[$0])
LogicalTableScan(table=[[CATALOG, SALES, NATION]])
]]>
</Resource>
</TestCase>
<TestCase name="testRollup">
<Resource name="sql">
<![CDATA[select 1
from (values (1, 2, 3, 4)) as t(a, b, c, d)
group by rollup(a, b), rollup(c, d)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[1])
LogicalAggregate(group=[{0, 1, 2, 3}], groups=[[{0, 1, 2, 3}, {0, 1, 2}, {0, 1}, {0, 2, 3}, {0, 2}, {0}, {2, 3}, {2}, {}]])
LogicalValues(tuples=[[{ 1, 2, 3, 4 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testRollupSimple">
<Resource name="sql">
<![CDATA[select a, b, count(*) as c
from (values (cast(null as integer), 2)) as t(a, b)
group by rollup(a, b)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{0, 1}], groups=[[{0, 1}, {0}, {}]], C=[COUNT()])
LogicalValues(tuples=[[{ null, 2 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testRollupTuples">
<Resource name="sql">
<![CDATA[select 1
from (values (1, 2, 3, 4)) as t(a, b, c, d)
group by rollup(b, (a, d))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[1])
LogicalAggregate(group=[{0, 1, 2}], groups=[[{0, 1, 2}, {0}, {}]])
LogicalProject(B=[$1], A=[$0], D=[$3])
LogicalValues(tuples=[[{ 1, 2, 3, 4 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testRowValueConstructorWithSubQuery">
<Resource name="sql">
<![CDATA[select ROW((select deptno
from dept
where dept.deptno = emp.deptno), emp.ename)
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[ROW($9, $1)])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO9=[$9])
LogicalJoin(condition=[=($9, $7)], joinType=[left])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testSample">
<Resource name="sql">
<![CDATA[select * from emp tablesample substitute('DATASET1') where empno > 5]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalFilter(condition=[>($0, 5)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testSampleBernoulli">
<Resource name="sql">
<![CDATA[select * from emp tablesample bernoulli(50) where empno > 5]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalFilter(condition=[>($0, 5)])
Sample(mode=[bernoulli], rate=[0.5], repeatableSeed=[-])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testSampleBernoulliQuery">
<Resource name="sql">
<![CDATA[select * from (
select * from emp as e tablesample bernoulli(10) repeatable(1)
join dept on e.deptno = dept.deptno
) tablesample bernoulli(50) repeatable(99)
where empno > 5]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO0=[$9], NAME=[$10])
LogicalFilter(condition=[>($0, 5)])
Sample(mode=[bernoulli], rate=[0.5], repeatableSeed=[99])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO0=[$9], NAME=[$10])
LogicalJoin(condition=[=($7, $9)], joinType=[inner])
Sample(mode=[bernoulli], rate=[0.1], repeatableSeed=[1])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testSampleQuery">
<Resource name="sql">
<![CDATA[select * from (
select * from emp as e tablesample substitute('DATASET1')
join dept on e.deptno = dept.deptno
) tablesample substitute('DATASET2')
where empno > 5]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO0=[$9], NAME=[$10])
LogicalFilter(condition=[>($0, 5)])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO0=[$9], NAME=[$10])
LogicalJoin(condition=[=($7, $9)], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testSampleSystem">
<Resource name="sql">
<![CDATA[select * from emp tablesample system(50) where empno > 5]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalFilter(condition=[>($0, 5)])
Sample(mode=[system], rate=[0.5], repeatableSeed=[-])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testSampleSystemQuery">
<Resource name="sql">
<![CDATA[select * from (
select * from emp as e tablesample system(10) repeatable(1)
join dept on e.deptno = dept.deptno
) tablesample system(50) repeatable(99)
where empno > 5]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO0=[$9], NAME=[$10])
LogicalFilter(condition=[>($0, 5)])
Sample(mode=[system], rate=[0.5], repeatableSeed=[99])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], DEPTNO0=[$9], NAME=[$10])
LogicalJoin(condition=[=($7, $9)], joinType=[inner])
Sample(mode=[system], rate=[0.1], repeatableSeed=[1])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testSelectDistinct">
<Resource name="sql">
<![CDATA[select distinct sal + 5 from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{0}])
LogicalProject(EXPR$0=[+($5, 5)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testSelectDistinctDup">
<Resource name="sql">
<![CDATA[select distinct sal + 5, deptno, sal + 5 from emp where deptno < 10]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[$0], DEPTNO=[$1], EXPR$2=[$0])
LogicalAggregate(group=[{0, 1}])
LogicalProject(EXPR$0=[+($5, 5)], DEPTNO=[$7])
LogicalFilter(condition=[<($7, 10)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testSelectDistinctGroup">
<Resource name="sql">
<![CDATA[select distinct sum(sal) from emp group by deptno]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{0}])
LogicalProject(EXPR$0=[$1])
LogicalAggregate(group=[{0}], EXPR$0=[SUM($1)])
LogicalProject(DEPTNO=[$7], SAL=[$5])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testSelectDynamicStarOrderBy">
<Resource name="sql">
<![CDATA[SELECT * from SALES.NATION order by n_nationkey]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(**=[$0])
LogicalSort(sort0=[$1], dir0=[ASC])
LogicalProject(**=[$0], EXPR$1=[ITEM($0, 'N_NATIONKEY')])
LogicalTableScan(table=[[CATALOG, SALES, NATION]])
]]>
</Resource>
</TestCase>
<TestCase name="testSelectFromDynamicTable">
<Resource name="sql">
<![CDATA[select n_nationkey, n_name from SALES.NATION]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(N_NATIONKEY=[$0], N_NAME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, NATION]])
]]>
</Resource>
</TestCase>
<TestCase name="testSelectModifiableViewConstraint">
<Resource name="sql">
<![CDATA[select deptno from EMP_MODIFIABLEVIEW2
where deptno = ?]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$3])
LogicalFilter(condition=[=($3, ?0)])
LogicalTableScan(table=[[CATALOG, SALES, EMP_MODIFIABLEVIEW2]])
]]>
</Resource>
</TestCase>
<TestCase name="testSelectNestedColumnType">
<Resource name="plan">
<![CDATA[
LogicalProject(UNIT_LENGTH=[CHAR_LENGTH($3)])
LogicalFilter(condition=[=($0, 'john')])
LogicalProject(FNAME=[$1], COORD=[$4], COORD2=[$5], COORD3=[$6])
LogicalFilter(condition=[AND(>($4, 1), >($5, 1))])
LogicalProject(CONTACTNO=[$0], FNAME=[$1], LNAME=[$2], EMAIL=[$3], X=[$4.X], Y=[$4.Y], unit=[$4.unit], M=[$5.M], A=[$5.SUB.A], B=[$5.SUB.B])
LogicalTableScan(table=[[CATALOG, CUSTOMER, CONTACT_PEEK]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select
char_length(coord."unit") as unit_length
from
(
select
fname,
coord
from
customer.contact_peek
where
coord.x > 1
and coord.y > 1
) as view
where
fname = 'john']]>
</Resource>
</TestCase>
<TestCase name="testSelectNull">
<Resource name="sql">
<![CDATA[select null from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[null:NULL])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testSelectNullWithAlias">
<Resource name="sql">
<![CDATA[select null as dummy from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DUMMY=[null:NULL])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testSelectNullWithCast">
<Resource name="sql">
<![CDATA[select cast(null as timestamp) dummy from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DUMMY=[null:TIMESTAMP(0)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testSelectOverDistinct">
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[CASE(>(COUNT(DISTINCT $7) OVER (ORDER BY $0 ROWS 10 PRECEDING), 0), $SUM0(DISTINCT $7) OVER (ORDER BY $0 ROWS 10 PRECEDING), null:INTEGER)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select SUM(DISTINCT deptno)
over (ORDER BY empno ROWS BETWEEN 10 PRECEDING AND CURRENT ROW)
from emp
]]>
</Resource>
</TestCase>
<TestCase name="testSelectStarFromDynamicTable">
<Resource name="sql">
<![CDATA[select * from SALES.NATION]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(**=[$0])
LogicalTableScan(table=[[CATALOG, SALES, NATION]])
]]>
</Resource>
</TestCase>
<TestCase name="testSelectStreamPartitionDistinct">
<Resource name="plan">
<![CDATA[
LogicalDelta
LogicalProject(C=[COUNT(DISTINCT $2) OVER (PARTITION BY $1 ORDER BY $0 RANGE 1000:INTERVAL SECOND PRECEDING)], C2=[COUNT(DISTINCT $2) OVER (PARTITION BY $1 ORDER BY $0 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)], C3=[COUNT($2) OVER (PARTITION BY $1 ORDER BY $0 RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)])
LogicalTableScan(table=[[CATALOG, SALES, ORDERS]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select stream
count(distinct orderId) over (partition by productId
order by rowtime
range interval '1' second preceding) as c,
count(distinct orderId) over w as c2,
count(orderId) over w as c3
from orders
window w as (partition by productId)]]>
</Resource>
</TestCase>
<TestCase name="testSelectView">
<Resource name="sql">
<![CDATA[select * from emp_20 where empno > 100]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], SLACKER=[$7])
LogicalFilter(condition=[>($0, 100)])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], SLACKER=[$8])
LogicalFilter(condition=[AND(=($7, 20), >($5, 1000))])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testSelectViewExtendedColumnCaseSensitiveCollision">
<Resource name="sql">
<![CDATA[select ENAME, EMPNO, JOB, SLACKER, "sal", HIREDATE, MGR
from EMP_MODIFIABLEVIEW3 extend ("sal" boolean)
where "sal" = true]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ENAME=[$1], EMPNO=[$0], JOB=[$2], SLACKER=[$6], sal=[$7], HIREDATE=[$4], MGR=[$3])
LogicalFilter(condition=[=($7, true)])
LogicalTableScan(table=[[CATALOG, SALES, EMP_MODIFIABLEVIEW3]])
]]>
</Resource>
</TestCase>
<TestCase name="testSelectViewExtendedColumnCaseSensitiveExtendedCollision">
<Resource name="sql">
<![CDATA[select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE, "extra"
from EMP_MODIFIABLEVIEW2 extend ("extra" boolean)
where "extra" = false]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ENAME=[$0], EMPNO=[$1], JOB=[$2], SLACKER=[$4], SAL=[$5], HIREDATE=[$7], extra=[$10])
LogicalFilter(condition=[=($10, false)])
LogicalTableScan(table=[[CATALOG, SALES, EMP_MODIFIABLEVIEW2]])
]]>
</Resource>
</TestCase>
<TestCase name="testSelectViewExtendedColumnCaseSensitiveUnderlyingCollision">
<Resource name="sql">
<![CDATA[select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE, MGR, "comm"
from EMP_MODIFIABLEVIEW3 extend ("comm" int)
where "comm" = 20]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ENAME=[$1], EMPNO=[$0], JOB=[$2], SLACKER=[$6], SAL=[$5], HIREDATE=[$4], MGR=[$3], comm=[$7])
LogicalFilter(condition=[=($7, 20)])
LogicalTableScan(table=[[CATALOG, SALES, EMP_MODIFIABLEVIEW3]])
]]>
</Resource>
</TestCase>
<TestCase name="testSelectViewExtendedColumnCollision">
<Resource name="sql">
<![CDATA[select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE, MGR
from EMP_MODIFIABLEVIEW3 extend (SAL int)
where SAL = 20]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ENAME=[$1], EMPNO=[$0], JOB=[$2], SLACKER=[$6], SAL=[$5], HIREDATE=[$4], MGR=[$3])
LogicalFilter(condition=[=($5, 20)])
LogicalTableScan(table=[[CATALOG, SALES, EMP_MODIFIABLEVIEW3]])
]]>
</Resource>
</TestCase>
<TestCase name="testSelectViewExtendedColumnExtendedCollision">
<Resource name="sql">
<![CDATA[select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE, EXTRA
from EMP_MODIFIABLEVIEW2 extend (EXTRA boolean)
where SAL = 20]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ENAME=[$0], EMPNO=[$1], JOB=[$2], SLACKER=[$4], SAL=[$5], HIREDATE=[$7], EXTRA=[$6])
LogicalFilter(condition=[=($5, 20)])
LogicalTableScan(table=[[CATALOG, SALES, EMP_MODIFIABLEVIEW2]])
]]>
</Resource>
</TestCase>
<TestCase name="testSelectViewExtendedColumnUnderlyingCollision">
<Resource name="sql">
<![CDATA[select ENAME, EMPNO, JOB, SLACKER, SAL, HIREDATE, MGR, COMM
from EMP_MODIFIABLEVIEW3 extend (COMM int)
where SAL = 20]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ENAME=[$1], EMPNO=[$0], JOB=[$2], SLACKER=[$6], SAL=[$5], HIREDATE=[$4], MGR=[$3], COMM=[$7])
LogicalFilter(condition=[=($5, 20)])
LogicalTableScan(table=[[CATALOG, SALES, EMP_MODIFIABLEVIEW3]])
]]>
</Resource>
</TestCase>
<TestCase name="testSelectWithoutFrom">
<Resource name="sql">
<![CDATA[select 2+2]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[+(2, 2)])
LogicalValues(tuples=[[{ 0 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testSessionTable">
<Resource name="sql">
<![CDATA[select stream session_start(rowtime, interval '1' hour) as rowtime,
session_end(rowtime, interval '1' hour),
count(*) as c
from orders
group by session(rowtime, interval '1' hour)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalDelta
LogicalProject(ROWTIME=[$0], EXPR$1=[$0], C=[$1])
LogicalAggregate(group=[{0}], C=[COUNT()])
LogicalProject($f0=[$SESSION($0, 3600000:INTERVAL HOUR)])
LogicalTableScan(table=[[CATALOG, SALES, ORDERS]])
]]>
</Resource>
</TestCase>
<TestCase name="testSimplifyExistsAggregateSubQuery">
<Resource name="sql">
<![CDATA[SELECT e1.empno
FROM emp e1 where exists
(select avg(sal) from emp e2 where e1.empno = e2.empno)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testSimplifyExistsValuesSubQuery">
<Resource name="sql">
<![CDATA[select deptno
from EMP
where exists (values 10)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testSimplifyNotExistsAggregateSubQuery">
<Resource name="sql">
<![CDATA[SELECT e1.empno
FROM emp e1 where not exists
(select avg(sal) from emp e2 where e1.empno = e2.empno)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0])
LogicalFilter(condition=[NOT(true)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testSimplifyNotExistsValuesSubQuery">
<Resource name="sql">
<![CDATA[select deptno
from EMP
where not exists (values 10)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$7])
LogicalFilter(condition=[NOT(true)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testSingletonGroupingSet">
<Resource name="sql">
<![CDATA[select sum(sal) from emp group by grouping sets (deptno)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[$1])
LogicalAggregate(group=[{0}], EXPR$0=[SUM($1)])
LogicalProject(DEPTNO=[$7], SAL=[$5])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testSnapshotOnTemporalTable1">
<Resource name="sql">
<![CDATA[select * from products_temporal for system_time as of TIMESTAMP '2011-01-02 00:00:00']]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(PRODUCTID=[$0], NAME=[$1], SUPPLIERID=[$2], SYS_START=[$3], SYS_END=[$4], SYS_START_LOCAL_TIMESTAMP=[$5], SYS_END_LOCAL_TIMESTAMP=[$6])
LogicalSnapshot(period=[2011-01-02 00:00:00])
LogicalTableScan(table=[[CATALOG, SALES, PRODUCTS_TEMPORAL]])
]]>
</Resource>
</TestCase>
<TestCase name="testSnapshotOnTemporalTable2">
<Resource name="sql">
<![CDATA[select * from VIRTUALCOLUMNS.VC_T1 for system_time as of TIMESTAMP '2011-01-02 00:00:00']]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(A=[$0], B=[$1], C=[$2], D=[$3], E=[$4])
LogicalSnapshot(period=[2011-01-02 00:00:00])
LogicalProject(A=[$0], B=[$1], C=[$2], D=[$3], $f4=[+($0, 1)])
LogicalTableScan(table=[[CATALOG, VIRTUALCOLUMNS, VC_T1]])
]]>
</Resource>
</TestCase>
<TestCase name="testSome">
<Resource name="sql">
<![CDATA[select empno from emp where deptno > some (
select deptno from dept)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0])
LogicalFilter(condition=[> SOME($7, {
LogicalProject(DEPTNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
})])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testSomeAndEveryAggregateFunctions">
<Resource name="sql">
<![CDATA[SELECT some(empno = 130) as someempnoexists,
every(empno > 0) as everyempnogtzero
FROM emp AS e group by e.sal]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(SOMEEMPNOEXISTS=[$1], EVERYEMPNOGTZERO=[$2])
LogicalAggregate(group=[{0}], SOMEEMPNOEXISTS=[SOME($1)], EVERYEMPNOGTZERO=[EVERY($2)])
LogicalProject(SAL=[$5], $f1=[=($0, 130)], $f2=[>($0, 0)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testSomeValueList">
<Resource name="sql">
<![CDATA[select empno from emp where deptno > some (10, 20)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0])
LogicalFilter(condition=[OR(>($7, 10), >($7, 20))])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testSomeWithEquality">
<Resource name="sql">
<![CDATA[select empno from emp where deptno = some (
select deptno from dept)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0])
LogicalFilter(condition=[IN($7, {
LogicalProject(DEPTNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
})])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testSomeWithNotEquality">
<Resource name="sql">
<![CDATA[select empno from emp where deptno <> some (
select deptno from dept)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0])
LogicalFilter(condition=[<> SOME($7, {
LogicalProject(DEPTNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
})])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testSortInSubQuery">
<Resource name="sql">
<![CDATA[select * from (select empno from emp order by empno)]]>
</Resource>
<Resource name="planRemoveSort">
<![CDATA[
LogicalProject(EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="planKeepSort">
<![CDATA[
LogicalProject(EMPNO=[$0])
LogicalSort(sort0=[$0], dir0=[ASC])
LogicalProject(EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testSortLimitWithCorrelateInput">
<Resource name="sql">
<![CDATA[SELECT deptno, ename
FROM
(SELECT DISTINCT deptno FROM emp) t1,
LATERAL (
SELECT ename, sal
FROM emp
WHERE deptno = t1.deptno)
ORDER BY ename DESC
LIMIT 3]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalSort(sort0=[$1], dir0=[DESC], fetch=[3])
LogicalProject(DEPTNO=[$0], ENAME=[$1])
LogicalJoin(condition=[=($0, $3)], joinType=[inner])
LogicalAggregate(group=[{0}])
LogicalProject(DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalProject(ENAME=[$1], SAL=[$5], DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testSortWithTrim">
<Resource name="sql">
<![CDATA[select ename from (select * from emp order by sal) a]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ENAME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testStarDynamicSchemaUnnest">
<Resource name="sql">
<![CDATA[select *
from SALES.CUSTOMER as t1,
lateral (select t2 as fake_col3
from unnest(t1.fake_col) as t2) as t3]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(**=[$1], FAKE_COL3=[$2])
LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{0}])
LogicalTableScan(table=[[CATALOG, SALES, CUSTOMER]])
LogicalProject(FAKE_COL3=[$0])
Uncollect
LogicalProject(FAKE_COL=[$cor0.FAKE_COL])
LogicalValues(tuples=[[{ 0 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testStarDynamicSchemaUnnest2">
<Resource name="sql">
<![CDATA[select *
from SALES.CUSTOMER as t1,
unnest(t1.fake_col) as t2]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(**=[$1], T2=[$2])
LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{0}])
LogicalTableScan(table=[[CATALOG, SALES, CUSTOMER]])
Uncollect
LogicalProject(FAKE_COL=[$cor0.FAKE_COL])
LogicalValues(tuples=[[{ 0 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testStarDynamicSchemaUnnestNestedSubQuery">
<Resource name="sql">
<![CDATA[select t2.c1
from (select * from SALES.CUSTOMER) as t1,
unnest(t1.fake_col) as t2(c1)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(C1=[$1])
LogicalProject(**=[$0], C1=[$2])
LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{1}])
LogicalProject(**=[$0], $f1=[ITEM($0, 'FAKE_COL')])
LogicalTableScan(table=[[CATALOG, SALES, CUSTOMER]])
LogicalProject(C1=[$0])
Uncollect
LogicalProject(EXPR$0=[$cor0.$f1])
LogicalValues(tuples=[[{ 0 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testStarJoinStaticDynTable">
<Resource name="sql">
<![CDATA[select * from SALES.NATION N, SALES.REGION as R where N.n_regionkey = R.r_regionkey]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(**=[$1], R_REGIONKEY=[$2], R_NAME=[$3], R_COMMENT=[$4])
LogicalFilter(condition=[=($0, $2)])
LogicalJoin(condition=[true], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, NATION]])
LogicalTableScan(table=[[CATALOG, SALES, REGION]])
]]>
</Resource>
</TestCase>
<TestCase name="testStream">
<Resource name="sql">
<![CDATA[select stream productId from orders where productId = 10]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalDelta
LogicalProject(PRODUCTID=[$1])
LogicalFilter(condition=[=($1, 10)])
LogicalTableScan(table=[[CATALOG, SALES, ORDERS]])
]]>
</Resource>
</TestCase>
<TestCase name="testStreamGroupBy">
<Resource name="sql">
<![CDATA[select stream
floor(rowtime to second) as rowtime, count(*) as c
from orders
group by floor(rowtime to second)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalDelta
LogicalAggregate(group=[{0}], C=[COUNT()])
LogicalProject(ROWTIME=[FLOOR($0, FLAG(SECOND))])
LogicalTableScan(table=[[CATALOG, SALES, ORDERS]])
]]>
</Resource>
</TestCase>
<TestCase name="testStreamWindowedAggregation">
<Resource name="sql">
<![CDATA[select stream *,
count(*) over (partition by productId
order by rowtime
range interval '1' second preceding) as c
from orders]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalDelta
LogicalProject(ROWTIME=[$0], PRODUCTID=[$1], ORDERID=[$2], C=[COUNT() OVER (PARTITION BY $1 ORDER BY $0 RANGE 1000:INTERVAL SECOND PRECEDING)])
LogicalTableScan(table=[[CATALOG, SALES, ORDERS]])
]]>
</Resource>
</TestCase>
<TestCase name="testStructTypeAlias">
<Resource name="sql">
<![CDATA[select t.r AS myRow
from (select row(row(1)) r from dept) t]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(MYROW=[ROW(ROW(1))])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testSubQueryAggregateFunctionFollowedBySimpleOperation">
<Resource name="sql">
<![CDATA[select deptno
from EMP
where deptno > (select min(deptno) * 2 + 10 from EMP)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$7])
LogicalFilter(condition=[>($7, $9)])
LogicalJoin(condition=[true], joinType=[left])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalProject(EXPR$0=[+(*($0, 2), 10)])
LogicalAggregate(group=[{}], agg#0=[MIN($0)])
LogicalProject(DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testSubQueryLimitOne">
<Resource name="sql">
<![CDATA[select deptno
from EMP
where deptno > (select deptno
from EMP order by deptno limit 1)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$7])
LogicalFilter(condition=[>($7, $9)])
LogicalJoin(condition=[true], joinType=[left])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalSort(sort0=[$0], dir0=[ASC], fetch=[1])
LogicalProject(DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testSubQueryNoExpand">
<Resource name="sql">
<![CDATA[select (select empno from EMP where 1 = 0)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[$SCALAR_QUERY({
LogicalProject(EMPNO=[$0])
LogicalFilter(condition=[=(1, 0)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
})])
LogicalValues(tuples=[[{ 0 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testSubQueryOr">
<Resource name="sql">
<![CDATA[select * from emp where deptno = 10 or deptno in (
select dept.deptno from dept where deptno < 5)
]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalFilter(condition=[OR(=($7, 10), IN($7, {
LogicalProject(DEPTNO=[$0])
LogicalFilter(condition=[<($0, 5)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
}))])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testSubQueryValues">
<Resource name="sql">
<![CDATA[select deptno
from EMP
where deptno > (values 10)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$7])
LogicalFilter(condition=[>($7, $9)])
LogicalJoin(condition=[true], joinType=[left])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalValues(tuples=[[{ 10 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testTableExpression">
<Resource name="sql">
<![CDATA[select deptno + deptno from dept]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[+($0, $0)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testTableExtend">
<Resource name="sql">
<![CDATA[select * from dept extend (x varchar(5) not null)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], NAME=[$1], X=[$2])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testTableExtendExpression">
<Resource name="sql">
<![CDATA[select deptno + x from dept extend (x int not null)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[+($0, $2)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testTableExtendSubset">
<Resource name="sql">
<![CDATA[select deptno, x from dept extend (x int)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], X=[$2])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testTableFunctionHop">
<Resource name="sql">
<![CDATA[select *
from table(hop(table Shipments, descriptor(rowtime), INTERVAL '1' MINUTE, INTERVAL '2' MINUTE))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ORDERID=[$0], ROWTIME=[$1], window_start=[$2], window_end=[$3])
LogicalTableFunctionScan(invocation=[HOP(DESCRIPTOR($1), 60000:INTERVAL MINUTE, 120000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER ORDERID, TIMESTAMP(0) ROWTIME, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end)])
LogicalProject(ORDERID=[$0], ROWTIME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, SHIPMENTS]])
]]>
</Resource>
</TestCase>
<TestCase name="testTableFunctionHopWithOffset">
<Resource name="sql">
<![CDATA[select *
from table(hop(table Shipments, descriptor(rowtime), INTERVAL '1' MINUTE, INTERVAL '5' MINUTE, INTERVAL '3' MINUTE))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ORDERID=[$0], ROWTIME=[$1], window_start=[$2], window_end=[$3])
LogicalTableFunctionScan(invocation=[HOP(DESCRIPTOR($1), 60000:INTERVAL MINUTE, 300000:INTERVAL MINUTE, 180000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER ORDERID, TIMESTAMP(0) ROWTIME, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end)])
LogicalProject(ORDERID=[$0], ROWTIME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, SHIPMENTS]])
]]>
</Resource>
</TestCase>
<TestCase name="testTableFunctionHopWithParamNames">
<Resource name="sql">
<![CDATA[select *
from table(
hop(
DATA => table Shipments,
TIMECOL => descriptor(rowtime),
SLIDE => INTERVAL '1' MINUTE,
SIZE => INTERVAL '2' MINUTE))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ORDERID=[$0], ROWTIME=[$1], window_start=[$2], window_end=[$3])
LogicalTableFunctionScan(invocation=[HOP(DESCRIPTOR($1), 60000:INTERVAL MINUTE, 120000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER ORDERID, TIMESTAMP(0) ROWTIME, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end)])
LogicalProject(ORDERID=[$0], ROWTIME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, SHIPMENTS]])
]]>
</Resource>
</TestCase>
<TestCase name="testTableFunctionHopWithParamReordered">
<Resource name="sql">
<![CDATA[select *
from table(
hop(
DATA => table Shipments,
SLIDE => INTERVAL '1' MINUTE,
TIMECOL => descriptor(rowtime),
SIZE => INTERVAL '2' MINUTE))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ORDERID=[$0], ROWTIME=[$1], window_start=[$2], window_end=[$3])
LogicalTableFunctionScan(invocation=[HOP(DESCRIPTOR($1), 60000:INTERVAL MINUTE, 120000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER ORDERID, TIMESTAMP(0) ROWTIME, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end)])
LogicalProject(ORDERID=[$0], ROWTIME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, SHIPMENTS]])
]]>
</Resource>
</TestCase>
<TestCase name="testTableFunctionHopWithSubQueryParam">
<Resource name="sql">
<![CDATA[select *
from table(hop((select * from Shipments), descriptor(rowtime), INTERVAL '1' MINUTE, INTERVAL '2' MINUTE))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ORDERID=[$0], ROWTIME=[$1], window_start=[$2], window_end=[$3])
LogicalTableFunctionScan(invocation=[HOP(DESCRIPTOR($1), 60000:INTERVAL MINUTE, 120000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER ORDERID, TIMESTAMP(0) ROWTIME, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end)])
LogicalProject(ORDERID=[$0], ROWTIME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, SHIPMENTS]])
]]>
</Resource>
</TestCase>
<TestCase name="testTableFunctionSession">
<Resource name="sql">
<![CDATA[select *
from table(session(table Shipments, descriptor(rowtime), descriptor(orderId), INTERVAL '10' MINUTE))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ORDERID=[$0], ROWTIME=[$1], window_start=[$2], window_end=[$3])
LogicalTableFunctionScan(invocation=[SESSION(DESCRIPTOR($1), DESCRIPTOR($0), 600000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER ORDERID, TIMESTAMP(0) ROWTIME, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end)])
LogicalProject(ORDERID=[$0], ROWTIME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, SHIPMENTS]])
]]>
</Resource>
</TestCase>
<TestCase name="testTableFunctionSessionCompoundSessionKey">
<Resource name="sql">
<![CDATA[select *
from table(session(table Orders, descriptor(rowtime), descriptor(orderId, productId), INTERVAL '10' MINUTE))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ROWTIME=[$0], PRODUCTID=[$1], ORDERID=[$2], window_start=[$3], window_end=[$4])
LogicalTableFunctionScan(invocation=[SESSION(DESCRIPTOR($0), DESCRIPTOR($2, $1), 600000:INTERVAL MINUTE)], rowType=[RecordType(TIMESTAMP(0) ROWTIME, INTEGER PRODUCTID, INTEGER ORDERID, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end)])
LogicalProject(ROWTIME=[$0], PRODUCTID=[$1], ORDERID=[$2])
LogicalTableScan(table=[[CATALOG, SALES, ORDERS]])
]]>
</Resource>
</TestCase>
<TestCase name="testTableFunctionSessionWithParamNames">
<Resource name="sql">
<![CDATA[select *
from table(
session(
DATA => table Shipments,
TIMECOL => descriptor(rowtime),
KEY => descriptor(orderId),
SIZE => INTERVAL '10' MINUTE))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ORDERID=[$0], ROWTIME=[$1], window_start=[$2], window_end=[$3])
LogicalTableFunctionScan(invocation=[SESSION(DESCRIPTOR($1), DESCRIPTOR($0), 600000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER ORDERID, TIMESTAMP(0) ROWTIME, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end)])
LogicalProject(ORDERID=[$0], ROWTIME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, SHIPMENTS]])
]]>
</Resource>
</TestCase>
<TestCase name="testTableFunctionSessionWithParamReordered">
<Resource name="sql">
<![CDATA[select *
from table(
session(
DATA => table Shipments,
KEY => descriptor(orderId),
TIMECOL => descriptor(rowtime),
SIZE => INTERVAL '10' MINUTE))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ORDERID=[$0], ROWTIME=[$1], window_start=[$2], window_end=[$3])
LogicalTableFunctionScan(invocation=[SESSION(DESCRIPTOR($1), DESCRIPTOR($0), 600000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER ORDERID, TIMESTAMP(0) ROWTIME, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end)])
LogicalProject(ORDERID=[$0], ROWTIME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, SHIPMENTS]])
]]>
</Resource>
</TestCase>
<TestCase name="testTableFunctionSessionWithSubQueryParam">
<Resource name="sql">
<![CDATA[select *
from table(session((select * from Shipments), descriptor(rowtime), descriptor(orderId), INTERVAL '10' MINUTE))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ORDERID=[$0], ROWTIME=[$1], window_start=[$2], window_end=[$3])
LogicalTableFunctionScan(invocation=[SESSION(DESCRIPTOR($1), DESCRIPTOR($0), 600000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER ORDERID, TIMESTAMP(0) ROWTIME, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end)])
LogicalProject(ORDERID=[$0], ROWTIME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, SHIPMENTS]])
]]>
</Resource>
</TestCase>
<TestCase name="testTableFunctionTumble">
<Resource name="sql">
<![CDATA[select *
from table(tumble(table Shipments, descriptor(rowtime), INTERVAL '1' MINUTE))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ORDERID=[$0], ROWTIME=[$1], window_start=[$2], window_end=[$3])
LogicalTableFunctionScan(invocation=[TUMBLE(DESCRIPTOR($1), 60000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER ORDERID, TIMESTAMP(0) ROWTIME, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end)])
LogicalProject(ORDERID=[$0], ROWTIME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, SHIPMENTS]])
]]>
</Resource>
</TestCase>
<TestCase name="testTableFunctionTumbleWithInnerJoin">
<Resource name="sql">
<![CDATA[select *
from table(tumble(table Shipments, descriptor(rowtime), INTERVAL '1' MINUTE)) a
join table(tumble(table Shipments, descriptor(rowtime), INTERVAL '1' MINUTE)) b
on a.orderid = b.orderid]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ORDERID=[$0], ROWTIME=[$1], window_start=[$2], window_end=[$3], ORDERID0=[$4], ROWTIME0=[$5], window_start0=[$6], window_end0=[$7])
LogicalJoin(condition=[=($0, $4)], joinType=[inner])
LogicalTableFunctionScan(invocation=[TUMBLE(DESCRIPTOR($1), 60000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER ORDERID, TIMESTAMP(0) ROWTIME, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end)])
LogicalProject(ORDERID=[$0], ROWTIME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, SHIPMENTS]])
LogicalTableFunctionScan(invocation=[TUMBLE(DESCRIPTOR($1), 60000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER ORDERID, TIMESTAMP(0) ROWTIME, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end)])
LogicalProject(ORDERID=[$0], ROWTIME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, SHIPMENTS]])
]]>
</Resource>
</TestCase>
<TestCase name="testTableFunctionTumbleWithOffset">
<Resource name="sql">
<![CDATA[select *
from table(tumble(table Shipments, descriptor(rowtime),
INTERVAL '10' MINUTE, INTERVAL '1' MINUTE))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ORDERID=[$0], ROWTIME=[$1], window_start=[$2], window_end=[$3])
LogicalTableFunctionScan(invocation=[TUMBLE(DESCRIPTOR($1), 600000:INTERVAL MINUTE, 60000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER ORDERID, TIMESTAMP(0) ROWTIME, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end)])
LogicalProject(ORDERID=[$0], ROWTIME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, SHIPMENTS]])
]]>
</Resource>
</TestCase>
<TestCase name="testTableFunctionTumbleWithParamNames">
<Resource name="sql">
<![CDATA[select *
from table(
tumble(
DATA => table Shipments,
TIMECOL => descriptor(rowtime),
SIZE => INTERVAL '1' MINUTE))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ORDERID=[$0], ROWTIME=[$1], window_start=[$2], window_end=[$3])
LogicalTableFunctionScan(invocation=[TUMBLE(DESCRIPTOR($1), 60000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER ORDERID, TIMESTAMP(0) ROWTIME, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end)])
LogicalProject(ORDERID=[$0], ROWTIME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, SHIPMENTS]])
]]>
</Resource>
</TestCase>
<TestCase name="testTableFunctionTumbleWithParamReordered">
<Resource name="sql">
<![CDATA[select *
from table(
tumble(
DATA => table Shipments,
SIZE => INTERVAL '1' MINUTE,
TIMECOL => descriptor(rowtime)))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ORDERID=[$0], ROWTIME=[$1], window_start=[$2], window_end=[$3])
LogicalTableFunctionScan(invocation=[TUMBLE(DESCRIPTOR($1), 60000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER ORDERID, TIMESTAMP(0) ROWTIME, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end)])
LogicalProject(ORDERID=[$0], ROWTIME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, SHIPMENTS]])
]]>
</Resource>
</TestCase>
<TestCase name="testTableFunctionTumbleWithSubQueryParam">
<Resource name="sql">
<![CDATA[select *
from table(tumble((select * from Shipments), descriptor(rowtime), INTERVAL '1' MINUTE))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ORDERID=[$0], ROWTIME=[$1], window_start=[$2], window_end=[$3])
LogicalTableFunctionScan(invocation=[TUMBLE(DESCRIPTOR($1), 60000:INTERVAL MINUTE)], rowType=[RecordType(INTEGER ORDERID, TIMESTAMP(0) ROWTIME, TIMESTAMP(3) window_start, TIMESTAMP(3) window_end)])
LogicalProject(ORDERID=[$0], ROWTIME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, SHIPMENTS]])
]]>
</Resource>
</TestCase>
<TestCase name="testTableFunctionWithComplexOrderBy">
<Resource name="sql">
<![CDATA[select *
from table(topn(table orders order by (orderId desc, productid desc nulls last), 3))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ROWTIME=[$0], PRODUCTID=[$1], ORDERID=[$2], RANK_NUMBER=[$3])
LogicalTableFunctionScan(invocation=[TOPN(3)], rowType=[RecordType(TIMESTAMP(0) ROWTIME, INTEGER PRODUCTID, INTEGER ORDERID, BIGINT RANK_NUMBER)])
LogicalSortExchange(distribution=[single], collation=[[2 DESC, 1 DESC-nulls-last]])
LogicalProject(ROWTIME=[$0], PRODUCTID=[$1], ORDERID=[$2])
LogicalTableScan(table=[[CATALOG, SALES, ORDERS]])
]]>
</Resource>
</TestCase>
<TestCase name="testTableFunctionWithMultipleInputTables">
<Resource name="sql">
<![CDATA[select *
from table(
similarlity(
table emp partition by deptno order by empno nulls first,
table emp_b partition by deptno order by empno nulls first))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(VAL=[$0])
LogicalTableFunctionScan(invocation=[SIMILARLITY()], rowType=[RecordType(DECIMAL(5, 2) VAL)])
LogicalSortExchange(distribution=[hash[7]], collation=[[0 ASC-nulls-first]])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalSortExchange(distribution=[hash[7]], collation=[[0 ASC-nulls-first]])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], BIRTHDATE=[$9])
LogicalTableScan(table=[[CATALOG, SALES, EMP_B]])
]]>
</Resource>
</TestCase>
<TestCase name="testTableFunctionWithMultipleInputTablesWithParamNames">
<Resource name="sql">
<![CDATA[select *
from table(
similarlity(
LTABLE => table emp partition by deptno order by empno nulls first,
RTABLE => table emp_b partition by deptno order by empno nulls first))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(VAL=[$0])
LogicalTableFunctionScan(invocation=[SIMILARLITY()], rowType=[RecordType(DECIMAL(5, 2) VAL)])
LogicalSortExchange(distribution=[hash[7]], collation=[[0 ASC-nulls-first]])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalSortExchange(distribution=[hash[7]], collation=[[0 ASC-nulls-first]])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], BIRTHDATE=[$9])
LogicalTableScan(table=[[CATALOG, SALES, EMP_B]])
]]>
</Resource>
</TestCase>
<TestCase name="testTableFunctionWithMultipleOrderKeys">
<Resource name="sql">
<![CDATA[select *
from table(topn(table orders order by (orderId, productid), 3))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ROWTIME=[$0], PRODUCTID=[$1], ORDERID=[$2], RANK_NUMBER=[$3])
LogicalTableFunctionScan(invocation=[TOPN(3)], rowType=[RecordType(TIMESTAMP(0) ROWTIME, INTEGER PRODUCTID, INTEGER ORDERID, BIGINT RANK_NUMBER)])
LogicalSortExchange(distribution=[single], collation=[[2, 1]])
LogicalProject(ROWTIME=[$0], PRODUCTID=[$1], ORDERID=[$2])
LogicalTableScan(table=[[CATALOG, SALES, ORDERS]])
]]>
</Resource>
</TestCase>
<TestCase name="testTableFunctionWithMultiplePartitionKeys">
<Resource name="sql">
<![CDATA[select *
from table(topn(table orders partition by (orderId, productid), 3))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ROWTIME=[$0], PRODUCTID=[$1], ORDERID=[$2], RANK_NUMBER=[$3])
LogicalTableFunctionScan(invocation=[TOPN(3)], rowType=[RecordType(TIMESTAMP(0) ROWTIME, INTEGER PRODUCTID, INTEGER ORDERID, BIGINT RANK_NUMBER)])
LogicalExchange(distribution=[hash[1, 2]])
LogicalProject(ROWTIME=[$0], PRODUCTID=[$1], ORDERID=[$2])
LogicalTableScan(table=[[CATALOG, SALES, ORDERS]])
]]>
</Resource>
</TestCase>
<TestCase name="testTableFunctionWithOrderByWithNullLast">
<Resource name="sql">
<![CDATA[select *
from table(topn(table orders order by orderId desc nulls last, 3))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ROWTIME=[$0], PRODUCTID=[$1], ORDERID=[$2], RANK_NUMBER=[$3])
LogicalTableFunctionScan(invocation=[TOPN(3)], rowType=[RecordType(TIMESTAMP(0) ROWTIME, INTEGER PRODUCTID, INTEGER ORDERID, BIGINT RANK_NUMBER)])
LogicalSortExchange(distribution=[single], collation=[[2 DESC-nulls-last]])
LogicalProject(ROWTIME=[$0], PRODUCTID=[$1], ORDERID=[$2])
LogicalTableScan(table=[[CATALOG, SALES, ORDERS]])
]]>
</Resource>
</TestCase>
<TestCase name="testTableFunctionWithOrderKey">
<Resource name="sql">
<![CDATA[select *
from table(topn(table orders order by orderId, 3))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ROWTIME=[$0], PRODUCTID=[$1], ORDERID=[$2], RANK_NUMBER=[$3])
LogicalTableFunctionScan(invocation=[TOPN(3)], rowType=[RecordType(TIMESTAMP(0) ROWTIME, INTEGER PRODUCTID, INTEGER ORDERID, BIGINT RANK_NUMBER)])
LogicalSortExchange(distribution=[single], collation=[[2]])
LogicalProject(ROWTIME=[$0], PRODUCTID=[$1], ORDERID=[$2])
LogicalTableScan(table=[[CATALOG, SALES, ORDERS]])
]]>
</Resource>
</TestCase>
<TestCase name="testTableFunctionWithParamNames">
<Resource name="sql">
<![CDATA[select *
from table(
topn(
DATA => table orders partition by productid order by orderId,
COL => 3))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ROWTIME=[$0], PRODUCTID=[$1], ORDERID=[$2], RANK_NUMBER=[$3])
LogicalTableFunctionScan(invocation=[TOPN(3)], rowType=[RecordType(TIMESTAMP(0) ROWTIME, INTEGER PRODUCTID, INTEGER ORDERID, BIGINT RANK_NUMBER)])
LogicalSortExchange(distribution=[hash[1]], collation=[[2]])
LogicalProject(ROWTIME=[$0], PRODUCTID=[$1], ORDERID=[$2])
LogicalTableScan(table=[[CATALOG, SALES, ORDERS]])
]]>
</Resource>
</TestCase>
<TestCase name="testTableFunctionWithPartitionKey">
<Resource name="sql">
<![CDATA[select *
from table(topn(table orders partition by productid, 3))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ROWTIME=[$0], PRODUCTID=[$1], ORDERID=[$2], RANK_NUMBER=[$3])
LogicalTableFunctionScan(invocation=[TOPN(3)], rowType=[RecordType(TIMESTAMP(0) ROWTIME, INTEGER PRODUCTID, INTEGER ORDERID, BIGINT RANK_NUMBER)])
LogicalExchange(distribution=[hash[1]])
LogicalProject(ROWTIME=[$0], PRODUCTID=[$1], ORDERID=[$2])
LogicalTableScan(table=[[CATALOG, SALES, ORDERS]])
]]>
</Resource>
</TestCase>
<TestCase name="testTableFunctionWithPartitionKeyAndOrderKey">
<Resource name="sql">
<![CDATA[select *
from table(topn(table orders partition by productid order by orderId, 3))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ROWTIME=[$0], PRODUCTID=[$1], ORDERID=[$2], RANK_NUMBER=[$3])
LogicalTableFunctionScan(invocation=[TOPN(3)], rowType=[RecordType(TIMESTAMP(0) ROWTIME, INTEGER PRODUCTID, INTEGER ORDERID, BIGINT RANK_NUMBER)])
LogicalSortExchange(distribution=[hash[1]], collation=[[2]])
LogicalProject(ROWTIME=[$0], PRODUCTID=[$1], ORDERID=[$2])
LogicalTableScan(table=[[CATALOG, SALES, ORDERS]])
]]>
</Resource>
</TestCase>
<TestCase name="testTableFunctionWithSubQuery">
<Resource name="sql">
<![CDATA[select *
from table(topn(select * from orders partition by productid order by orderId desc nulls last, 3))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ROWTIME=[$0], PRODUCTID=[$1], ORDERID=[$2], RANK_NUMBER=[$3])
LogicalTableFunctionScan(invocation=[TOPN(3)], rowType=[RecordType(TIMESTAMP(0) ROWTIME, INTEGER PRODUCTID, INTEGER ORDERID, BIGINT RANK_NUMBER)])
LogicalSortExchange(distribution=[hash[1]], collation=[[2 DESC-nulls-last]])
LogicalProject(ROWTIME=[$0], PRODUCTID=[$1], ORDERID=[$2])
LogicalTableScan(table=[[CATALOG, SALES, ORDERS]])
]]>
</Resource>
</TestCase>
<TestCase name="testTableFunctionWithSubQueryWithParamNames">
<Resource name="sql">
<![CDATA[select *
from table(
topn(
DATA => select * from orders partition by productid order by orderId nulls first,
COL => 3))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ROWTIME=[$0], PRODUCTID=[$1], ORDERID=[$2], RANK_NUMBER=[$3])
LogicalTableFunctionScan(invocation=[TOPN(3)], rowType=[RecordType(TIMESTAMP(0) ROWTIME, INTEGER PRODUCTID, INTEGER ORDERID, BIGINT RANK_NUMBER)])
LogicalSortExchange(distribution=[hash[1]], collation=[[2 ASC-nulls-first]])
LogicalProject(ROWTIME=[$0], PRODUCTID=[$1], ORDERID=[$2])
LogicalTableScan(table=[[CATALOG, SALES, ORDERS]])
]]>
</Resource>
</TestCase>
<TestCase name="testTableSubset">
<Resource name="sql">
<![CDATA[select deptno, name from dept]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], NAME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testTranslateFunc1">
<Resource name="sql">
<![CDATA[select translate(ename using utf8) as new_ename
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(NEW_ENAME=[TRANSLATE($1, 'UTF8')])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testTranslateFunc2">
<Resource name="sql">
<![CDATA[select convert(ename using utf8) as new_ename
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(NEW_ENAME=[TRANSLATE($1, 'UTF8')])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testTrimExceptAll">
<Resource name="sql">
<![CDATA[select deptno from
(select ename, deptno from emp
except all
select name, deptno from dept)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$1])
LogicalMinus(all=[true])
LogicalProject(ENAME=[$1], DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalProject(NAME=[$1], DEPTNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testTrimExceptDistinct">
<Resource name="sql">
<![CDATA[select deptno from
(select ename, deptno from emp
except
select name, deptno from dept)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$1])
LogicalMinus(all=[false])
LogicalProject(ENAME=[$1], DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalProject(NAME=[$1], DEPTNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testTrimIntersectAll">
<Resource name="sql">
<![CDATA[select deptno from
(select ename, deptno from emp
intersect all
select name, deptno from dept)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$1])
LogicalIntersect(all=[true])
LogicalProject(ENAME=[$1], DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalProject(NAME=[$1], DEPTNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testTrimIntersectDistinct">
<Resource name="sql">
<![CDATA[select deptno from
(select ename, deptno from emp
intersect
select name, deptno from dept)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$1])
LogicalIntersect(all=[false])
LogicalProject(ENAME=[$1], DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalProject(NAME=[$1], DEPTNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testTrimUnionAll">
<Resource name="sql">
<![CDATA[select deptno from
(select ename, deptno from emp
union all
select name, deptno from dept)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalUnion(all=[true])
LogicalProject(DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalProject(DEPTNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testTrimUnionDistinct">
<Resource name="sql">
<![CDATA[select deptno from
(select ename, deptno from emp
union
select name, deptno from dept)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$1])
LogicalUnion(all=[false])
LogicalProject(ENAME=[$1], DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalProject(NAME=[$1], DEPTNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testTumble">
<Resource name="sql">
<![CDATA[select STREAM
TUMBLE_START(rowtime, INTERVAL '1' MINUTE) AS s,
TUMBLE_END(rowtime, INTERVAL '1' MINUTE) AS e
from Shipments
GROUP BY TUMBLE(rowtime, INTERVAL '1' MINUTE)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalDelta
LogicalProject(S=[$0], E=[+($0, 60000:INTERVAL MINUTE)])
LogicalAggregate(group=[{0}])
LogicalProject($f0=[$TUMBLE($1, 60000:INTERVAL MINUTE)])
LogicalTableScan(table=[[CATALOG, SALES, SHIPMENTS]])
]]>
</Resource>
</TestCase>
<TestCase name="testTumbleTable">
<Resource name="sql">
<![CDATA[select stream tumble_end(rowtime, interval '2' hour) as rowtime, productId
from orders
group by tumble(rowtime, interval '2' hour), productId]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalDelta
LogicalProject(ROWTIME=[+($0, 7200000:INTERVAL HOUR)], PRODUCTID=[$1])
LogicalAggregate(group=[{0, 1}])
LogicalProject($f0=[$TUMBLE($0, 7200000:INTERVAL HOUR)], PRODUCTID=[$1])
LogicalTableScan(table=[[CATALOG, SALES, ORDERS]])
]]>
</Resource>
</TestCase>
<TestCase name="testTumbleTableRowtimeNotFirstColumn">
<Resource name="sql">
<![CDATA[select stream
tumble_end(rowtime, interval '2' hour) as rowtime, orderId
from shipments
group by tumble(rowtime, interval '2' hour), orderId]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalDelta
LogicalProject(ROWTIME=[+($0, 7200000:INTERVAL HOUR)], ORDERID=[$1])
LogicalAggregate(group=[{0, 1}])
LogicalProject($f0=[$TUMBLE($1, 7200000:INTERVAL HOUR)], ORDERID=[$0])
LogicalTableScan(table=[[CATALOG, SALES, SHIPMENTS]])
]]>
</Resource>
</TestCase>
<TestCase name="testUdfWithStructuredReturnType">
<Resource name="sql">
<![CDATA[SELECT deptno, tmp.r.f0, tmp.r.f1 FROM
(SELECT deptno, STRUCTURED_FUNC() AS r from dept)tmp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], F0=[STRUCTURED_FUNC().F0], F1=[STRUCTURED_FUNC().F1])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testUncorrelatedScalarSubQueryInAggregateRex">
<Resource name="sql">
<![CDATA[select sum((select min(deptno) from emp)) as s
from emp
group by deptno
]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(S=[$1])
LogicalAggregate(group=[{0}], S=[SUM($1)])
LogicalProject(DEPTNO=[$7], $f1=[$SCALAR_QUERY({
LogicalAggregate(group=[{}], EXPR$0=[MIN($0)])
LogicalProject(DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
})])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testUncorrelatedScalarSubQueryInGroupOrderRex">
<Resource name="sql">
<![CDATA[select sum(sal) as s
from emp
group by deptno
order by (select case when true then deptno else null end from emp) desc,
count(*)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(S=[$0])
LogicalSort(sort0=[$1], sort1=[$2], dir0=[DESC], dir1=[ASC])
LogicalProject(S=[$1], EXPR$1=[$SCALAR_QUERY({
LogicalProject(EXPR$0=[CAST($7):INTEGER])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
})], EXPR$2=[$2])
LogicalAggregate(group=[{0}], S=[SUM($1)], agg#1=[COUNT()])
LogicalProject(DEPTNO=[$7], SAL=[$5])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testUncorrelatedScalarSubQueryInOrderRex">
<Resource name="sql">
<![CDATA[select ename
from emp
order by (select case when true then deptno else null end from emp) desc,
ename]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(ENAME=[$0])
LogicalSort(sort0=[$1], sort1=[$0], dir0=[DESC], dir1=[ASC])
LogicalProject(ENAME=[$1], EXPR$1=[$SCALAR_QUERY({
LogicalProject(EXPR$0=[CAST($7):INTEGER])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
})])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testUnion">
<Resource name="plan">
<![CDATA[
LogicalUnion(all=[false])
LogicalProject(EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalProject(DEPTNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select empno from emp union select deptno from dept]]>
</Resource>
</TestCase>
<TestCase name="testUnionAll">
<Resource name="plan">
<![CDATA[
LogicalUnion(all=[true])
LogicalProject(EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalProject(DEPTNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select empno from emp union all select deptno from dept]]>
</Resource>
</TestCase>
<TestCase name="testUnionInFrom">
<Resource name="sql">
<![CDATA[select x0, x1 from (
select 'a' as x0, 'a' as x1, 'a' as x2 from emp
union all
select 'bb' as x0, 'bb' as x1, 'bb' as x2 from dept)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(X0=[$0], X1=[$1])
LogicalUnion(all=[true])
LogicalProject(X0=['a'], X1=['a'], X2=['a'])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalProject(X0=['bb'], X1=['bb'], X2=['bb'])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testUnionSubQuery">
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$7])
LogicalJoin(condition=[true], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalUnion(all=[true])
LogicalUnion(all=[true])
LogicalProject(EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalProject(DEPTNO=[$0])
LogicalFilter(condition=[>($0, 20)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
LogicalValues(tuples=[[{ 45 }, { 67 }]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select deptno from emp as emp0 cross join
(select empno from emp union all
select deptno from dept where deptno > 20 union all
values (45), (67))]]>
</Resource>
</TestCase>
<TestCase name="testUnionValues">
<Resource name="plan">
<![CDATA[
LogicalUnion(all=[true])
LogicalUnion(all=[true])
LogicalValues(tuples=[[{ 10 }, { 20 }]])
LogicalProject(EXPR$0=[34])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalUnion(all=[true])
LogicalValues(tuples=[[{ 30 }]])
LogicalProject(EXPR$0=[+(45, 10)])
LogicalValues(tuples=[[{ 0 }]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[values (10), (20)
union all
select 34 from emp
union all values (30), (45 + 10)]]>
</Resource>
</TestCase>
<TestCase name="testUniqueWithExpand">
<Resource name="sql">
<![CDATA[select * from emp
where unique (select 1 from dept where deptno=55)]]>
</Resource>
</TestCase>
<TestCase name="testUniqueWithManyProject">
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalFilter(condition=[UNIQUE({
LogicalProject(DEPTNO=[$0], NAME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
})])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select * from emp
where unique (select * from dept)]]>
</Resource>
</TestCase>
<TestCase name="testUniqueWithOneProject">
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalFilter(condition=[UNIQUE({
LogicalProject(NAME=[$1])
LogicalFilter(condition=[=($0, 55)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
})])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select * from emp
where unique (select name from dept where deptno=55)]]>
</Resource>
</TestCase>
<TestCase name="testUniqueWithProjectLateral">
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalFilter(condition=[UNIQUE({
LogicalProject(EXPR$0=[1])
LogicalFilter(condition=[=($0, 55)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
})])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select * from emp
where unique (select 1 from dept where deptno=55)]]>
</Resource>
</TestCase>
<TestCase name="testUnnest">
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[$0])
Uncollect
LogicalProject(EXPR$0=[$SLICE($0)])
Collect(field=[EXPR$0])
LogicalValues(tuples=[[{ 1 }, { 2 }]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select*from unnest(multiset[1,2])]]>
</Resource>
</TestCase>
<TestCase name="testUnnestArray">
<Resource name="sql">
<![CDATA[select*from unnest(array(select*from dept))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], NAME=[$1])
Uncollect
Collect(field=[EXPR$0])
LogicalProject(DEPTNO=[$0], NAME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testUnnestArrayAggPlan">
<Resource name="sql">
<![CDATA[select d.deptno, e2.empno_avg
from dept_nested as d outer apply
(select avg(e.empno) as empno_avg from UNNEST(d.employees) as e) e2]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], EMPNO_AVG=[$7])
LogicalProject(DEPTNO=[$0], NAME=[$1], TYPE=[$2], DESC=[$3], A=[$4], B=[$5], EMPLOYEES=[$6], EMPNO_AVG=[$7])
LogicalCorrelate(correlation=[$cor0], joinType=[left], requiredColumns=[{6}])
LogicalProject(DEPTNO=[$0], NAME=[$1], TYPE=[$2.TYPE], DESC=[$2.DESC], A=[$2.OTHERS.A], B=[$2.OTHERS.B], EMPLOYEES=[$3])
LogicalTableScan(table=[[CATALOG, SALES, DEPT_NESTED]])
LogicalAggregate(group=[{}], EMPNO_AVG=[AVG($0)])
LogicalProject(EMPNO=[$0])
Uncollect
LogicalProject(EMPLOYEES=[$cor0.EMPLOYEES])
LogicalValues(tuples=[[{ 0 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testUnnestArrayNoExpand">
<Resource name="sql">
<![CDATA[select name,
array (select *
from emp
where deptno = dept.deptno) as emp_array,
multiset (select *
from emp
where deptno = dept.deptno) as emp_multiset,
map (select empno, job
from emp
where deptno = dept.deptno) as job_map
from dept]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(NAME=[$1], EMP_ARRAY=[ARRAY({
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalFilter(condition=[=($7, $cor0.DEPTNO)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
})], EMP_MULTISET=[MULTISET({
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalFilter(condition=[=($7, $cor0.DEPTNO)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
})], JOB_MAP=[MAP({
LogicalProject(EMPNO=[$0], JOB=[$2])
LogicalFilter(condition=[=($7, $cor0.DEPTNO)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
})])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testUnnestArrayPlan">
<Resource name="sql">
<![CDATA[select d.deptno, e2.empno
from dept_nested as d,
UNNEST(d.employees) e2]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], EMPNO=[$7])
LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{6}])
LogicalProject(DEPTNO=[$0], NAME=[$1], TYPE=[$2.TYPE], DESC=[$2.DESC], A=[$2.OTHERS.A], B=[$2.OTHERS.B], EMPLOYEES=[$3])
LogicalTableScan(table=[[CATALOG, SALES, DEPT_NESTED]])
Uncollect
LogicalProject(EMPLOYEES=[$cor0.EMPLOYEES])
LogicalValues(tuples=[[{ 0 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testUnnestArrayPlanAs">
<Resource name="sql">
<![CDATA[select d.deptno, e2.empno
from dept_nested as d,
UNNEST(d.employees) as e2(empno, y, z)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], EMPNO=[$7])
LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{6}])
LogicalProject(DEPTNO=[$0], NAME=[$1], TYPE=[$2.TYPE], DESC=[$2.DESC], A=[$2.OTHERS.A], B=[$2.OTHERS.B], EMPLOYEES=[$3])
LogicalTableScan(table=[[CATALOG, SALES, DEPT_NESTED]])
LogicalProject(EMPNO=[$0], Y=[$1], Z=[$2])
Uncollect
LogicalProject(EMPLOYEES=[$cor0.EMPLOYEES])
LogicalValues(tuples=[[{ 0 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testUnnestSelect">
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[$0])
Uncollect
LogicalProject(EXPR$0=[$SLICE($2)])
LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{0}])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
Collect(field=[EXPR$0])
LogicalUnion(all=[true])
LogicalProject(EXPR$0=[$cor0.DEPTNO])
LogicalValues(tuples=[[{ 0 }]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select*from unnest(select multiset[deptno] from dept)]]>
</Resource>
</TestCase>
<TestCase name="testUnnestSelectRex">
<Resource name="sql">
<![CDATA[select*from unnest(select multiset[deptno] from dept)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[$0])
Uncollect
LogicalProject(EXPR$0=[$SLICE($2)])
LogicalCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{0}])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
Collect(field=[EXPR$0])
LogicalUnion(all=[true])
LogicalProject(EXPR$0=[$cor0.DEPTNO])
LogicalValues(tuples=[[{ 0 }]])
]]>
</Resource>
</TestCase>
<TestCase name="testUnnestSubQuery">
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], NAME=[$1])
Uncollect
Collect(field=[EXPR$0])
LogicalProject(DEPTNO=[$0], NAME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
<Resource name="sql">
<![CDATA[select*from unnest(multiset(select*from dept))]]>
</Resource>
</TestCase>
<TestCase name="testUnnestWithOrdinality">
<Resource name="sql">
<![CDATA[select*from unnest(array(select*from dept)) with ordinality]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], NAME=[$1], ORDINALITY=[$2])
Uncollect(withOrdinality=[true])
Collect(field=[EXPR$0])
LogicalProject(DEPTNO=[$0], NAME=[$1])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testUnpivot">
<Resource name="sql">
<![CDATA[SELECT * FROM emp
UNPIVOT INCLUDE NULLS (remuneration
FOR remuneration_type IN (comm AS 'commission',
sal as 'salary'))]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], DEPTNO=[$7], SLACKER=[$8], REMUNERATION_TYPE=[$9], REMUNERATION=[CASE(=($9, 'commission'), $6, =($9, 'salary '), $5, null:NULL)])
LogicalJoin(condition=[true], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalValues(tuples=[[{ 'commission' }, { 'salary ' }]])
]]>
</Resource>
</TestCase>
<TestCase name="testUpdate">
<Resource name="sql">
<![CDATA[update emp set empno = empno + 1]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMP]], operation=[UPDATE], updateColumnList=[[EMPNO]], sourceExpressionList=[[+($0, 1)]], flattened=[true])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], EXPR$0=[+($0, 1)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testUpdateBind">
<Resource name="sql">
<![CDATA[update emp set sal = sal + ? where slacker = false]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMP]], operation=[UPDATE], updateColumnList=[[SAL]], sourceExpressionList=[[+($5, ?0)]], flattened=[true])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], EXPR$0=[+($5, ?0)])
LogicalFilter(condition=[=($8, false)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testUpdateBind2">
<Resource name="sql">
<![CDATA[update emp set sal = ? where slacker = false]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMP]], operation=[UPDATE], updateColumnList=[[SAL]], sourceExpressionList=[[?0]], flattened=[true])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], EXPR$0=[?0])
LogicalFilter(condition=[=($8, false)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testUpdateExtendedColumn">
<Resource name="sql">
<![CDATA[update empdefaults(updated TIMESTAMP) set deptno = 1, updated = timestamp '2017-03-12 13:03:05', empno = 20, ename = 'Bob' where deptno = 10]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMPDEFAULTS]], operation=[UPDATE], updateColumnList=[[DEPTNO, UPDATED, EMPNO, ENAME]], sourceExpressionList=[[1, 2017-03-12 13:03:05, 20, 'Bob']], flattened=[true])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], UPDATED=[$9], EXPR$0=[1], EXPR$1=[2017-03-12 13:03:05], EXPR$2=[20], EXPR$3=['Bob'])
LogicalFilter(condition=[=($7, 10)])
LogicalTableScan(table=[[CATALOG, SALES, EMPDEFAULTS]])
]]>
</Resource>
</TestCase>
<TestCase name="testUpdateExtendedColumnCaseSensitiveCollision">
<Resource name="sql">
<![CDATA[update empdefaults("slacker" INTEGER, deptno INTEGER) set deptno = 1, "slacker" = 100 where ename = 'Bob']]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMPDEFAULTS]], operation=[UPDATE], updateColumnList=[[DEPTNO, slacker]], sourceExpressionList=[[1, 100]], flattened=[true])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], slacker=[$9], EXPR$0=[1], EXPR$1=[100])
LogicalFilter(condition=[=($1, 'Bob')])
LogicalTableScan(table=[[CATALOG, SALES, EMPDEFAULTS]])
]]>
</Resource>
</TestCase>
<TestCase name="testUpdateExtendedColumnCollision">
<Resource name="sql">
<![CDATA[update empdefaults(empno INTEGER NOT NULL, deptno INTEGER) set deptno = 1, empno = 20, ename = 'Bob' where deptno = 10]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMPDEFAULTS]], operation=[UPDATE], updateColumnList=[[DEPTNO, EMPNO, ENAME]], sourceExpressionList=[[1, 20, 'Bob']], flattened=[true])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], EXPR$0=[1], EXPR$1=[20], EXPR$2=['Bob'])
LogicalFilter(condition=[=($7, 10)])
LogicalTableScan(table=[[CATALOG, SALES, EMPDEFAULTS]])
]]>
</Resource>
</TestCase>
<TestCase name="testUpdateExtendedColumnModifiableView">
<Resource name="sql">
<![CDATA[update EMP_MODIFIABLEVIEW2(updated TIMESTAMP)
set updated = timestamp '2017-03-12 13:03:05', sal = sal + 5000
where slacker = false]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMP_MODIFIABLEVIEW2]], operation=[UPDATE], updateColumnList=[[UPDATED, SAL]], sourceExpressionList=[[2017-03-12 13:03:05, +($5, 5000)]], flattened=[true])
LogicalProject(ENAME=[$0], EMPNO=[$1], JOB=[$2], DEPTNO=[$3], SLACKER=[$4], SAL=[$5], EXTRA=[$6], HIREDATE=[$7], MGR=[$8], COMM=[$9], UPDATED=[$10], EXPR$0=[2017-03-12 13:03:05], EXPR$1=[+($5, 5000)])
LogicalFilter(condition=[=($4, false)])
LogicalTableScan(table=[[CATALOG, SALES, EMP_MODIFIABLEVIEW2]])
]]>
</Resource>
</TestCase>
<TestCase name="testUpdateExtendedColumnModifiableViewCaseSensitiveCollision">
<Resource name="sql">
<![CDATA[update EMP_MODIFIABLEVIEW2("slacker" INTEGER, deptno INTEGER) set deptno = 20, "slacker" = 100 where ename = 'Bob']]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMP_MODIFIABLEVIEW2]], operation=[UPDATE], updateColumnList=[[DEPTNO, slacker]], sourceExpressionList=[[20, 100]], flattened=[true])
LogicalProject(ENAME=[$0], EMPNO=[$1], JOB=[$2], DEPTNO=[$3], SLACKER=[$4], SAL=[$5], EXTRA=[$6], HIREDATE=[$7], MGR=[$8], COMM=[$9], slacker=[$10], EXPR$0=[20], EXPR$1=[100])
LogicalFilter(condition=[=($0, 'Bob')])
LogicalTableScan(table=[[CATALOG, SALES, EMP_MODIFIABLEVIEW2]])
]]>
</Resource>
</TestCase>
<TestCase name="testUpdateExtendedColumnModifiableViewCollision">
<Resource name="sql">
<![CDATA[update EMP_MODIFIABLEVIEW3(empno INTEGER NOT NULL, deptno INTEGER) set deptno = 20, empno = 20, ename = 'Bob' where empno = 10]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMP_MODIFIABLEVIEW3]], operation=[UPDATE], updateColumnList=[[DEPTNO, EMPNO, ENAME]], sourceExpressionList=[[20, 20, 'Bob']], flattened=[true])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], SLACKER=[$6], DEPTNO=[$7], EXPR$0=[20], EXPR$1=[20], EXPR$2=['Bob'])
LogicalFilter(condition=[=($0, 10)])
LogicalTableScan(table=[[CATALOG, SALES, EMP_MODIFIABLEVIEW3]])
]]>
</Resource>
</TestCase>
<TestCase name="testUpdateExtendedColumnModifiableViewExtendedCaseSensitiveCollision">
<Resource name="sql">
<![CDATA[update EMP_MODIFIABLEVIEW2("extra" INTEGER, extra BOOLEAN) set deptno = 20, "extra" = 100, extra = true where ename = 'Bob']]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMP_MODIFIABLEVIEW2]], operation=[UPDATE], updateColumnList=[[DEPTNO, extra, EXTRA]], sourceExpressionList=[[20, 100, true]], flattened=[true])
LogicalProject(ENAME=[$0], EMPNO=[$1], JOB=[$2], DEPTNO=[$3], SLACKER=[$4], SAL=[$5], EXTRA=[$6], HIREDATE=[$7], MGR=[$8], COMM=[$9], extra=[$10], EXPR$0=[20], EXPR$1=[100], EXPR$2=[true])
LogicalFilter(condition=[=($0, 'Bob')])
LogicalTableScan(table=[[CATALOG, SALES, EMP_MODIFIABLEVIEW2]])
]]>
</Resource>
</TestCase>
<TestCase name="testUpdateExtendedColumnModifiableViewExtendedCollision">
<Resource name="sql">
<![CDATA[update EMP_MODIFIABLEVIEW2("slacker" INTEGER, extra BOOLEAN) set deptno = 20, "slacker" = 100, extra = true where ename = 'Bob']]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMP_MODIFIABLEVIEW2]], operation=[UPDATE], updateColumnList=[[DEPTNO, slacker, EXTRA]], sourceExpressionList=[[20, 100, true]], flattened=[true])
LogicalProject(ENAME=[$0], EMPNO=[$1], JOB=[$2], DEPTNO=[$3], SLACKER=[$4], SAL=[$5], EXTRA=[$6], HIREDATE=[$7], MGR=[$8], COMM=[$9], slacker=[$10], EXPR$0=[20], EXPR$1=[100], EXPR$2=[true])
LogicalFilter(condition=[=($0, 'Bob')])
LogicalTableScan(table=[[CATALOG, SALES, EMP_MODIFIABLEVIEW2]])
]]>
</Resource>
</TestCase>
<TestCase name="testUpdateExtendedColumnModifiableViewUnderlyingCollision">
<Resource name="sql">
<![CDATA[update EMP_MODIFIABLEVIEW3(extra BOOLEAN, comm INTEGER) set empno = 20, comm = 123, extra = true where ename = 'Bob']]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMP_MODIFIABLEVIEW3]], operation=[UPDATE], updateColumnList=[[EMPNO, COMM, EXTRA]], sourceExpressionList=[[20, 123, true]], flattened=[true])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], SLACKER=[$6], EXTRA=[$7], COMM=[$8], EXPR$0=[20], EXPR$1=[123], EXPR$2=[true])
LogicalFilter(condition=[=($1, 'Bob')])
LogicalTableScan(table=[[CATALOG, SALES, EMP_MODIFIABLEVIEW3]])
]]>
</Resource>
</TestCase>
<TestCase name="testUpdateModifiableView">
<Resource name="sql">
<![CDATA[update EMP_MODIFIABLEVIEW2
set sal = sal + 5000 where slacker = false]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMP_MODIFIABLEVIEW2]], operation=[UPDATE], updateColumnList=[[SAL]], sourceExpressionList=[[+($5, 5000)]], flattened=[true])
LogicalProject(ENAME=[$0], EMPNO=[$1], JOB=[$2], DEPTNO=[$3], SLACKER=[$4], SAL=[$5], EXTRA=[$6], HIREDATE=[$7], MGR=[$8], COMM=[$9], EXPR$0=[+($5, 5000)])
LogicalFilter(condition=[=($4, false)])
LogicalTableScan(table=[[CATALOG, SALES, EMP_MODIFIABLEVIEW2]])
]]>
</Resource>
</TestCase>
<TestCase name="testUpdateSubQuery">
<Resource name="sql">
<![CDATA[update emp
set empno = (
select min(empno) from emp as e where e.deptno = emp.deptno)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMP]], operation=[UPDATE], updateColumnList=[[EMPNO]], sourceExpressionList=[[$0]], flattened=[true])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], EXPR$0=[$10])
LogicalJoin(condition=[=($7, $9)], joinType=[left])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0}], EXPR$0=[MIN($1)])
LogicalProject(DEPTNO=[$7], EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testUpdateSubQueryWithIn">
<Resource name="sql">
<![CDATA[update emp
set empno = 1 where empno in (
select empno from emp where empno=2)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMP]], operation=[UPDATE], updateColumnList=[[EMPNO]], sourceExpressionList=[[1]], flattened=[true])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], EXPR$0=[1])
LogicalJoin(condition=[=($0, $9)], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0}])
LogicalProject(EMPNO=[$0])
LogicalFilter(condition=[=($0, 2)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testUpdateSubQueryWithIn1">
<Resource name="sql">
<![CDATA[update emp
set empno = 1 where emp.empno in (
select emp.empno from emp where emp.empno=2)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMP]], operation=[UPDATE], updateColumnList=[[EMPNO]], sourceExpressionList=[[1]], flattened=[true])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], EXPR$0=[1])
LogicalJoin(condition=[=($0, $9)], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0}])
LogicalProject(EMPNO=[$0])
LogicalFilter(condition=[=($0, 2)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testUpdateSubQueryWithNotIn">
<Resource name="sql">
<![CDATA[update emp
set empno = 1 where empno not in (
select empno from emp where empno=2)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMP]], operation=[UPDATE], updateColumnList=[[EMPNO]], sourceExpressionList=[[1]], flattened=[true])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], EXPR$0=[1])
LogicalFilter(condition=[NOT(AND(IS TRUE($11), IS NOT NULL($9)))])
LogicalJoin(condition=[=($9, $10)], joinType=[left])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], EMPNO0=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0}], agg#0=[MIN($1)])
LogicalProject(EMPNO=[$0], $f1=[true])
LogicalFilter(condition=[=($0, 2)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testUpdateWhere">
<Resource name="sql">
<![CDATA[update emp set empno = empno + 1 where deptno = 10]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, SALES, EMP]], operation=[UPDATE], updateColumnList=[[EMPNO]], sourceExpressionList=[[+($0, 1)]], flattened=[true])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], EXPR$0=[+($0, 1)])
LogicalFilter(condition=[=($7, 10)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testUpdateWithCustomColumnResolving">
<Resource name="sql">
<![CDATA[update struct.t set c0 = c0 + 1]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalTableModify(table=[[CATALOG, STRUCT, T]], operation=[UPDATE], updateColumnList=[["F0"."C0"]], sourceExpressionList=[[+($4, 1)]], flattened=[true])
LogicalProject("K0"=[$0], "C1"=[$1], "F1"."A0"=[$2], "F2"."A0"=[$3], "F0"."C0"=[$4], "F1"."C0"=[$5], "F0"."C1"=[$6], "F1"."C2"=[$7], "F2"."C3"=[$8], EXPR$0=[+($4, 1)])
LogicalTableScan(table=[[CATALOG, STRUCT, T]])
]]>
</Resource>
</TestCase>
<TestCase name="testUserDefinedOrderByOverFirst">
<Resource name="sql">
<![CDATA[select deptno,
rank() over (partition by empno order by comm desc)
from emp
order by row_number() over (partition by empno order by comm)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], EXPR$1=[$1])
LogicalSort(sort0=[$2], dir0=[ASC-nulls-first])
LogicalProject(DEPTNO=[$7], EXPR$1=[RANK() OVER (PARTITION BY $0 ORDER BY $6 DESC)], EXPR$2=[ROW_NUMBER() OVER (PARTITION BY $0 ORDER BY $6 NULLS FIRST)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testUserDefinedOrderByOverHigh">
<Resource name="sql">
<![CDATA[select deptno,
rank() over (partition by empno order by comm desc)
from emp
order by row_number() over (partition by empno order by comm)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], EXPR$1=[$1])
LogicalSort(sort0=[$2], dir0=[ASC])
LogicalProject(DEPTNO=[$7], EXPR$1=[RANK() OVER (PARTITION BY $0 ORDER BY $6 DESC)], EXPR$2=[ROW_NUMBER() OVER (PARTITION BY $0 ORDER BY $6)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testUserDefinedOrderByOverLast">
<Resource name="sql">
<![CDATA[select deptno,
rank() over (partition by empno order by comm desc)
from emp
order by row_number() over (partition by empno order by comm)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], EXPR$1=[$1])
LogicalSort(sort0=[$2], dir0=[ASC])
LogicalProject(DEPTNO=[$7], EXPR$1=[RANK() OVER (PARTITION BY $0 ORDER BY $6 DESC NULLS LAST)], EXPR$2=[ROW_NUMBER() OVER (PARTITION BY $0 ORDER BY $6)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testUserDefinedOrderByOverLow">
<Resource name="sql">
<![CDATA[select deptno,
rank() over (partition by empno order by comm desc)
from emp
order by row_number() over (partition by empno order by comm)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(DEPTNO=[$0], EXPR$1=[$1])
LogicalSort(sort0=[$2], dir0=[ASC-nulls-first])
LogicalProject(DEPTNO=[$7], EXPR$1=[RANK() OVER (PARTITION BY $0 ORDER BY $6 DESC NULLS LAST)], EXPR$2=[ROW_NUMBER() OVER (PARTITION BY $0 ORDER BY $6 NULLS FIRST)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testValuesUsing">
<Resource name="sql">
<![CDATA[select d.deptno, min(e.empid) as empid
from (values (100, 'Bill', 1)) as e(empid, name, deptno)
join (values (1, 'LeaderShip')) as d(deptno, name)
using (deptno)
group by d.deptno]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{0}], EMPID=[MIN($1)])
LogicalProject(DEPTNO=[$3], EMPID=[$0])
LogicalJoin(condition=[=($2, $3)], joinType=[inner])
LogicalValues(tuples=[[{ 100, 'Bill', 1 }]])
LogicalValues(tuples=[[{ 1, 'LeaderShip' }]])
]]>
</Resource>
</TestCase>
<TestCase name="testWhereInCorrelated">
<Resource name="sql">
<![CDATA[select empno from emp as e
join dept as d using (deptno)
where e.sal in (
select e2.sal from emp as e2 where e2.deptno > e.deptno)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0])
LogicalFilter(condition=[IN($5, {
LogicalProject(SAL=[$5])
LogicalFilter(condition=[>($7, $cor0.DEPTNO)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
})], variablesSet=[[$cor0]])
LogicalJoin(condition=[=($7, $9)], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testWindowAggInSubQueryJoin">
<Resource name="sql">
<![CDATA[select T.x, T.y, T.z, emp.empno
from (select min(deptno) as x,
rank() over (order by empno) as y,
max(empno) over (partition by deptno) as z
from emp group by deptno, empno) as T
inner join emp on T.x = emp.deptno
and T.y = emp.empno
]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(X=[$0], Y=[$1], Z=[$2], EMPNO=[$3])
LogicalJoin(condition=[AND(=($0, $10), =($1, $12))], joinType=[inner])
LogicalProject(X=[$2], Y=[RANK() OVER (ORDER BY $1)], Z=[MAX($1) OVER (PARTITION BY $0)])
LogicalAggregate(group=[{0, 1}], X=[MIN($0)])
LogicalProject(DEPTNO=[$7], EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8], EMPNO0=[CAST($0):BIGINT NOT NULL])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testWindowAggWithGroupBy">
<Resource name="sql">
<![CDATA[select min(deptno), rank() over (order by empno),
max(empno) over (partition by deptno)
from emp group by deptno, empno
]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[$2], EXPR$1=[RANK() OVER (ORDER BY $1)], EXPR$2=[MAX($1) OVER (PARTITION BY $0)])
LogicalAggregate(group=[{0, 1}], EXPR$0=[MIN($0)])
LogicalProject(DEPTNO=[$7], EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testWindowAggWithGroupByAndHaving">
<Resource name="sql">
<![CDATA[select min(deptno), rank() over (order by empno),
max(empno) over (partition by deptno)
from emp group by deptno, empno
having empno < 10 and min(deptno) < 20
]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[$2], EXPR$1=[RANK() OVER (ORDER BY $1)], EXPR$2=[MAX($1) OVER (PARTITION BY $0)])
LogicalFilter(condition=[AND(<($1, 10), <($2, 20))])
LogicalAggregate(group=[{0, 1}], EXPR$0=[MIN($0)])
LogicalProject(DEPTNO=[$7], EMPNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testWindowAggWithGroupByAndJoin">
<Resource name="sql">
<![CDATA[select min(d.deptno), rank() over (order by e.empno),
max(e.empno) over (partition by e.deptno)
from emp e, dept d
where e.deptno = d.deptno
group by d.deptno, e.empno, e.deptno
]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[$3], EXPR$1=[RANK() OVER (ORDER BY $1)], EXPR$2=[MAX($1) OVER (PARTITION BY $2)])
LogicalAggregate(group=[{0, 1, 2}], EXPR$0=[MIN($0)])
LogicalProject(DEPTNO0=[$9], EMPNO=[$0], DEPTNO=[$7])
LogicalFilter(condition=[=($7, $9)])
LogicalJoin(condition=[true], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testWindowAndGroupByWithDynamicStar">
<Resource name="sql">
<![CDATA[SELECT
n_regionkey,
MAX(MIN(n_nationkey)) OVER (PARTITION BY n_regionkey)
FROM (SELECT * FROM SALES.NATION)
GROUP BY n_regionkey]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(N_REGIONKEY=[$0], EXPR$1=[MAX($1) OVER (PARTITION BY $0)])
LogicalAggregate(group=[{0}], agg#0=[MIN($1)])
LogicalProject(N_REGIONKEY=[ITEM($0, 'N_REGIONKEY')], $f1=[ITEM($0, 'N_NATIONKEY')])
LogicalTableScan(table=[[CATALOG, SALES, NATION]])
]]>
</Resource>
</TestCase>
<TestCase name="testWindowAverageWithGroupBy">
<Resource name="sql">
<![CDATA[select avg(deptno) over ()
from emp
group by deptno]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[CAST(/(SUM($0) OVER (), COUNT($0) OVER ())):INTEGER NOT NULL])
LogicalAggregate(group=[{0}])
LogicalProject(DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testWindowOnDynamicStar">
<Resource name="sql">
<![CDATA[SELECT SUM(n_nationkey) OVER w
FROM (SELECT * FROM SALES.NATION) subQry
WINDOW w AS (PARTITION BY REGION ORDER BY n_nationkey)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EXPR$0=[CASE(>(COUNT(ITEM($0, 'N_NATIONKEY')) OVER (PARTITION BY ITEM($0, 'REGION') ORDER BY ITEM($0, 'N_NATIONKEY')), 0), $SUM0(ITEM($0, 'N_NATIONKEY')) OVER (PARTITION BY ITEM($0, 'REGION') ORDER BY ITEM($0, 'N_NATIONKEY')), null:ANY)])
LogicalTableScan(table=[[CATALOG, SALES, NATION]])
]]>
</Resource>
</TestCase>
<TestCase name="testWith">
<Resource name="sql">
<![CDATA[with emp2 as (select * from emp)
select * from emp2]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testWithAlias">
<Resource name="sql">
<![CDATA[with w(x, y) as
(select * from dept where deptno > 10)
select x from w where x < 30 union all select deptno from dept]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalUnion(all=[true])
LogicalProject(X=[$0])
LogicalFilter(condition=[<($0, 30)])
LogicalProject(DEPTNO=[$0], NAME=[$1])
LogicalFilter(condition=[>($0, 10)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
LogicalProject(DEPTNO=[$0])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testWithExists">
<Resource name="sql">
<![CDATA[with t (a, b) as (select * from (values (1, 2)))
select * from t where exists (
select 1 from emp where deptno = t.a)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(A=[$0], B=[$1])
LogicalProject(EXPR$0=[$0], EXPR$1=[$1], $f0=[$2])
LogicalFilter(condition=[IS NOT NULL($2)])
LogicalCorrelate(correlation=[$cor0], joinType=[left], requiredColumns=[{0}])
LogicalProject(EXPR$0=[$0], EXPR$1=[$1])
LogicalValues(tuples=[[{ 1, 2 }]])
LogicalAggregate(group=[{}], agg#0=[MIN($0)])
LogicalProject($f0=[true])
LogicalFilter(condition=[=($7, $cor0.A)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testWithInsideScalarSubQuery">
<Resource name="sql">
<![CDATA[select (
with dept2 as (select * from dept where deptno > 10) select count(*) from dept2) as c
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(C=[$9])
LogicalJoin(condition=[true], joinType=[left])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{}], agg#0=[SINGLE_VALUE($0)])
LogicalAggregate(group=[{}], EXPR$0=[COUNT()])
LogicalProject($f0=[0])
LogicalFilter(condition=[>($0, 10)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testWithInsideScalarSubQueryRex">
<Resource name="sql">
<![CDATA[select (
with dept2 as (select * from dept where deptno > 10) select count(*) from dept2) as c
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(C=[$SCALAR_QUERY({
LogicalAggregate(group=[{}], EXPR$0=[COUNT()])
LogicalProject($f0=[0])
LogicalFilter(condition=[>($0, 10)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
})])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testWithInsideWhereExists">
<Resource name="sql">
<![CDATA[select * from emp
where exists (
with dept2 as (select * from dept where dept.deptno >= emp.deptno)
select 1 from dept2 where deptno <= emp.deptno)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalFilter(condition=[IS NOT NULL($9)])
LogicalCorrelate(correlation=[$cor1], joinType=[left], requiredColumns=[{7}])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{}], agg#0=[MIN($0)])
LogicalProject($f0=[true])
LogicalFilter(condition=[<=($0, $cor1.DEPTNO)])
LogicalProject(DEPTNO=[$0], NAME=[$1])
LogicalFilter(condition=[>=($0, $cor1.DEPTNO)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testWithInsideWhereExistsDecorrelate">
<Resource name="sql">
<![CDATA[select * from emp
where exists (
with dept2 as (select * from dept where dept.deptno >= emp.deptno)
select 1 from dept2 where deptno <= emp.deptno)]]>
</Resource>
<Resource name="plan">
<![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], DEPTNO0=[CAST($9):INTEGER], $f1=[CAST($10):BOOLEAN])
LogicalJoin(condition=[=($7, $9)], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalAggregate(group=[{0}], agg#0=[MIN($1)])
LogicalProject(DEPTNO0=[$2], $f0=[true])
LogicalFilter(condition=[<=($0, $2)])
LogicalProject(DEPTNO=[$0], NAME=[$1], DEPTNO0=[$2])
LogicalJoin(condition=[>=($0, $2)], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
LogicalAggregate(group=[{0}])
LogicalProject(DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testWithInsideWhereExistsDecorrelateRex">
<Resource name="sql">
<![CDATA[select * from emp
where exists (
with dept2 as (select * from dept where dept.deptno >= emp.deptno)
select 1 from dept2 where deptno <= emp.deptno)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalFilter(condition=[EXISTS({
LogicalFilter(condition=[<=($0, $cor1.DEPTNO)])
LogicalProject(DEPTNO=[$0], NAME=[$1])
LogicalFilter(condition=[>=($0, $cor1.DEPTNO)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
})], variablesSet=[[$cor1]])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testWithInsideWhereExistsRex">
<Resource name="sql">
<![CDATA[select * from emp
where exists (
with dept2 as (select * from dept where dept.deptno >= emp.deptno)
select 1 from dept2 where deptno <= emp.deptno)]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalFilter(condition=[EXISTS({
LogicalFilter(condition=[<=($0, $cor1.DEPTNO)])
LogicalProject(DEPTNO=[$0], NAME=[$1])
LogicalFilter(condition=[>=($0, $cor1.DEPTNO)])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
})], variablesSet=[[$cor1]])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testWithOrder">
<Resource name="sql">
<![CDATA[with emp2 as (select * from emp)
select * from emp2 order by deptno]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalSort(sort0=[$7], dir0=[ASC])
LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], MGR=[$3], HIREDATE=[$4], SAL=[$5], COMM=[$6], DEPTNO=[$7], SLACKER=[$8])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testWithUnion">
<Resource name="sql">
<![CDATA[with emp2 as (select * from emp where deptno > 10)
select empno from emp2 where deptno < 30
union all
select deptno from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalUnion(all=[true])
LogicalProject(EMPNO=[$0])
LogicalFilter(condition=[<($7, 30)])
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(DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testWithUnionOrder">
<Resource name="sql">
<![CDATA[with emp2 as (select empno, deptno as x from emp)
select * from emp2
union all
select * from emp2
order by empno + x]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalProject(EMPNO=[$0], X=[$1])
LogicalSort(sort0=[$2], dir0=[ASC])
LogicalProject(EMPNO=[$0], X=[$1], EXPR$2=[+($0, $1)])
LogicalUnion(all=[true])
LogicalProject(EMPNO=[$0], X=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalProject(EMPNO=[$0], X=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testWithinDistinct1">
<Resource name="sql">
<![CDATA[select avg(empno) within distinct (deptno)
from emp]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{}], EXPR$0=[AVG($0) WITHIN DISTINCT ($1)])
LogicalProject(EMPNO=[$0], DEPTNO=[$7])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testWithinGroup1">
<Resource name="sql">
<![CDATA[select deptno,
collect(empno) within group (order by deptno, hiredate desc)
from emp
group by deptno]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{0}], EXPR$1=[COLLECT($1) WITHIN GROUP ([0, 2 DESC])])
LogicalProject(DEPTNO=[$7], EMPNO=[$0], HIREDATE=[$4])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
<TestCase name="testWithinGroup2">
<Resource name="sql">
<![CDATA[select dept.deptno,
collect(sal) within group (order by sal desc) as s,
collect(sal) within group (order by 1)as s1,
collect(sal) within group (order by sal)
filter (where sal > 2000) as s2
from emp
join dept using (deptno)
group by dept.deptno]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{0}], S=[COLLECT($1) WITHIN GROUP ([1 DESC])], S1=[COLLECT($1) WITHIN GROUP ([2])], S2=[COLLECT($1) WITHIN GROUP ([1]) FILTER $3])
LogicalProject(DEPTNO=[$9], SAL=[$5], $f2=[1], $f3=[>($5, 2000)])
LogicalJoin(condition=[=($7, $9)], joinType=[inner])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
LogicalTableScan(table=[[CATALOG, SALES, DEPT]])
]]>
</Resource>
</TestCase>
<TestCase name="testWithinGroup3">
<Resource name="sql">
<![CDATA[select deptno,
collect(empno) within group (order by empno not in (1, 2)), count(*)
from emp
group by deptno]]>
</Resource>
<Resource name="plan">
<![CDATA[
LogicalAggregate(group=[{0}], EXPR$1=[COLLECT($1) WITHIN GROUP ([2])], EXPR$2=[COUNT()])
LogicalProject(DEPTNO=[$7], EMPNO=[$0], $f2=[SEARCH($0, Sarg[(-∞..1), (1..2), (2..+∞)])])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
</Root>