You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2023/03/09 20:16:58 UTC

[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #5537: Minor: add the concise way for matching numerics

alamb commented on code in PR #5537:
URL: https://github.com/apache/arrow-datafusion/pull/5537#discussion_r1131544013


##########
datafusion/expr/src/type_coercion/aggregates.rs:
##########
@@ -314,77 +314,45 @@ pub fn sum_return_type(arg_type: &DataType) -> Result<DataType> {
 
 /// function return type of variance
 pub fn variance_return_type(arg_type: &DataType) -> Result<DataType> {
-    match arg_type {
-        DataType::Int8
-        | DataType::Int16
-        | DataType::Int32
-        | DataType::Int64
-        | DataType::UInt8
-        | DataType::UInt16
-        | DataType::UInt32
-        | DataType::UInt64
-        | DataType::Float32
-        | DataType::Float64 => Ok(DataType::Float64),
-        other => Err(DataFusionError::Plan(format!(
-            "VAR does not support {other:?}"
-        ))),
+    if NUMERICS.contains(&arg_type) {

Review Comment:
   🤔  this is very close to https://docs.rs/arrow/34.0.0/arrow/datatypes/enum.DataType.html#method.is_numeric except that is_numeric also includes Decimals.
   
   



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org