coderfender commented on code in PR #20593:
URL: https://github.com/apache/datafusion/pull/20593#discussion_r2969848232
##########
datafusion/spark/src/function/math/ceil.rs:
##########
@@ -73,11 +73,14 @@ impl ScalarUDFImpl for SparkCeil {
fn return_type(&self, arg_types: &[DataType]) -> Result<DataType> {
match &arg_types[0] {
- DataType::Decimal128(p, s) if *s > 0 => {
- let new_p = ((*p as i64) - (*s as i64) + 1).clamp(1, 38) as u8;
- Ok(DataType::Decimal128(new_p, 0))
+ DataType::Decimal128(p, s) => {
+ if *s > 0 {
+ let new_p = ((*p as i64) - (*s as i64) + 1).clamp(1, 38)
as u8;
+ Ok(DataType::Decimal128(new_p, 0))
+ } else {
+ Ok(DataType::Decimal128(*p, *s))
+ }
Review Comment:
this makes it clear :)
##########
datafusion/spark/src/function/math/ceil.rs:
##########
@@ -148,7 +148,7 @@ mod tests {
None,
]);
let args = vec![ColumnarValue::Array(Arc::new(input))];
- let result = spark_ceil(&args, &DataType::Int64).unwrap();
+ let result = spark_ceil(&args).unwrap();
Review Comment:
Never a good idea to unwrap in main code ! If you think an unsafe `unwrap`
is needed, please add a comment why the code is safe enough for us to do that
--
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]