lvheyang commented on a change in pull request #716:
URL: https://github.com/apache/arrow-datafusion/pull/716#discussion_r668760430



##########
File path: datafusion/src/physical_plan/functions.rs
##########
@@ -468,7 +468,15 @@ pub fn return_type(
         | BuiltinScalarFunction::Sin
         | BuiltinScalarFunction::Sqrt
         | BuiltinScalarFunction::Tan
-        | BuiltinScalarFunction::Trunc => Ok(DataType::Float64),
+        | BuiltinScalarFunction::Trunc => {
+            if arg_types.len() <= 0 {
+                return Err(DataFusionError::Internal(String::from(
+                    "Builtin Scalar Function does not support empty arguments",
+                )));
+            }
+            // return the same type as the input argument
+            return Ok(arg_types.get(0).unwrap().clone());

Review comment:
       Yes, the code cannot work because of type coercion rules. I checked the 
rules, it really supports int as input args type. Thus here we cannot return an 
error when the input type is not Float32 or Float64.
   
   So I kept the default return type, but add a float32 match arm as a special 
case.
   
   And I also changed the behavior of ColumnarValue::Scalar  to be the same as 
ColumnarValue::Array(array). The test case passed this time.  >_<




-- 
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]


Reply via email to