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

Ruben Quesada Lopez commented on CALCITE-2714:
----------------------------------------------

My pleasure, [~julianhyde]. Thanks for your review.

> Make BasicSqlType immutable, and now createWithNullability re-uses existing 
> type if possible
> --------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-2714
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2714
>             Project: Calcite
>          Issue Type: Improvement
>            Reporter: Ruben Quesada Lopez
>            Assignee: Julian Hyde
>            Priority: Trivial
>             Fix For: 1.18.0
>
>
> As it is done in the parent implementation 
> RelDataTypeFactoryImpl#createTypeWithNullability where the parameter 'type' 
> is directly used as 'newType' if nullable matches:
> {code:java}
> public RelDataType createTypeWithNullability(final RelDataType type, final 
> boolean nullable) {
>   RelDataType newType;
>   if (type.isNullable() == nullable) {
>     newType = type;
>   } else ...
> {code}
> I think that SqlTypeFactoryImpl#createTypeWithNullability should be modified 
> in the same way when handling a BasicSqlType, to avoid calling 
> BasicSqlType#createWithNullability (which internally executes a clone) if 
> nullable matches:
> {code:java}
> public RelDataType createTypeWithNullability(final RelDataType type, final 
> boolean nullable) {
>   RelDataType newType;
>   if (type instanceof BasicSqlType) {
>     if (type.isNullable() == nullable) { // new piece of code
>       newType = type;
>     } else { // previously, this block was always executed
>       BasicSqlType sqlType = (BasicSqlType) type;
>       newType = sqlType.createWithNullability(nullable);
>     }
>   } else ...
> {code}
> I have verified, and Calcite Core unit tests run fine with this modification.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to