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

TJ Banghart edited comment on CALCITE-5449 at 4/20/23 1:09 AM:
---------------------------------------------------------------

We could keep these as custom time unit if we had a way to unparse them as time 
unit identifiers. They are treated as string literals so something like 
{{MINUTE15}} would unparse as {{'MINUTE15'}}. 

I'm not sure how we'd translate something like {{MINUTE15}} into an equivalent 
expression the target dialect would recognize but it would be a pretty neat 
feature for Calcite. The translation from {{ISOWEEK}} and {{WEEK(WEEKDAY)}} to 
SQL would be simpler as those are more common and can be solved by overriding 
{{unparseCall}} for the dialect. 

I'd imagine custom timeframes to SQL translation warrants its own Jira case.


was (Author: tjbanghart):
We could keep these as custom time unit if we had a way to unparse them as time 
unit identifiers. They are treated as string literals so something like 
{{MINUTE15}} would unparse as {{'MINUTE15'}}. 

I'm not sure how we'd translate something like {{MINUTE15}} into an equivalent 
expression the target dialect would recognize but it would be a pretty neat 
feature for Calcite. The translation from {{ISOWEEK}} and {{WEEK(WEEKDAY)}} to 
SQL would be simpler as those are more common - and can be solved by overriding 
{{unparseCall}} for the dialect. 

I'd imagine custom timeframes to SQL translation warrants its own Jira case.

> Allow EXTRACT() to accept ISOWEEK and WEEK(WEEKDAY)
> ---------------------------------------------------
>
>                 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
>              Labels: pull-request-available
>          Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> 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