[ 
https://issues.apache.org/jira/browse/CALCITE-6023?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17768177#comment-17768177
 ] 

Julian Hyde commented on CALCITE-6023:
--------------------------------------

A query similar to yours works just fine:
{noformat}
diff --git a/core/src/test/resources/sql/winagg.iq 
b/core/src/test/resources/sql/winagg.iq
index 7304a00382..f1ce24e40a 100644
--- a/core/src/test/resources/sql/winagg.iq
+++ b/core/src/test/resources/sql/winagg.iq
@@ -98,6 +98,20 @@ order by 1;
 
 !ok
 
+select deptno, lead(count(*), -1) over (order by deptno) as x
+from emp
+group by deptno;
++--------+---+
+| DEPTNO | X |
++--------+---+
+|     10 |   |
+|     20 | 3 |
+|     30 | 5 |
++--------+---+
+(3 rows)
+
+!ok
+ {noformat}
I think the problem is that you are calling the parser and sql-to-rel-converter 
by hand and maybe not calling the validator.

Please change the summary to describe the minimum repro. "Possible bug found in 
Calcite" could describe all of our bugs. :)

> Possible bug found in SqlToRelConverter
> ---------------------------------------
>
>                 Key: CALCITE-6023
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6023
>             Project: Calcite
>          Issue Type: Bug
>    Affects Versions: 1.35.0
>            Reporter: Jordan Hannel
>            Priority: Major
>         Attachments: stacktrace.txt
>
>
> Hello all, I believe I have found a bug in SqlToRelConverter. The symptom and 
> repro are outlined below, and the full stacktrace is attached. This is on 
> calcite version 1.35.0. Any insight would be much appreciated, thanks!
> When I parse the below SQL string to get a SqlNode, and call 
> SqlToRelConverter.convertQuery on this SqlNode, I get error:
> ```
> UnsupportedOperationException: class org.apache.calcite.sql.SqlBasicCall: 
> LEAD(COUNT(*)) OVER (ORDER BY `dim4`)
> ```
> SQL:
> ```
> SELECT "dim4" AS "dim7", LEAD(COUNT(*), -1) OVER (ORDER BY "dim4") AS 
> "measure10" FROM ( SELECT "timestamp" AS "dim4" FROM "Shared.factDataset") AS 
> "t0" GROUP BY "dim4"
> ```
> I have confirmed that my SqlToRelConverter instance seems generally ok, 
> because it is able to convert many other SqlNodes to RelNodes. After some 
> experimentation, I noticed that just changing `ORDER BY "dim4"` to `ORDER BY 
> "t0"."dim4"` fixes the issue - after that, the SqlNode successfully is 
> translated to a RelNode.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to