Kristofferjoha commented on code in PR #27994:
URL: https://github.com/apache/datafusion/pull/27994#discussion_r4803214501


##########
datafusion/physical-plan/src/repartition/mod.rs:
##########
@@ -2871,6 +2970,61 @@ mod tests {
         );
     }
 
+    #[test]
+    fn unshared_output_charges_each_partition_for_its_own_rows() -> Result<()> 
{
+        let schema = Arc::new(Schema::new(vec![
+            Field::new("k", DataType::Int64, false),
+            Field::new("s", DataType::Utf8View, false),
+        ]));
+        let batch = RecordBatch::try_new(
+            Arc::clone(&schema),
+            vec![
+                Arc::new(Int64Array::from_iter_values(0..8192)),
+                Arc::new(StringViewArray::from_iter_values(
+                    (0..8192).map(|i| format!("{}{i}", "x".repeat(100))),
+                )),
+            ],
+        )?;
+        let input_size = get_record_batch_memory_size(&batch);
+
+        let metrics = ExecutionPlanMetricsSet::new();
+        let timer = MetricBuilder::new(&metrics).subset_time("test", 0);
+        let partition = |unshared: bool| -> Result<Vec<(usize, RecordBatch)>> {
+            let mut partitioner = BatchPartitioner::new_hash_partitioner(
+                vec![col("k", &schema)?],
+                8,
+                timer.clone(),
+            )?;
+            if unshared {
+                partitioner = partitioner.with_unshared_output();
+            }
+            partitioner.partition_iter(batch.clone())?.collect()
+        };
+        let total_size = |outputs: &[(usize, RecordBatch)]| -> usize {
+            outputs
+                .iter()
+                .map(|(_, batch)| get_record_batch_memory_size(batch))
+                .sum()
+        };
+
+        let shared = partition(false)?;
+        let unshared = partition(true)?;
+        assert_eq!(shared.len(), 8);
+        assert_eq!(shared, unshared);

Review Comment:
   uses fixed range split points now. 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