[
https://issues.apache.org/jira/browse/CALCITE-5757?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17729843#comment-17729843
]
Tanner Clary commented on CALCITE-5757:
---------------------------------------
[~julianhyde] Yeah I'm happy to verify the other functions, but I'm not sure
that the behavior you described is fully accurate. From what I can tell, it's
more about what arguments you supply the function. For instance, passing a
Calcite {{TIMESTAMP_LTZ}} to {{DATETIME_TRUNC}} should still return
{{TIMESTAMP_LTZ}} despite it being a datetime function.
> Incorrect return type for BigQuery TRUNC functions
> --------------------------------------------------
>
> Key: CALCITE-5757
> URL: https://issues.apache.org/jira/browse/CALCITE-5757
> Project: Calcite
> Issue Type: Bug
> Reporter: Tanner Clary
> Assignee: Tanner Clary
> Priority: Major
> Labels: pull-request-available
>
> This is written in Calcite terms, a Calcite {{TIMESTAMP}} is a BigQuery
> {{DATETIME}} and a Calcite {{TIMESTAMP_LTZ}} is a BigQuery {{TIMESTAMP}}
> Some BigQuery operators, such as {{TIMESTAMP_TRUNC}}, currently have their
> return type set to {{TIMESTAMP_NULLABLE}}. This causes behavior which does
> not mirror BigQuery. {{TIMESTAMP_TRUNC}} can accept either a {{TIMESTAMP}} or
> a {{TIMESTAMP_LTZ}} and the return type should match the operand type (i.e.
> the return type should be ARG0}}.
> This can lead to discrepancies with queries like the following:
> {{SELECT CAST(TIMESTAMP_TRUNC([some TIMESTAMP_LTZ], MONTH) AS TIMESTAMP)}}
> because {{TIMESTAMP_TRUNC}} is currently implemented to return a
> {{TIMESTAMP}} the cast is deemed unnecessary and removed, when in reality the
> function should return a {{TIMESTAMP_LTZ}}, in which case the {{CAST}} is not
> redundant.
> The goal of this case is to adjust the return types of the BigQuery TRUNC
> functions so that they correctly align with BigQuery behavior.
> [Relevant
> Docs|https://cloud.google.com/bigquery/docs/reference/standard-sql/timestamp_functions#timestamp_trunc]
--
This message was sent by Atlassian Jira
(v8.20.10#820010)