You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "Mark1626 (via GitHub)" <gi...@apache.org> on 2025/12/01 02:39:49 UTC

Re: [PR] fix: partition pruning stats pruning when multiple values are present [datafusion]

Mark1626 commented on code in PR #18923:
URL: https://github.com/apache/datafusion/pull/18923#discussion_r2575460532


##########
datafusion/common/src/pruning.rs:
##########
@@ -560,6 +560,79 @@ mod tests {
         assert_eq!(partition_stats.num_containers(), 2);
     }
 
+    #[test]
+    fn test_partition_pruning_statistics_multiple_positive_values() {
+        let partition_values = vec![
+            vec![ScalarValue::from(1i32), ScalarValue::from(2i32)],
+            vec![ScalarValue::from(3i32), ScalarValue::from(4i32)],
+        ];
+        let partition_fields = vec![
+            Arc::new(Field::new("a", DataType::Int32, false)),
+            Arc::new(Field::new("b", DataType::Int32, false)),
+        ];
+        let partition_stats =
+            PartitionPruningStatistics::try_new(partition_values, partition_fields)
+                .unwrap();
+
+        let column_a = Column::new_unqualified("a");
+
+        let values = HashSet::from([ScalarValue::from(1i32), ScalarValue::from(3i32)]);

Review Comment:
   Given the partition columns are `(a, b)`, the value of `partition_values` in the test represent two partitions `(a=1, b=2)` and `(a=3, b=4)`. 
   
   The `contained` is done on an array of column `a` values `[1, 3]`, and not a single tuple `(a=1, b=2)`. Which is why the result is `[true, true]`



-- 
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@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org