2010YOUY01 commented on code in PR #14399:
URL: https://github.com/apache/datafusion/pull/14399#discussion_r1938282667


##########
datafusion/functions-aggregate/src/median.rs:
##########
@@ -242,14 +242,26 @@ impl<T: ArrowNumericType> Debug for MedianAccumulator<T> {
 
 impl<T: ArrowNumericType> Accumulator for MedianAccumulator<T> {
     fn state(&mut self) -> Result<Vec<ScalarValue>> {
-        let all_values = self
-            .all_values
-            .iter()
-            .map(|x| ScalarValue::new_primitive::<T>(Some(*x), 
&self.data_type))
-            .collect::<Result<Vec<_>>>()?;
+        // Convert `all_values` to `ListArray` and return a single List 
ScalarValue
 
-        let arr = ScalarValue::new_list_nullable(&all_values, &self.data_type);
-        Ok(vec![ScalarValue::List(arr)])
+        // Build offsets
+        let offsets =
+            OffsetBuffer::new(ScalarBuffer::from(vec![0, self.all_values.len() 
as i32]));
+
+        // Build inner array
+        let values_array =
+            
PrimitiveArray::<T>::new(ScalarBuffer::from(self.all_values.clone()), None)

Review Comment:
   updated, thanks!



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

Reply via email to