-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add support for TryCast expression in Spark 3.2 and 3.3 #416
Conversation
case UnaryExpression(child) if expr.prettyName == "trycast" => | ||
val timeZoneId = SQLConf.get.sessionLocalTimeZone | ||
handleCast(child, inputs, expr.dataType, Some(timeZoneId), "TRY") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this approach 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks @vaibhawvipul
@@ -617,50 +663,17 @@ object QueryPlanSerde extends Logging with ShimQueryPlanSerde with CometExprShim | |||
val value = cast.eval() | |||
exprToProtoInternal(Literal(value, dataType), inputs) | |||
|
|||
case UnaryExpression(child) if expr.prettyName == "trycast" => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just making sure whether it is trycast
, not try_cast
. Looks like Spark 3.4 is using try_cast
, haven't been able to find the source for Spark 3.3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it is trycast
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM pending CI
// https://github.com/apache/datafusion-comet/issues/374 | ||
val testTryCast = CometSparkSessionExtensions.isSpark34Plus | ||
|
||
// we now support the TryCast expression in Spark 3.2 and 3.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: This comment looks unnecessary.
Which issue does this PR close?
Closes #374 .
Rationale for this change
Improve compatibility with various versions of spark.
What changes are included in this PR?
Inclusion of trycast while pattern matching expr
How are these changes tested?
All test cases pass.