[AURON#1327] Implement native function of round#1426
Conversation
|
@richox @cxzl25 Could you please help review this PR? Thanks a lot! In #1327, I conducted a detailed comparison between |
zuston
left a comment
There was a problem hiding this comment.
looks good, if we could involve the more spark tests here, it will be better.
@zuston Thank you very much for reviewing the code. I have implemented the Spark validation logic based on your suggestions, and it runs as expected in local testing. |
round
Merged. Thanks for your contribution! @slfan1989 |
Thank you very much for reviewing the code! |
Which issue does this PR close?
Closes #1327.
Rationale for this change
spark_roundis a Rust implementation of an Apache Spark-style round function for the DataFusion query engine. Its primary purpose is to perform rounding operations on numerical values, adhering to Spark's HALF_UP rounding mode (i.e.,0.5rounds to1,-0.5rounds to-1). It supports multiple data types (Float64,Float32,Int16,Int32,Int64,Decimal128) and can handle negative precision and null values.What changes are included in this PR?
We implemented the Round function following Spark’s HALF_UP rounding semantics,
ensuring full behavioral alignment with Spark SQL.
For validation, we directly reused the unit tests from
MathExpressionsSuite#round/bround,comparing our implementation against Spark’s native results using:
behaves correctly under edge conditions such as large numbers, small numbers, and negative scales.
Are there any user-facing changes?
No.
How was this patch tested?
Unit Test.