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/05/01 13:53:02 UTC

[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #6175: Handle ScalarValue::Dictionary in add_to_row and update_avg_to_row

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


##########
datafusion/physical-expr/src/aggregate/sum.rs:
##########
@@ -546,4 +555,76 @@ mod tests {
             Arc::new(Float64Array::from(vec![1_f64, 2_f64, 3_f64, 4_f64, 5_f64]));
         generic_test_op!(a, DataType::Float64, Sum, ScalarValue::from(15_f64))
     }
+
+    fn row_aggregate(
+        array: &ArrayRef,
+        agg: Arc<dyn AggregateExpr>,
+        row_accessor: &mut RowAccessor,
+    ) -> Result<ScalarValue> {
+        let mut accum = agg.create_row_accumulator(0)?;
+        let scalar_value = ScalarValue::try_from_array(array, 0)?;
+
+        accum.update_scalar(&scalar_value, row_accessor)?;
+        accum.evaluate(row_accessor)
+    }
+
+    #[test]
+    fn sum_dictionary_f64() -> Result<()> {
+        let keys = Int32Array::from(vec![0, 1, 2, 3, 4]);

Review Comment:
   I recommend using keys that are different from values, to help improve the coverage.
   
   Also perhaps a repeated value rather that distinct values would help



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