You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2022/07/18 02:50:33 UTC

[GitHub] [calcite] hailin0 commented on a diff in pull request #2855: [CALCITE-5214] Implicit type conversion fails in union sql

hailin0 commented on code in PR #2855:
URL: https://github.com/apache/calcite/pull/2855#discussion_r922942312


##########
core/src/main/java/org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.java:
##########
@@ -436,11 +436,13 @@ private RelDataType getTightestCommonTypeOrThrow(
     // 2. VARCHAR has 65536 as default precision.
     // 3. Following MS-SQL: BINARY or BOOLEAN can be casted to VARCHAR.
     if (SqlTypeUtil.isAtomic(type1) && SqlTypeUtil.isCharacter(type2)) {
-      resultType = factory.createSqlType(SqlTypeName.VARCHAR);
+      resultType = factory.createTypeWithNullability(factory.createSqlType(SqlTypeName.VARCHAR),
+          type1.isNullable() || type2.isNullable());
     }
 
     if (SqlTypeUtil.isCharacter(type1) && SqlTypeUtil.isAtomic(type2)) {
-      resultType = factory.createSqlType(SqlTypeName.VARCHAR);
+      resultType = factory.createTypeWithNullability(factory.createSqlType(SqlTypeName.VARCHAR),
+          type1.isNullable() || type2.isNullable());
     }

Review Comment:
   https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.java#L543-L548
   
   Other type conversions already handle nullable settings in the getTightestCommonType method



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org