maropu commented on a change in pull request #30260:
URL: https://github.com/apache/spark/pull/30260#discussion_r520238225



##########
File path: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CastSuite.scala
##########
@@ -38,8 +38,11 @@ import org.apache.spark.unsafe.types.UTF8String
 
 abstract class CastSuiteBase extends SparkFunSuite with ExpressionEvalHelper {
 
+  // Whether this test suite is for checking AnsiCast or default Cast.
+  protected def isAnsiCast: Boolean
+
   // Whether it is required to set SQLConf.ANSI_ENABLED as true for testing 
numeric overflow.

Review comment:
       I feel the name `requiredAnsiEnabledForOverflowTestCases` is confusing, 
so could you rename it according to the current usage and update the comment 
above? 

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
##########
@@ -1770,6 +1782,64 @@ case class AnsiCast(child: Expression, dataType: 
DataType, timeZoneId: Option[St
     copy(timeZoneId = Option(timeZoneId))
 
   override protected val ansiEnabled: Boolean = true
+
+  override def canCast(from: DataType, to: DataType): Boolean = 
AnsiCast.canCast(from, to)
+}
+
+object AnsiCast {

Review comment:
       Could you leave some comments to summarize the current behaivour of the 
ANSI explicit cast as described in the PR description (references `section 6.13 
of the ANSI SQL standard` and differences from the standard, e.g., `Numeric <=> 
Boolean`) ?

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
##########
@@ -1753,6 +1759,12 @@ case class Cast(child: Expression, dataType: DataType, 
timeZoneId: Option[String
     copy(timeZoneId = Option(timeZoneId))
 
   override protected val ansiEnabled: Boolean = SQLConf.get.ansiEnabled
+
+  override def canCast(from: DataType, to: DataType): Boolean = if 
(ansiEnabled) {

Review comment:
       How about describing this new behaviour in the usage above of 
`ExpressionDescription`?




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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to