[
https://issues.apache.org/jira/browse/CALCITE-5662?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17714335#comment-17714335
]
Oliver Lee edited comment on CALCITE-5662 at 4/19/23 11:13 PM:
---------------------------------------------------------------
I've fixed the title of the JIRA ticket.
I have a PR to enable it but I just saw your comment about the SQL standard, I
went to verify and yes, the current behavior follows that (not allowing
cast(boolean as integer)
(PR for reference: https://github.com/apache/calcite/pull/3168)
Let me look into how we can toggle whether to enable it for certain dialects,
I'll comment again when I have the final PR ready
was (Author: JIRAUSER297744):
I've fixed the title of the JIRA ticket.
I have a PR to enable it but I just saw your comment about the SQL standard, I
went to verify and yes, the current behavior follows that.
(PR for reference: https://github.com/apache/calcite/pull/3168)
Let me look into how we can toggle whether to enable it for certain dialects,
I'll comment again when I have the final PR ready
> CAST(BOOLEAN as INTEGER) throws a NumberFormatException
> -------------------------------------------------------
>
> Key: CALCITE-5662
> URL: https://issues.apache.org/jira/browse/CALCITE-5662
> Project: Calcite
> Issue Type: Bug
> Reporter: Oliver Lee
> Assignee: Oliver Lee
> Priority: Minor
> Labels: pull-request-available
> Time Spent: 10m
> Remaining Estimate: 0h
>
> Currently attempting to run {{SELECT CAST(BOOLEAN as INTEGER)}} will throw a
> {{NumberFormatException}}.
> The BigQuery dialect allows casting {{boolean}} literals to the following:
> {{string}}, {{int64}} , {{tinyint}}, {{smallint}}, {{bigint}}
> src:
> https://cloud.google.com/bigquery/docs/reference/standard-sql/conversion_functions
>
> Desired behavior:
> {{SELECT CAST(TRUE as INTEGER)}} -> {{1}}
> {{SELECT CAST(TRUE as BIGINT)}} -> {{1}}
> {{SELECT CAST(FALSE as INTEGER)}} -> {{0}}
> {{SELECT CAST(null as INTEGER)}} -> {{null}}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)