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

Oliver Lee commented on CALCITE-5662:
-------------------------------------

I've pushed a commit to consolidate the lenient conformance methods (as we 
discussed we don't need such detailed configurability)

 

Regarding the assert, it looks like it is there to make sure we allow Calcite 
internals to rewrite and coerce operand types, even if the dialect doesn't 
allow explicit coercion for that set of types. 


I've added an override to allow for SqlTypeMapperRule input to needToCast(), 
and in the operand type coercion I'm passing in the lenient conformance rule. 
This will allow internals to cast / coerce types for boolean to integer, and 
more in the future as well. Let me know what you think. 

> 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)

Reply via email to