You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Fedir Petrukhin (Jira)" <ji...@apache.org> on 2023/03/08 17:27:00 UTC
[jira] [Commented] (CALCITE-5447) Add DATE_TRUNC for BigQuery
[ https://issues.apache.org/jira/browse/CALCITE-5447?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17698018#comment-17698018 ]
Fedir Petrukhin commented on CALCITE-5447:
------------------------------------------
Hi [~oliverlee]. I get parser error for redshift-style DATE_TRUNC function syntax. SQL expression example:
date_trunc('hour',cast('2023-02-27') as timestamp)
Error
Encountered "(" at line 1, column 23.
Was expecting:
")" ...
The Babel parser treats 'cast' as a time unit and expects closing parenthesis. When I remove keyword "CAST" from the "nonReservedKeywordsToAdd" - it works fine. Would it be right to replace TimeUnitOrName() pattern with something like TimeUnit()?
(
unit = TimeUnitOrName() \{ args.add(unit); }
|
AddExpression(args, ExprContext.ACCEPT_SUB_QUERY)
)
> Add DATE_TRUNC for BigQuery
> ---------------------------
>
> Key: CALCITE-5447
> URL: https://issues.apache.org/jira/browse/CALCITE-5447
> Project: Calcite
> Issue Type: Improvement
> Reporter: Oliver Lee
> Assignee: Oliver Lee
> Priority: Minor
> Labels: pull-request-available
> Fix For: 1.33.0
>
> Time Spent: 2h 20m
> Remaining Estimate: 0h
>
> Adding in BigQuery's definition of DATE_TRUNC as described [https://g3doc.corp.google.com/company/teams/googlesql/reference/date_functions.md?cl=head#date-trunc]
>
> ex.
> DATE_TRUNC('2022-01-05', month) -> 2022-01-01
> DATE_TRUNC('2022-01-05', day) -> 2022-01-05
> DATE_TRUNC('2022-01-05', year) -> 2022-01-01
>
>
> Supported parameters:
> * {{DAY}}
> * {{WEEK}}
> * {{{}WEEK(WEEKDAY){}}}following: {{{}SUNDAY{}}}, {{{}MONDAY{}}}, {{{}TUESDAY{}}}, {{{}WEDNESDAY{}}}, {{{}THURSDAY{}}}, {{{}FRIDAY{}}}, or {{{}SATURDAY{}}}.
> * {{ISOWEEK}}
> * {{MONTH}}
> * {{QUARTER}}
> * {{YEAR}}
> * {{ISOYEAR}}
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)