This is an automated email from the ASF dual-hosted git repository.
mbudiu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/main by this push:
new f8eb832e2c [CALCITE-6376] Selecting 6 columns with QUALIFY operation
results in exception
f8eb832e2c is described below
commit f8eb832e2cbcbb7964d19e3e35035e1af1d4b365
Author: Mihai Budiu <[email protected]>
AuthorDate: Tue Apr 30 13:28:18 2024 -0700
[CALCITE-6376] Selecting 6 columns with QUALIFY operation results in
exception
Signed-off-by: Mihai Budiu <[email protected]>
---
.../main/java/org/apache/calcite/runtime/FlatLists.java | 5 +++++
.../org/apache/calcite/test/SqlToRelConverterTest.java | 8 ++++++++
.../org/apache/calcite/test/SqlToRelConverterTest.xml | 15 +++++++++++++++
3 files changed, 28 insertions(+)
diff --git a/core/src/main/java/org/apache/calcite/runtime/FlatLists.java
b/core/src/main/java/org/apache/calcite/runtime/FlatLists.java
index de7471eda6..544a8926f0 100644
--- a/core/src/main/java/org/apache/calcite/runtime/FlatLists.java
+++ b/core/src/main/java/org/apache/calcite/runtime/FlatLists.java
@@ -21,6 +21,7 @@ import org.apache.calcite.util.ImmutableNullableList;
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;
@@ -1323,6 +1324,10 @@ public class FlatLists {
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);
}
diff --git
a/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java
b/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java
index e62eeb78b5..4e55821999 100644
--- a/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java
+++ b/core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java
@@ -3490,6 +3490,14 @@ class SqlToRelConverterTest extends SqlToRelTestBase {
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"
diff --git
a/core/src/test/resources/org/apache/calcite/test/SqlToRelConverterTest.xml
b/core/src/test/resources/org/apache/calcite/test/SqlToRelConverterTest.xml
index 1bf1556aa7..2a029cfd09 100644
--- a/core/src/test/resources/org/apache/calcite/test/SqlToRelConverterTest.xml
+++ b/core/src/test/resources/org/apache/calcite/test/SqlToRelConverterTest.xml
@@ -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>