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

Tanner Clary commented on CALCITE-5449:
---------------------------------------

[~julianhyde] From what I can tell, Calcite currently extracts the week from a 
date using Avatica's {{julianExtract()}} method which for {{WEEK}} returns the 
{{Iso8601}} week number. This means that the call {{EXTRACT(WEEK FROM DATE 
...)}} would actually return the isoweek number. This conflicts with BigQuery, 
who considers the start of the week to be on Sunday. In the [BQ docs| 
https://cloud.google.com/bigquery/docs/reference/standard-sql/date_functions#extract],
 all the example queries for {{ISOWEEK}} provide the response that Calcite 
would provide for {{WEEK}}.

 Let me know how you would like to handle this. One solution I can think of is 
adding another method to the DateTimeUtils class which would return the 
'BigQuery' WEEK answer (modified logic from Monday->Sunday), although I am not 
sure of the practicality of this. Thanks.

> Implement EXTRACT() Function for BigQuery
> -----------------------------------------
>
>                 Key: CALCITE-5449
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5449
>             Project: Calcite
>          Issue Type: Sub-task
>            Reporter: Tanner Clary
>            Assignee: Tanner Clary
>            Priority: Major
>
> Implement BigQuery {{EXTRACT()}} Function. {{EXTRACT(part FROM 
> date_expression)}} returns the value from the date_expression corresponding 
> to the specified part. Calcite currently supports PostgreSQL' {{DATE_PART}} 
> which has similar behavior.
> Example: {{SELECT EXTRACT(DAY FROM DATE '2013-12-25')}} would return 25.
> [BigQuery 
> Docs|https://g3doc.corp.google.com/company/teams/googlesql/reference/date_functions.md#extract
>  ]



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

Reply via email to