This is an automated email from the ASF dual-hosted git repository.

adriangb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new ad100fbd66 chore: replace Schema with SchemaRef in 
PruningExpressionBuilder (#17216)
ad100fbd66 is described below

commit ad100fbd663eee85d1e1105cff338a21f33b9855
Author: Eugene Tolbakov <ev.tolba...@gmail.com>
AuthorDate: Mon Aug 25 13:55:42 2025 +0100

    chore: replace Schema with SchemaRef in PruningExpressionBuilder (#17216)
---
 datafusion/pruning/src/pruning_predicate.rs | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/datafusion/pruning/src/pruning_predicate.rs 
b/datafusion/pruning/src/pruning_predicate.rs
index fa1a8515b2..13490ebff6 100644
--- a/datafusion/pruning/src/pruning_predicate.rs
+++ b/datafusion/pruning/src/pruning_predicate.rs
@@ -457,7 +457,7 @@ impl PruningPredicate {
     /// details.
     pub fn try_new(expr: Arc<dyn PhysicalExpr>, schema: SchemaRef) -> 
Result<Self> {
         // Get a (simpler) snapshot of the physical expr here to use with 
`PruningPredicate`
-        // which does not handle dynamic exprs  in general
+        // which does not handle dynamic exprs in general
         let expr = snapshot_physical_expr(expr)?;
         let unhandled_hook = 
Arc::new(ConstantUnhandledPredicateHook::default()) as _;
 
@@ -465,7 +465,7 @@ impl PruningPredicate {
         let mut required_columns = RequiredColumns::new();
         let predicate_expr = build_predicate_expression(
             &expr,
-            schema.as_ref(),
+            &schema,
             &mut required_columns,
             &unhandled_hook,
         );
@@ -520,9 +520,9 @@ impl PruningPredicate {
                     // If `contained` returns false, that means the column is
                     // not any of the values so we can prune the container
                     Guarantee::In => builder.combine_array(&results),
-                    // `NotIn` means the values in the column must must not be
+                    // `NotIn` means the values in the column must not be
                     // any of the values in the set for the predicate to
-                    // evaluate to true. If contained returns true, it means 
the
+                    // evaluate to true. If `contained` returns true, it means 
the
                     // column is only in the set of values so we can prune the
                     // container
                     Guarantee::NotIn => {
@@ -876,7 +876,7 @@ impl From<Vec<(phys_expr::Column, StatisticsType, Field)>> 
for RequiredColumns {
 
 /// Build a RecordBatch from a list of statistics, creating arrays,
 /// with one row for each PruningStatistics and columns specified in
-/// in the required_columns parameter.
+/// the required_columns parameter.
 ///
 /// For example, if the requested columns are
 /// ```text
@@ -960,7 +960,7 @@ impl<'a> PruningExpressionBuilder<'a> {
         left: &'a Arc<dyn PhysicalExpr>,
         right: &'a Arc<dyn PhysicalExpr>,
         op: Operator,
-        schema: &'a Schema,
+        schema: &'a SchemaRef,
         required_columns: &'a mut RequiredColumns,
     ) -> Result<Self> {
         // find column name; input could be a more complicated expression
@@ -978,8 +978,7 @@ impl<'a> PruningExpressionBuilder<'a> {
                 }
             };
 
-        // TODO pass in SchemaRef so we don't need to clone the schema
-        let df_schema = DFSchema::try_from(schema.clone())?;
+        let df_schema = DFSchema::try_from(Arc::clone(schema))?;
         let (column_expr, correct_operator, scalar_expr) = 
rewrite_expr_to_prunable(
             column_expr,
             correct_operator,
@@ -1369,7 +1368,7 @@ impl PredicateRewriter {
         let mut required_columns = RequiredColumns::new();
         build_predicate_expression(
             expr,
-            schema,
+            &Arc::new(schema.clone()),
             &mut required_columns,
             &self.unhandled_hook,
         )
@@ -1387,7 +1386,7 @@ impl PredicateRewriter {
 /// Notice: Does not handle [`phys_expr::InListExpr`] greater than 20, which 
will fall back to calling `unhandled_hook`
 fn build_predicate_expression(
     expr: &Arc<dyn PhysicalExpr>,
-    schema: &Schema,
+    schema: &SchemaRef,
     required_columns: &mut RequiredColumns,
     unhandled_hook: &Arc<dyn UnhandledPredicateHook>,
 ) -> Arc<dyn PhysicalExpr> {
@@ -5131,7 +5130,12 @@ mod tests {
     ) -> Arc<dyn PhysicalExpr> {
         let expr = logical2physical(expr, schema);
         let unhandled_hook = 
Arc::new(ConstantUnhandledPredicateHook::default()) as _;
-        build_predicate_expression(&expr, schema, required_columns, 
&unhandled_hook)
+        build_predicate_expression(
+            &expr,
+            &Arc::new(schema.clone()),
+            required_columns,
+            &unhandled_hook,
+        )
     }
 
     #[test]


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@datafusion.apache.org
For additional commands, e-mail: commits-h...@datafusion.apache.org

Reply via email to