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

Mihai Budiu commented on CALCITE-7146:
--------------------------------------

I think the most sensible way to treat DATE - TIME (or vice-versa) is to 
(implicitly) cast the DATE to TIMESTAMP and then perform the arithmetic. This 
is probably what most users would expect. I will provide an implementation 
which does that.


> TIMESTAMPDIFF accepts arguments with mismatched types
> -----------------------------------------------------
>
>                 Key: CALCITE-7146
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7146
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.40.0
>            Reporter: Mihai Budiu
>            Assignee: Mihai Budiu
>            Priority: Minor
>
> Calcite will typecheck this:
> {code:sql}
> SELECT TIMESTAMPDIFF(DAY, DATE '2020-01-01', TIME '10:00:00')
> {code}
> and reduce it to 36000000 - 18262, subtracting days from milliseconds.
> One solution would be to reject arithmetic between DATE and TIME. Another 
> solution would be to treat this by casting both to TIMESTAMP. Of course, the 
> semantics of casting a TIME to TIMESTAMP is also not clearly defined - 
> currently Calcite seems to use Unix EPOCH for the DATE in such casts.



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

Reply via email to