-
Notifications
You must be signed in to change notification settings - Fork 165
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: Implement Spark-compatible CAST from String to Decimal #615
Conversation
We currently delegate to DataFusion when casting from string to decimal and there are some differences in behavior compared to Spark. This PR implements a Spark-compatible cast from String to Decimal.
@kevinmingtarja, thank you for helping me with a draft. Could you please take a look? |
@andygrove @vaibhawvipul Could you please take a look? |
Apologies @sujithjay I had missed this ping. I will review this early next week. |
Ok(Some(cast)) | ||
} | ||
|
||
/// Copied from arrow-rs, modified to replicate Spark's behavior |
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.
This comment is useful, thanks. Could you also update the comment to give a brief summary of what needed to change to replicate Spark's behavior?
This is looking good @sujithjay. CI is failing due to clippy warnings. If you run clippy locally you should be able to see the same warnings as well as suggestions for fixing. |
@sujithjay I took the liberty of fixing the clippy issues and fixing the conflicts |
let result: SparkResult<ArrayRef> = Ok(Arc::new(cast_array.finish()) as ArrayRef); | ||
result? |
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.
No need to wrap in a result and then unwrap.
let result: SparkResult<ArrayRef> = Ok(Arc::new(cast_array.finish()) as ArrayRef); | |
result? | |
Arc::new(cast_array.finish()) as ArrayRef |
@sujithjay I will close this PR for now since it has been inactive for a while. Feel free to reopen this or create a new PR if you continue work on this. |
Which issue does this PR close?
Closes #325.
Rationale for this change
We currently delegate to DataFusion when casting from string to decimal and there are some differences in behavior compared to Spark.
This PR implements a Spark-compatible cast from String to Decimal.
What changes are included in this PR?
An implementation of
parse_decimal
copied fromarrow-rs
, modified to be compatible with Spark's behavior.How are these changes tested?
CometCastSuite
now passes.cast.rs
.