[
https://issues.apache.org/jira/browse/CALCITE-7834?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Mihai Budiu resolved CALCITE-7834.
----------------------------------
Fix Version/s: 1.43.0
Resolution: Fixed
Fixed in
[https://github.com/apache/calcite/commit/0f8414c0bfda63930254103ee700b76bf200724a]
Thank you for your review [~xuzifu666]
> Type inferred for LAG/LEAD should (almost) always be nullable
> -------------------------------------------------------------
>
> Key: CALCITE-7834
> URL: https://issues.apache.org/jira/browse/CALCITE-7834
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.42.0
> Reporter: Mihai Budiu
> Assignee: Mihai Budiu
> Priority: Minor
> Labels: pull-request-available
> Fix For: 1.43.0
>
>
> The column produced by LAG/LEAD should always be nullable, but Calcite copies
> the input column type. As a result, the following quidem test crashes:
> {code:java}
> SELECT y, x, LAG(x, 1, 0) OVER (ORDER BY y) AS l
> FROM (VALUES (1, 10), (2, CAST(NULL AS INTEGER)), (3, 30)) AS t(y, x); {code}
> stack trace:
> {code:java}
> Caused by: org.apache.calcite.runtime.CalciteException: Cannot convert null
> to int
> at
> java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:67)
> at
> java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
> at
> java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:484)
> at
> org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:511)
> at org.apache.calcite.runtime.Resources$ExInst.ex(Resources.java:605)
> at
> org.apache.calcite.runtime.SqlFunctions.cannotConvert(SqlFunctions.java:5283)
> at org.apache.calcite.runtime.SqlFunctions.toInt(SqlFunctions.java:5464)
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)