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

Julian Hyde commented on CALCITE-2714:
--------------------------------------

This change looks good, but can you try going a little further: in 
{{BasicSqlType}} make the fields {{collation}} and {{wrappedCharset}} final, 
deprecate {{BasicSqlType.clone}} (because it is now immutable), and stop 
calling {{clone}}. You will probably need to change the private constructor.

[~tedxu], FYI, since you're looking at charset support right now.

> Slight optimization in SqlTypeFactoryImpl#createTypeWithNullability
> -------------------------------------------------------------------
>
>                 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
>
> 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