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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to