gengliangwang commented on code in PR #39855:
URL: https://github.com/apache/spark/pull/39855#discussion_r1093799136


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala:
##########
@@ -2511,40 +2511,41 @@ case class UpCast(child: Expression, target: 
AbstractDataType, walkedTypePath: S
  */
 case class CheckOverflowInTableInsert(child: Expression, columnName: String)
     extends UnaryExpression {
-  checkChild(child)
-
-  private def checkChild(child: Expression): Unit = child match {
-    case _: Cast =>
-    case ExpressionProxy(c, _, _) if c.isInstanceOf[Cast] =>
-    case _ =>
-      throw SparkException.internalError("Child is not Cast or ExpressionProxy 
of Cast")
-  }
 
   override protected def withNewChildInternal(newChild: Expression): 
Expression = {
-    checkChild(newChild)
     copy(child = newChild)
   }
 
-  private def getCast: Cast = child match {
+  private def getCast: Option[Cast] = child match {
     case c: Cast =>
-      c
+      Some(c)
     case ExpressionProxy(c, _, _) =>
-      c.asInstanceOf[Cast]
+      Some(c.asInstanceOf[Cast])

Review Comment:
   How about 
   ```
   case ExpressionProxy(c: Cast, _, _) =>
         Some(c)
   ```



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


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

Reply via email to