Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions core/src/main/java/org/apache/calcite/runtime/FlatLists.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.checkerframework.checker.nullness.qual.PolyNull;

Expand Down Expand Up @@ -1323,6 +1324,10 @@ protected ComparableListImpl(List<T> list) {
return list.size();
}

@Override @NonNull public Object[] toArray(@NonNull ComparableListImpl<T> this) {
return this.list.toArray();
}

@Override public int compareTo(List o) {
return compare(list, o);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3490,6 +3490,14 @@ void checkCorrelatedMapSubQuery(boolean expand) {
sql(sql).ok();
}

/** Test case for <a href="https://issues.apache.org/jira/browse/CALCITE-6376">[CALCITE-6376]
* Selecting 6 columns with QUALIFY operation results in exception</a>. */
@Test void testQualifyWindow() {
sql("SELECT empno, ename, deptno, job, mgr, hiredate\n"
+ "FROM emp\n"
+ "QUALIFY ROW_NUMBER() over (partition by ename order by deptno) = 1")
.ok();
}

@Test void testQualifyWithoutReferences() {
sql("SELECT empno, ename, deptno\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6136,6 +6136,21 @@ 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="testQualifyWindow">
<Resource name="sql">
<![CDATA[SELECT empno, ename, deptno, job, mgr, hiredate
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], JOB=[$3], MGR=[$4], HIREDATE=[$5])
LogicalFilter(condition=[$6])
LogicalProject(EMPNO=[$0], ENAME=[$1], DEPTNO=[$7], JOB=[$2], MGR=[$3], HIREDATE=[$4], QualifyExpression=[=(ROW_NUMBER() OVER (PARTITION BY $1 ORDER BY $7), 1)])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
Expand Down