jovanm-db commented on code in PR #49340:
URL: https://github.com/apache/spark/pull/49340#discussion_r1904596927


##########
sql/api/src/main/scala/org/apache/spark/sql/types/UpCastRule.scala:
##########
@@ -41,10 +41,9 @@ private[sql] object UpCastRule {
     case (TimestampNTZType, TimestampType) => true
     case (TimestampType, TimestampNTZType) => true
 
-    case (_: AtomicType, CharType(_) | VarcharType(_)) => false
-    case (_: CalendarIntervalType, CharType(_) | VarcharType(_)) => false
-    case (_: AtomicType, _: StringType) => true
-    case (_: CalendarIntervalType, _: StringType) => true
+    case (s1: StringType, s2: StringType) => 
StringHelper.isMoreConstrained(s1, s2)
+    case (_: AtomicType, s: StringType) => StringHelper.isPlainString(s)

Review Comment:
   Should it be possible to upcast int to char/varchar?



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala:
##########
@@ -93,9 +93,9 @@ object Cast extends QueryErrorsBase {
 
     case (NullType, _) => true
 
-    case (_, CharType(_) | VarcharType(_)) => false
+    case (_, CharType(_) | VarcharType(_)) if 
!SQLConf.get.preserveCharVarcharTypeInfo => false

Review Comment:
   Without this change a test `"disallow type conversions between calendar 
interval type and char/varchar types"` in `CastSuiteBase.scala:1018` would 
fail. 



-- 
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: reviews-unsubscr...@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to