[
https://issues.apache.org/jira/browse/CALCITE-2714?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Ruben Quesada Lopez updated CALCITE-2714:
-----------------------------------------
Description:
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.
was:
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 tests run fine with this modification.
> 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)