[ 
https://issues.apache.org/jira/browse/CALCITE-6382?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Mihai Budiu updated CALCITE-6382:
---------------------------------
    Description: 
Currently the LeadLag operator does not use the default value when inferring 
the type of a column.

For the following example:
{code:java}
SELECT lead(c * 2, 1, -1.4) OVER (PARTITION BY x ORDER BY c) FROM t
{code}
The column 'c' has type INTEGER, and Calcite infers a type of INTEGER for the 
result. However, the default value for the lead is -1.4, which is DECIMAL, so 
the result type should be DECIMAL.

Currently Calcite only uses the nullability of the default value, but not its 
type in the result type inference.

  was:
Currently the LeadLag operator does not use the default value when inferring 
the type of a column.

For the following example:
```
SELECT lead(c * 2, 1, -1.4) OVER (PARTITION BY x ORDER BY c) FROM t
```
The column 'c' has type INTEGER, and Calcite infers a type of INTEGER for the 
result. However, the default value for the lead is -1.4, which is DECIMAL, so 
the result type should be DECIMAL.

Currently Calcite only uses the nullability of the default value, but not its 
type in the result type inference.


> Type inference for SqlLeadLagAggFunction is incorrect
> -----------------------------------------------------
>
>                 Key: CALCITE-6382
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6382
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.36.0
>            Reporter: Mihai Budiu
>            Priority: Minor
>              Labels: pull-request-available
>
> Currently the LeadLag operator does not use the default value when inferring 
> the type of a column.
> For the following example:
> {code:java}
> SELECT lead(c * 2, 1, -1.4) OVER (PARTITION BY x ORDER BY c) FROM t
> {code}
> The column 'c' has type INTEGER, and Calcite infers a type of INTEGER for the 
> result. However, the default value for the lead is -1.4, which is DECIMAL, so 
> the result type should be DECIMAL.
> Currently Calcite only uses the nullability of the default value, but not its 
> type in the result type inference.



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

Reply via email to