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

Yu Xu edited comment on CALCITE-7629 at 6/29/26 6:52 AM:
---------------------------------------------------------

It's strange; I wrote a few tests in BabelTest locally based on the main 
branch, but I don't seem to have reproduced the issue:
{code:java}
f.withSql("SELECT DATEDIFF(^EPOCH^, " + ts + ", " + ts2 + ")")
        .fails("'EPOCH' is not a valid time frame in 'DATEDIFF'");

f.withSql("SELECT ^DATEDIFF(day, " + ts + ", " + ts2 + ", " + ts + ")^")
        .fails("Invalid number of arguments to function 'DATEDIFF'. Was 
expecting 3 arguments");

f.withSql("SELECT ^DATEDIFF(A, " + ts + ")^")
        .fails("Invalid number of arguments to function 'DATEDIFF'. Was 
expecting 3 arguments");{code}


was (Author: JIRAUSER307770):
It's strange; I wrote a few tests in `BabelTest` locally based on the `main` 
branch, but I don't seem to have reproduced the issue:
{code:java}
f.withSql("SELECT DATEDIFF(^EPOCH^, " + ts + ", " + ts2 + ")")
        .fails("'EPOCH' is not a valid time frame in 'DATEDIFF'");

f.withSql("SELECT ^DATEDIFF(day, " + ts + ", " + ts2 + ", " + ts + ")^")
        .fails("Invalid number of arguments to function 'DATEDIFF'. Was 
expecting 3 arguments");

f.withSql("SELECT ^DATEDIFF(A, " + ts + ")^")
        .fails("Invalid number of arguments to function 'DATEDIFF'. Was 
expecting 3 arguments");{code}

> DATEDIFF is shown in error messages as TIMESTAMPDIFF
> ----------------------------------------------------
>
>                 Key: CALCITE-7629
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7629
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.42.0
>            Reporter: Mihai Budiu
>            Priority: Minor
>
> The parser uses SqlStdOperatorTable.TIMESTAMP_DIFF to represent DATEDIFF. In 
> consequence, programs that use DATEDIFF will actually unparse as 
> TIMESTAMPDIFF, and will report errors about TIMESTAMPDIFF, e.g.:
> SELECT(DATEDIFF(a, b)) FROM T
> will produce an error message like:
> Invalid number of arguments to function 'TIMESTAMPDIFF'. Was expecting 3 
> arguments
> This is confusing for the users.



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

Reply via email to