Skip to content

Conversation

@vaibhawvipul
Copy link
Contributor

@vaibhawvipul vaibhawvipul commented May 11, 2024

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.

@vaibhawvipul vaibhawvipul marked this pull request as ready for review May 15, 2024 10:40
Comment on lines +666 to +668
case UnaryExpression(child) if expr.prettyName == "trycast" =>
val timeZoneId = SQLConf.get.sessionLocalTimeZone
handleCast(child, inputs, expr.dataType, Some(timeZoneId), "TRY")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this approach 👍

@vaibhawvipul vaibhawvipul requested a review from andygrove May 15, 2024 15:36
Copy link
Member

@andygrove andygrove left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @vaibhawvipul

@andygrove andygrove requested a review from viirya May 15, 2024 17:05
val value = cast.eval()
exprToProtoInternal(Literal(value, dataType), inputs)

case UnaryExpression(child) if expr.prettyName == "trycast" =>
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it is trycast.

Copy link
Contributor

@kazuyukitanimura kazuyukitanimura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM pending CI

@andygrove andygrove merged commit ddf6a6f into apache:main May 15, 2024
@vaibhawvipul vaibhawvipul deleted the issue-374 branch May 16, 2024 01:43
// 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
Copy link
Member

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.

himadripal pushed a commit to himadripal/datafusion-comet that referenced this pull request Sep 7, 2024
…#416)

* working on trycast

* code refactor

* compilation fix

* bug fixes and supporting try_Cast

* removing trycast var and comment

* removing issue comment

* adding comments

(cherry picked from commit ddf6a6f)
himadripal pushed a commit to himadripal/datafusion-comet that referenced this pull request Sep 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for TryCast expression in Spark 3.2 and 3.3

4 participants