Ulrich Kramer created CALCITE-7275:
--------------------------------------
Summary: 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
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)