[
https://issues.apache.org/jira/browse/CALCITE-2714?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Julian Hyde resolved CALCITE-2714.
----------------------------------
Resolution: Fixed
Fixed in
[08aefb09|http://git-wip-us.apache.org/repos/asf/calcite/commit/08aefb09];
thanks for the PR, [~rubenql]!
> 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)