Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion datafusion/macros/src/user_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ use syn::{parse_macro_input, DeriveInput, LitStr};
/// }
/// ```
/// will generate the following code
///
/// ```ignore
/// pub struct ToDateFunc {
/// signature: Signature,
Expand Down
4 changes: 0 additions & 4 deletions datafusion/optimizer/src/push_down_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,6 @@ fn push_down_join(
///
/// * `on_filters` filters from the join ON clause that have not already been
/// identified as join predicates
///
fn infer_join_predicates(
join: &Join,
predicates: &[Expr],
Expand Down Expand Up @@ -649,7 +648,6 @@ impl InferredPredicates {
/// * `predicates` the pushed down predicates
///
/// * `inferred_predicates` the inferred results
///
fn infer_join_predicates_from_predicates(
join_col_keys: &[(&Column, &Column)],
predicates: &[Expr],
Expand All @@ -673,7 +671,6 @@ fn infer_join_predicates_from_predicates(
/// identified as join predicates
///
/// * `inferred_predicates` the inferred results
///
fn infer_join_predicates_from_on_filters(
join_col_keys: &[(&Column, &Column)],
join_type: JoinType,
Expand Down Expand Up @@ -719,7 +716,6 @@ fn infer_join_predicates_from_on_filters(
///
/// * `ENABLE_RIGHT_TO_LEFT` indicates that the left table related predicate can
/// be inferred from the right table related predicate
///
fn infer_join_predicates_impl<
const ENABLE_LEFT_TO_RIGHT: bool,
const ENABLE_RIGHT_TO_LEFT: bool,
Expand Down
1 change: 0 additions & 1 deletion datafusion/optimizer/src/push_down_limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ use datafusion_expr::logical_plan::{Join, JoinType, Limit, LogicalPlan};
use datafusion_expr::{lit, FetchType, SkipType};

/// Optimization rule that tries to push down `LIMIT`.
///
//. It will push down through projection, limits (taking the smaller limit)
#[derive(Default, Debug)]
pub struct PushDownLimit {}
Expand Down
110 changes: 54 additions & 56 deletions datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,21 @@ use regex::Regex;
///
/// For example:
/// ```
/// use arrow::datatypes::{Schema, Field, DataType};
/// use datafusion_expr::{col, lit};
/// use arrow::datatypes::{DataType, Field, Schema};
/// use datafusion_common::{DataFusionError, ToDFSchema};
/// use datafusion_expr::execution_props::ExecutionProps;
/// use datafusion_expr::simplify::SimplifyContext;
/// use datafusion_expr::{col, lit};
/// use datafusion_optimizer::simplify_expressions::ExprSimplifier;
///
/// // Create the schema
/// let schema = Schema::new(vec![
/// Field::new("i", DataType::Int64, false),
/// ])
/// .to_dfschema_ref().unwrap();
/// let schema = Schema::new(vec![Field::new("i", DataType::Int64, false)])
/// .to_dfschema_ref()
/// .unwrap();
///
/// // Create the simplifier
/// let props = ExecutionProps::new();
/// let context = SimplifyContext::new(&props)
/// .with_schema(schema);
/// let context = SimplifyContext::new(&props).with_schema(schema);
/// let simplifier = ExprSimplifier::new(context);
///
/// // Use the simplifier
Expand Down Expand Up @@ -144,35 +142,35 @@ impl<S: SimplifyInfo> ExprSimplifier<S> {
///
/// ```
/// use arrow::datatypes::DataType;
/// use datafusion_expr::{col, lit, Expr};
/// use datafusion_common::DFSchema;
/// use datafusion_common::Result;
/// use datafusion_expr::execution_props::ExecutionProps;
/// use datafusion_expr::simplify::SimplifyContext;
/// use datafusion_expr::simplify::SimplifyInfo;
/// use datafusion_expr::{col, lit, Expr};
/// use datafusion_optimizer::simplify_expressions::ExprSimplifier;
/// use datafusion_common::DFSchema;
/// use std::sync::Arc;
///
/// /// Simple implementation that provides `Simplifier` the information it needs
/// /// See SimplifyContext for a structure that does this.
/// #[derive(Default)]
/// struct Info {
/// execution_props: ExecutionProps,
/// execution_props: ExecutionProps,
/// };
///
/// impl SimplifyInfo for Info {
/// fn is_boolean_type(&self, expr: &Expr) -> Result<bool> {
/// Ok(false)
/// }
/// fn nullable(&self, expr: &Expr) -> Result<bool> {
/// Ok(true)
/// }
/// fn execution_props(&self) -> &ExecutionProps {
/// &self.execution_props
/// }
/// fn get_data_type(&self, expr: &Expr) -> Result<DataType> {
/// Ok(DataType::Int32)
/// }
/// fn is_boolean_type(&self, expr: &Expr) -> Result<bool> {
/// Ok(false)
/// }
/// fn nullable(&self, expr: &Expr) -> Result<bool> {
/// Ok(true)
/// }
/// fn execution_props(&self) -> &ExecutionProps {
/// &self.execution_props
/// }
/// fn get_data_type(&self, expr: &Expr) -> Result<DataType> {
/// Ok(DataType::Int32)
/// }
/// }
///
/// // Create the simplifier
Expand All @@ -198,7 +196,6 @@ impl<S: SimplifyInfo> ExprSimplifier<S> {
/// optimizations.
///
/// See [Self::simplify] for details and usage examples.
///
#[deprecated(
since = "48.0.0",
note = "Use `simplify_with_cycle_count_transformed` instead"
Expand All @@ -222,7 +219,6 @@ impl<S: SimplifyInfo> ExprSimplifier<S> {
/// - The number of simplification cycles that were performed
///
/// See [Self::simplify] for details and usage examples.
///
pub fn simplify_with_cycle_count_transformed(
&self,
mut expr: Expr,
Expand Down Expand Up @@ -286,24 +282,24 @@ impl<S: SimplifyInfo> ExprSimplifier<S> {
///
/// ```rust
/// use arrow::datatypes::{DataType, Field, Schema};
/// use datafusion_expr::{col, lit, Expr};
/// use datafusion_expr::interval_arithmetic::{Interval, NullableInterval};
/// use datafusion_common::{Result, ScalarValue, ToDFSchema};
/// use datafusion_expr::execution_props::ExecutionProps;
/// use datafusion_expr::interval_arithmetic::{Interval, NullableInterval};
/// use datafusion_expr::simplify::SimplifyContext;
/// use datafusion_expr::{col, lit, Expr};
/// use datafusion_optimizer::simplify_expressions::ExprSimplifier;
///
/// let schema = Schema::new(vec![
/// Field::new("x", DataType::Int64, false),
/// Field::new("y", DataType::UInt32, false),
/// Field::new("z", DataType::Int64, false),
/// ])
/// .to_dfschema_ref().unwrap();
/// Field::new("x", DataType::Int64, false),
/// Field::new("y", DataType::UInt32, false),
/// Field::new("z", DataType::Int64, false),
/// ])
/// .to_dfschema_ref()
/// .unwrap();
///
/// // Create the simplifier
/// let props = ExecutionProps::new();
/// let context = SimplifyContext::new(&props)
/// .with_schema(schema);
/// let context = SimplifyContext::new(&props).with_schema(schema);
///
/// // Expression: (x >= 3) AND (y + 2 < 10) AND (z > 5)
/// let expr_x = col("x").gt_eq(lit(3_i64));
Expand All @@ -312,15 +308,18 @@ impl<S: SimplifyInfo> ExprSimplifier<S> {
/// let expr = expr_x.and(expr_y).and(expr_z.clone());
///
/// let guarantees = vec![
/// // x ∈ [3, 5]
/// (
/// col("x"),
/// NullableInterval::NotNull {
/// values: Interval::make(Some(3_i64), Some(5_i64)).unwrap()
/// }
/// ),
/// // y = 3
/// (col("y"), NullableInterval::from(ScalarValue::UInt32(Some(3)))),
/// // x ∈ [3, 5]
/// (
/// col("x"),
/// NullableInterval::NotNull {
/// values: Interval::make(Some(3_i64), Some(5_i64)).unwrap(),
/// },
/// ),
/// // y = 3
/// (
/// col("y"),
/// NullableInterval::from(ScalarValue::UInt32(Some(3))),
/// ),
/// ];
/// let simplifier = ExprSimplifier::new(context).with_guarantees(guarantees);
/// let output = simplifier.simplify(expr).unwrap();
Expand All @@ -345,24 +344,24 @@ impl<S: SimplifyInfo> ExprSimplifier<S> {
///
/// ```rust
/// use arrow::datatypes::{DataType, Field, Schema};
/// use datafusion_expr::{col, lit, Expr};
/// use datafusion_expr::interval_arithmetic::{Interval, NullableInterval};
/// use datafusion_common::{Result, ScalarValue, ToDFSchema};
/// use datafusion_expr::execution_props::ExecutionProps;
/// use datafusion_expr::interval_arithmetic::{Interval, NullableInterval};
/// use datafusion_expr::simplify::SimplifyContext;
/// use datafusion_expr::{col, lit, Expr};
/// use datafusion_optimizer::simplify_expressions::ExprSimplifier;
///
/// let schema = Schema::new(vec![
/// Field::new("a", DataType::Int64, false),
/// Field::new("b", DataType::Int64, false),
/// Field::new("c", DataType::Int64, false),
/// ])
/// .to_dfschema_ref().unwrap();
/// Field::new("a", DataType::Int64, false),
/// Field::new("b", DataType::Int64, false),
/// Field::new("c", DataType::Int64, false),
/// ])
/// .to_dfschema_ref()
/// .unwrap();
///
/// // Create the simplifier
/// let props = ExecutionProps::new();
/// let context = SimplifyContext::new(&props)
/// .with_schema(schema);
/// let context = SimplifyContext::new(&props).with_schema(schema);
/// let simplifier = ExprSimplifier::new(context);
///
/// // Expression: a = c AND 1 = b
Expand All @@ -376,9 +375,9 @@ impl<S: SimplifyInfo> ExprSimplifier<S> {
///
/// // If canonicalization is disabled, the expression is not changed
/// let non_canonicalized = simplifier
/// .with_canonicalize(false)
/// .simplify(expr.clone())
/// .unwrap();
/// .with_canonicalize(false)
/// .simplify(expr.clone())
/// .unwrap();
///
/// assert_eq!(non_canonicalized, expr);
/// ```
Expand Down Expand Up @@ -437,7 +436,6 @@ impl<S: SimplifyInfo> ExprSimplifier<S> {
/// assert_eq!(simplified_expr.data, lit(true));
/// // Only 1 cycle was executed
/// assert_eq!(count, 1);
///
/// ```
pub fn with_max_cycles(mut self, max_simplifier_cycles: u32) -> Self {
self.max_simplifier_cycles = max_simplifier_cycles;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
//! ```text
//! c1 > INT32(10)
//! ```
//!

use arrow::datatypes::DataType;
use datafusion_common::{internal_err, tree_node::Transformed};
Expand Down