You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Mihai Budiu (Jira)" <ji...@apache.org> on 2025/09/02 16:03:00 UTC
[jira] [Resolved] (CALCITE-7146) TIMESTAMPDIFF accepts arguments with mismatched types
[ https://issues.apache.org/jira/browse/CALCITE-7146?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mihai Budiu resolved CALCITE-7146.
----------------------------------
Fix Version/s: 1.41.0
Resolution: Fixed
Fixed in https://github.com/apache/calcite/commit/b1c29f15ae2d8e4196a2ba35f321f1eb3276d75c
Thank you for the review [~jensen]
> 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
> Labels: pull-request-available
> Fix For: 1.41.0
>
>
> 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)