mihaibudiu commented on code in PR #4024:
URL: https://github.com/apache/calcite/pull/4024#discussion_r1824811903


##########
core/src/main/java/org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.java:
##########
@@ -274,9 +274,10 @@ protected boolean needToCast(SqlValidatorScope scope, 
SqlNode node,
       return false;
     }
 
-    // No need to cast between char and varchar.
+    // No need to cast between char and unlimited varchar.
     if (SqlTypeUtil.isCharacter(toType)
-        && SqlTypeUtil.isCharacter(fromType)) {
+        && SqlTypeUtil.isCharacter(fromType)
+        && toType.getPrecision() == RelDataType.PRECISION_NOT_SPECIFIED) {

Review Comment:
   clearly, the original code is wrong. The comment says "varchar", but the 
code does not check for varchar. Here I have made the code match the comment, 
which seems correct. I haven't investigated what happens to binary objects. 
It's possible that this check is still not strong enough, but it is certainly 
better than it was, and it fixes the problem reported.
   
   In general, when fixing a bug, I am trying to make the minimal changes 
necessary to solve the problem reported, without breaking anything else. 
Calcite is very complex, as you can see, even a small change may affect lots of 
tests.



-- 
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