grundprinzip commented on code in PR #38970:
URL: https://github.com/apache/spark/pull/38970#discussion_r1042952381
##########
connector/connect/server/src/main/scala/org/apache/spark/sql/connect/planner/SparkConnectPlanner.scala:
##########
@@ -518,9 +518,16 @@ class SparkConnectPlanner(session: SparkSession) {
}
private def transformCast(cast: proto.Expression.Cast): Expression = {
- Cast(
- transformExpression(cast.getExpr),
- DataTypeProtoConverter.toCatalystType(cast.getCastToType))
+ cast.getCastToTypeCase match {
+ case proto.Expression.Cast.CastToTypeCase.TYPE =>
+ Cast(
+ transformExpression(cast.getExpr),
+ DataTypeProtoConverter.toCatalystType(cast.getType))
+ case _ =>
+ Cast(
+ transformExpression(cast.getExpr),
+ session.sessionState.sqlParser.parseDataType(cast.getTypeStr))
Review Comment:
When I looked at cast as a unicorn in the context of expressions, it's one
of the few where not all argument types resolve to expressions. I was wondering
if we could simplify the approach to make the type argument of cast an
expression that can resolve as a string then we can do the matching of the
expression in the analyzer.
This is very similar to why you added the oneof to the proto message.
--
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]