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

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

{{mustSetNullability }} flag was introduced in CALCITE-2464 with the intention 
of optimizing recursive toSql calls when dealing with nested RelRecordTypes, 
but as pointed out by [~zhztheplayer], it leads to issues. I think we should 
probably remove it at all:
{code:java}
  /** Converts a type in Java format to a SQL-oriented type. */
  public static RelDataType toSql(final RelDataTypeFactory typeFactory,
      RelDataType type) {
    RelDataType sqlType = type;
    if (type instanceof RelRecordType) {
      sqlType = typeFactory.createStructType(
              Lists.transform(type.getFieldList(),
                field -> toSql(typeFactory, field.getType())),
              type.getFieldNames());
    } else if (type instanceof JavaType) {
      sqlType = typeFactory.createSqlType(type.getSqlTypeName());
    }
    return typeFactory.createTypeWithNullability(sqlType, type.isNullable());
  }
{code}

What do you think, [~zabetak]?

> Java-oriented field type is wrongly forced to be NOT NULL after being 
> converted to SQL-oriented
> -----------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-3029
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3029
>             Project: Calcite
>          Issue Type: Bug
>    Affects Versions: 1.19.0
>            Reporter: Hongze Zhang
>            Assignee: Hongze Zhang
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.20.0
>
>          Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> A Java-oriented field type loses its nullable constraint after calling method 
> {{org.apache.calcite.jdbc.JavaTypeFactoryImpl#toSql(org.apache.calcite.rel.type.RelDataType)}}.



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

Reply via email to