mohitgurav20 commented on code in PR #27196:
URL: https://github.com/apache/datafusion/pull/27196#discussion_r4732220055


##########
datafusion/physical-plan/src/aggregates/order/mod.rs:
##########
@@ -215,12 +216,18 @@ mod tests {
             
GroupClustering::Partial(GroupClusteringPartial::try_new(grouping_indices)?);
         assert_eq!(group_clustering.size(), expected);
 
-        // A variable-width key checks both the scalar descriptor and its 
payload.
+        // A variable-width key checks retained sort-key capacity, the scalar
+        // slots, and the scalar payload.
         let key = "retained group key";
         let batch_group_values: Vec<ArrayRef> =
             vec![Arc::new(StringArray::from(vec!["a", key]))];
         group_clustering.new_groups(&batch_group_values, &[0, 1], 2)?;
-        let in_progress = expected + 
ScalarValue::Utf8(Some(key.to_owned())).size();
+        let group_key = get_row_at_idx(&batch_group_values, 1)?;
+        // `size_of_vec` includes the inline Vec descriptor, which
+        // `GroupClustering::size` already charges via `size_of::<Self>()`.
+        let retained_sort_key =
+            ScalarValue::size_of_vec(&group_key) - 
size_of::<Vec<ScalarValue>>();
+        let in_progress = expected + retained_sort_key;
         assert_eq!(group_clustering.size(), in_progress);

Review Comment:
   also added the reset() check with a live key in 
test_size_partial_retained_allocations, then refilled it before input_done() so 
both transitions are asserted.



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