Skip to content

Commit 11c9789

Browse files
alambcomphead
andauthored
Add documentation example for PartitionPruningStatistics (#19020)
## Which issue does this PR close? - Follow on to #18923 ## Rationale for this change I was confused about the argument meaning to `PartitionPruningStatistics` so let's add an example ## What changes are included in this PR? Add a doc example ## Are these changes tested? By CI ## Are there any user-facing changes? New docs --------- Co-authored-by: Oleks V <[email protected]>
1 parent b402dff commit 11c9789

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

datafusion/common/src/pruning.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,36 @@ impl PartitionPruningStatistics {
169169
/// This must **not** be the schema of the entire file or table:
170170
/// instead it must only be the schema of the partition columns,
171171
/// in the same order as the values in `partition_values`.
172+
///
173+
/// # Example
174+
///
175+
/// To create [`PartitionPruningStatistics`] for two partition columns `a` and `b`,
176+
/// for three containers like this:
177+
///
178+
/// | a | b |
179+
/// | - | - |
180+
/// | 1 | 2 |
181+
/// | 3 | 4 |
182+
/// | 5 | 6 |
183+
///
184+
/// ```
185+
/// # use std::sync::Arc;
186+
/// # use datafusion_common::ScalarValue;
187+
/// # use arrow::datatypes::{DataType, Field};
188+
/// # use datafusion_common::pruning::PartitionPruningStatistics;
189+
///
190+
/// let partition_values = vec![
191+
/// vec![ScalarValue::from(1i32), ScalarValue::from(2i32)],
192+
/// vec![ScalarValue::from(3i32), ScalarValue::from(4i32)],
193+
/// vec![ScalarValue::from(5i32), ScalarValue::from(6i32)],
194+
/// ];
195+
/// let partition_fields = vec![
196+
/// Arc::new(Field::new("a", DataType::Int32, false)),
197+
/// Arc::new(Field::new("b", DataType::Int32, false)),
198+
/// ];
199+
/// let partition_stats =
200+
/// PartitionPruningStatistics::try_new(partition_values, partition_fields).unwrap();
201+
/// ```
172202
pub fn try_new(
173203
partition_values: Vec<Vec<ScalarValue>>,
174204
partition_fields: Vec<FieldRef>,

0 commit comments

Comments
 (0)