You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/11/12 16:34:59 UTC

[GitHub] [spark] grundprinzip commented on a diff in pull request #38634: [WIP] [CONNECT] Support Cast and DataTypes as Literals

grundprinzip commented on code in PR #38634:
URL: https://github.com/apache/spark/pull/38634#discussion_r1020780715


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala:
##########
@@ -499,6 +506,9 @@ case class Cast(
   def this(child: Expression, dataType: DataType, timeZoneId: Option[String]) =
     this(child, dataType, timeZoneId, evalMode = EvalMode.fromSQLConf(SQLConf.get))
 
+  def this(child: Expression, dt: Expression) =

Review Comment:
   This is the probably most interesting part of this change. Here, we simply use the output type of the expression to determine what the target type of the type cast is.
   
   There is a similar piece of code in the `from_json` function which takes an expression as the second parameter for the schema, but evaluates it to string and then parses the string into the type.



-- 
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-unsubscribe@spark.apache.org

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


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