-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move PruningPredicate to physical-optimizer crate #12037
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +17,13 @@ | |
|
||
//! Logical Expr types and traits for [DataFusion] | ||
//! | ||
//! This crate contains types and traits that are used by both Logical and Physical expressions. | ||
//! They are kept in their own crate to avoid physical expressions depending on logical expressions. | ||
//! | ||
//! This crate contains types and traits that are used by both Logical and | ||
//! Physical expressions. They are kept in their own crate to avoid physical | ||
//! expressions depending on logical expressions. | ||
//! | ||
//! Note this crate is not intended to have substantial logic itself, but rather | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added some additional explanation about this crate (partly as a justification about why it was ok to depend on in the physical optimizer) |
||
//! to provide a common set of types and traits that can be used by both logical | ||
//! and physical expressions. | ||
//! | ||
//! [DataFusion]: <https://crates.io/crates/datafusion> | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,5 @@ mod optimizer; | |
pub mod output_requirements; | ||
|
||
pub use optimizer::PhysicalOptimizerRule; | ||
|
||
pub mod pruning; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this was just to make the |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,28 +22,24 @@ | |
use std::collections::HashSet; | ||
use std::sync::Arc; | ||
|
||
use crate::{ | ||
common::{Column, DFSchema}, | ||
error::{DataFusionError, Result}, | ||
logical_expr::Operator, | ||
physical_plan::{ColumnarValue, PhysicalExpr}, | ||
}; | ||
|
||
use arrow::array::AsArray; | ||
use arrow::{ | ||
array::{new_null_array, ArrayRef, BooleanArray}, | ||
datatypes::{DataType, Field, Schema, SchemaRef}, | ||
record_batch::{RecordBatch, RecordBatchOptions}, | ||
}; | ||
use arrow_array::cast::AsArray; | ||
use datafusion_common::tree_node::TransformedResult; | ||
use datafusion_common::{ | ||
internal_err, plan_datafusion_err, plan_err, | ||
tree_node::{Transformed, TreeNode}, | ||
ScalarValue, | ||
Column, DFSchema, ScalarValue, | ||
}; | ||
use datafusion_common::{DataFusionError, Result}; | ||
use datafusion_physical_expr::utils::{collect_columns, Guarantee, LiteralGuarantee}; | ||
use datafusion_physical_expr::{expressions as phys_expr, PhysicalExprRef}; | ||
use datafusion_physical_expr::{expressions as phys_expr, PhysicalExpr, PhysicalExprRef}; | ||
|
||
use datafusion_expr_common::operator::Operator; | ||
use datafusion_physical_plan::ColumnarValue; | ||
use log::trace; | ||
|
||
/// A source of runtime statistical information to [`PruningPredicate`]s. | ||
|
@@ -615,7 +611,8 @@ impl PruningPredicate { | |
is_always_true(&self.predicate_expr) && self.literal_guarantees.is_empty() | ||
} | ||
|
||
pub(crate) fn required_columns(&self) -> &RequiredColumns { | ||
/// Return the columns that are required to evaluate the pruning predicate | ||
pub fn required_columns(&self) -> &RequiredColumns { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as it is in a different crate now this function needs to become pub, which I think is reasonable as it is part of the API Likewise the change to make |
||
&self.required_columns | ||
} | ||
|
||
|
@@ -724,7 +721,7 @@ fn is_always_true(expr: &Arc<dyn PhysicalExpr>) -> bool { | |
/// Handles creating references to the min/max statistics | ||
/// for columns as well as recording which statistics are needed | ||
#[derive(Debug, Default, Clone)] | ||
pub(crate) struct RequiredColumns { | ||
pub struct RequiredColumns { | ||
/// The statistics required to evaluate this predicate: | ||
/// * The unqualified column in the input schema | ||
/// * Statistics type (e.g. Min or Max or Null_Count) | ||
|
@@ -746,7 +743,7 @@ impl RequiredColumns { | |
/// * `a > 5 OR a < 10` returns `Some(a)` | ||
/// * `a > 5 OR b < 10` returns `None` | ||
/// * `true` returns None | ||
pub(crate) fn single_column(&self) -> Option<&phys_expr::Column> { | ||
pub fn single_column(&self) -> Option<&phys_expr::Column> { | ||
if self.columns.windows(2).all(|w| { | ||
// check if all columns are the same (ignoring statistics and field) | ||
let c1 = &w[0].0; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is a
a few lines down which adds an alias to the
pruning
module in its new home