Apache DataFusion SQL Query Engine
chore: replace Schema with SchemaRef in PruningExpressionBuilder (#17216)
Eugene Tolbakovad100fbd663e
diff --git a/datafusion/pruning/src/pruning_predicate.rs b/datafusion/pruning/src/pruning_predicate.rsindex 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 generallet 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 containerGuarantee::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// containerGuarantee::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]