[
https://issues.apache.org/jira/browse/CALCITE-5447?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Oliver Lee updated CALCITE-5447:
--------------------------------
Description:
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}}
WEEK(WEEKDAY) will have a follow up PR as well
https://issues.apache.org/jira/browse/CALCITE-5450
was:
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
Note: BigQuery says it'll support
* {{DAY}}
* {{WEEK}}
* {{{}WEEK(WEEKDAY){}}}following: {{{}SUNDAY{}}}, {{{}MONDAY{}}},
{{{}TUESDAY{}}}, {{{}WEDNESDAY{}}}, {{{}THURSDAY{}}}, {{{}FRIDAY{}}}, or
{{{}SATURDAY{}}}.
* {{ISOWEEK}}
* {{MONTH}}
* {{QUARTER}}
* {{YEAR}}
* {{ISOYEAR}}
but as of right now this ticket will only support
* {{DAY}}
* {{WEEK}}
* {{MONTH}}
* {{QUARTER}}
* {{YEAR}}
WEEK(WEEKDAY) will have a follow up PR as well
https://issues.apache.org/jira/browse/CALCITE-5450
I left out ISOWEEK, ISOYEAR for date_part because I'm experiencing some weird
behavior:
{quote}0: jdbc:avatica:remote:url=http://localhost:1> SELECT FLOOR(DATE
'2008-12-25' to ISOYEAR);
+------------+
| EXPR$0 |
+------------+
| 2008-12-19 |
+------------+
{quote}
whereas on BQ console
{quote}SELECT DATE_TRUNC(DATE '2008-12-25', ISOYEAR);
returns 2007-12-31{quote}
> 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
> Time Spent: 10m
> 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}}
>
> WEEK(WEEKDAY) will have a follow up PR as well
> https://issues.apache.org/jira/browse/CALCITE-5450
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)