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

Julian Hyde commented on CALCITE-7275:
--------------------------------------

[~kramerul], You re-opened this case yesterday. I don't believe that the 
current summary, "DATEDIFF should be able to handle NULL values", is a current 
problem in Calcite. Can you either amend the summary or close this case.

> DATEDIFF should be able to handle NULL values
> ---------------------------------------------
>
>                 Key: CALCITE-7275
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7275
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Ulrich Kramer
>            Priority: Major
>
> Normally DATEDIFF handles NULL values by returning NULL.
> {noformat}
> SELECT DATEDIFF(day, NULL, '2024-01-15')        -- Result: NULL
> SELECT DATEDIFF(day, '2024-01-01', NULL)        -- Result: NULL
> SELECT DATEDIFF(day, NULL, NULL)                -- Result: NULL
> {noformat}
> But the builtin Method {{SqlFunctions.customDateDiff}} has only parameters 
> and a return code, which doesn't allow to handle this:
> {code}
>   public static int customDateDiff(DataContext root,
>       String timeFrameName, int date, int date2) 
> {code}
> {code:SQL}
> SELECT DATEDIFF(DAY,NULL,NULL)
> {code}
> generates invalid code:
> {noformat}
> ...
>             public Object current() {
>               return 
> Integer.valueOf(com.sap.sva.nucleus.resources.calcite.base.DateTimeUtil.dateDifference(org.apache.calcite.avatica.util.TimeUnitRange.DAY,
>  null, null));
>             }
> ...
> {noformat}



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

Reply via email to