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

Julian Hyde commented on CALCITE-5360:
--------------------------------------

I agree, custom time frames is difficult. I shouldn't have suggested it.

I believe that in BigQuery SQL, the {{INTERVAL}} keyword is part of the 
{{TIMESTAMP_ADD}} function whereas in ISO standard SQL (and Calcite SQL) the 
{{INTERVAL}} keyword introduces an interval literal (or an interval expression, 
e.g. "{{INTERVAL x + y SECOND}}").

I think that {{INTERVAL}} should NOT be part of Calcite's {{TIMESTAMP_ADD}} 
syntax. The function should take two arguments, separated by a comma, and the 
second argument is any value of type {{INTERVAL}}. For example, 
{{TIMESTAMP_ADD(ts, i)}} should be valid if {{ts}} and {{i}} are columns of 
type {{TIMESTAMP}} and {{INTERVAL HOUR TO SECOND}}.

Calcite already supports adding an interval to a timestamp. The effect of 
{{TIMESTAMP_ADD(ts, i)}} will be as if the user wrote {{ts + i}}.

> Implement BigQuery TIMESTAMP_ADD and TIMESTAMP_DIFF
> ---------------------------------------------------
>
>                 Key: CALCITE-5360
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5360
>             Project: Calcite
>          Issue Type: Sub-task
>          Components: core
>            Reporter: TJ Banghart
>            Assignee: TJ Banghart
>            Priority: Major
>
> Calcite already supports TIMESTAMPADD and TIMESTAMPDIFF. We should try 
> mapping the BQ style syntax to these already implemented functions.
> We did something similar for TIMESTAMP_TRUNC and TIME_TRUNC which 
> conveniently mapped to FLOOR in 
> [CALCITE-5269|https://issues.apache.org/jira/browse/CALCITE-5269]



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

Reply via email to