wuchong commented on a change in pull request #8730: 
[FLINK-12834][table-planner-blink] Support CharType and BinaryType
URL: https://github.com/apache/flink/pull/8730#discussion_r296087336
 
 

 ##########
 File path: 
flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/typeutils/TypeCoercion.scala
 ##########
 @@ -63,13 +64,14 @@ object TypeCoercion {
     */
   def canSafelyCast(
       from: LogicalType, to: LogicalType): Boolean = (from.getTypeRoot, 
to.getTypeRoot) match {
-    case (_, VARCHAR) => true
+    case (_, VARCHAR | CHAR) => true
 
     case (_, DECIMAL) if isNumeric(from) => true
 
-    case (_, _) if numericWideningPrecedence.contains(from) &&
-        numericWideningPrecedence.contains(to) =>
-      if (numericWideningPrecedence.indexOf(from) < 
numericWideningPrecedence.indexOf(to)) {
+    case (_, _) if numericWideningPrecedence.contains(from.copy(true)) &&
+        numericWideningPrecedence.contains(to.copy(true)) =>
+      if (numericWideningPrecedence.indexOf(from.copy(true)) <
+          numericWideningPrecedence.indexOf(to.copy(true))) {
 
 Review comment:
   What about add both NULLABLE and NOT NULL types to 
`numericWideningPrecedence`, so that we can avoid the verbose ` xx.copy(true)` 
in the code.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to