@@ -69,23 +69,21 @@ use regex::Regex;
6969///
7070/// For example:
7171/// ```
72- /// use arrow::datatypes::{Schema, Field, DataType};
73- /// use datafusion_expr::{col, lit};
72+ /// use arrow::datatypes::{DataType, Field, Schema};
7473/// use datafusion_common::{DataFusionError, ToDFSchema};
7574/// use datafusion_expr::execution_props::ExecutionProps;
7675/// use datafusion_expr::simplify::SimplifyContext;
76+ /// use datafusion_expr::{col, lit};
7777/// use datafusion_optimizer::simplify_expressions::ExprSimplifier;
7878///
7979/// // Create the schema
80- /// let schema = Schema::new(vec![
81- /// Field::new("i", DataType::Int64, false),
82- /// ])
83- /// .to_dfschema_ref().unwrap();
80+ /// let schema = Schema::new(vec![Field::new("i", DataType::Int64, false)])
81+ /// .to_dfschema_ref()
82+ /// .unwrap();
8483///
8584/// // Create the simplifier
8685/// let props = ExecutionProps::new();
87- /// let context = SimplifyContext::new(&props)
88- /// .with_schema(schema);
86+ /// let context = SimplifyContext::new(&props).with_schema(schema);
8987/// let simplifier = ExprSimplifier::new(context);
9088///
9189/// // Use the simplifier
@@ -144,35 +142,35 @@ impl<S: SimplifyInfo> ExprSimplifier<S> {
144142 ///
145143 /// ```
146144 /// use arrow::datatypes::DataType;
147- /// use datafusion_expr::{col, lit, Expr} ;
145+ /// use datafusion_common::DFSchema ;
148146 /// use datafusion_common::Result;
149147 /// use datafusion_expr::execution_props::ExecutionProps;
150148 /// use datafusion_expr::simplify::SimplifyContext;
151149 /// use datafusion_expr::simplify::SimplifyInfo;
150+ /// use datafusion_expr::{col, lit, Expr};
152151 /// use datafusion_optimizer::simplify_expressions::ExprSimplifier;
153- /// use datafusion_common::DFSchema;
154152 /// use std::sync::Arc;
155153 ///
156154 /// /// Simple implementation that provides `Simplifier` the information it needs
157155 /// /// See SimplifyContext for a structure that does this.
158156 /// #[derive(Default)]
159157 /// struct Info {
160- /// execution_props: ExecutionProps,
158+ /// execution_props: ExecutionProps,
161159 /// };
162160 ///
163161 /// impl SimplifyInfo for Info {
164- /// fn is_boolean_type(&self, expr: &Expr) -> Result<bool> {
165- /// Ok(false)
166- /// }
167- /// fn nullable(&self, expr: &Expr) -> Result<bool> {
168- /// Ok(true)
169- /// }
170- /// fn execution_props(&self) -> &ExecutionProps {
171- /// &self.execution_props
172- /// }
173- /// fn get_data_type(&self, expr: &Expr) -> Result<DataType> {
174- /// Ok(DataType::Int32)
175- /// }
162+ /// fn is_boolean_type(&self, expr: &Expr) -> Result<bool> {
163+ /// Ok(false)
164+ /// }
165+ /// fn nullable(&self, expr: &Expr) -> Result<bool> {
166+ /// Ok(true)
167+ /// }
168+ /// fn execution_props(&self) -> &ExecutionProps {
169+ /// &self.execution_props
170+ /// }
171+ /// fn get_data_type(&self, expr: &Expr) -> Result<DataType> {
172+ /// Ok(DataType::Int32)
173+ /// }
176174 /// }
177175 ///
178176 /// // Create the simplifier
@@ -198,7 +196,6 @@ impl<S: SimplifyInfo> ExprSimplifier<S> {
198196 /// optimizations.
199197 ///
200198 /// See [Self::simplify] for details and usage examples.
201- ///
202199 #[ deprecated(
203200 since = "48.0.0" ,
204201 note = "Use `simplify_with_cycle_count_transformed` instead"
@@ -222,7 +219,6 @@ impl<S: SimplifyInfo> ExprSimplifier<S> {
222219 /// - The number of simplification cycles that were performed
223220 ///
224221 /// See [Self::simplify] for details and usage examples.
225- ///
226222 pub fn simplify_with_cycle_count_transformed (
227223 & self ,
228224 mut expr : Expr ,
@@ -286,24 +282,24 @@ impl<S: SimplifyInfo> ExprSimplifier<S> {
286282 ///
287283 /// ```rust
288284 /// use arrow::datatypes::{DataType, Field, Schema};
289- /// use datafusion_expr::{col, lit, Expr};
290- /// use datafusion_expr::interval_arithmetic::{Interval, NullableInterval};
291285 /// use datafusion_common::{Result, ScalarValue, ToDFSchema};
292286 /// use datafusion_expr::execution_props::ExecutionProps;
287+ /// use datafusion_expr::interval_arithmetic::{Interval, NullableInterval};
293288 /// use datafusion_expr::simplify::SimplifyContext;
289+ /// use datafusion_expr::{col, lit, Expr};
294290 /// use datafusion_optimizer::simplify_expressions::ExprSimplifier;
295291 ///
296292 /// let schema = Schema::new(vec![
297- /// Field::new("x", DataType::Int64, false),
298- /// Field::new("y", DataType::UInt32, false),
299- /// Field::new("z", DataType::Int64, false),
300- /// ])
301- /// .to_dfschema_ref().unwrap();
293+ /// Field::new("x", DataType::Int64, false),
294+ /// Field::new("y", DataType::UInt32, false),
295+ /// Field::new("z", DataType::Int64, false),
296+ /// ])
297+ /// .to_dfschema_ref()
298+ /// .unwrap();
302299 ///
303300 /// // Create the simplifier
304301 /// let props = ExecutionProps::new();
305- /// let context = SimplifyContext::new(&props)
306- /// .with_schema(schema);
302+ /// let context = SimplifyContext::new(&props).with_schema(schema);
307303 ///
308304 /// // Expression: (x >= 3) AND (y + 2 < 10) AND (z > 5)
309305 /// let expr_x = col("x").gt_eq(lit(3_i64));
@@ -312,15 +308,18 @@ impl<S: SimplifyInfo> ExprSimplifier<S> {
312308 /// let expr = expr_x.and(expr_y).and(expr_z.clone());
313309 ///
314310 /// let guarantees = vec![
315- /// // x ∈ [3, 5]
316- /// (
317- /// col("x"),
318- /// NullableInterval::NotNull {
319- /// values: Interval::make(Some(3_i64), Some(5_i64)).unwrap()
320- /// }
321- /// ),
322- /// // y = 3
323- /// (col("y"), NullableInterval::from(ScalarValue::UInt32(Some(3)))),
311+ /// // x ∈ [3, 5]
312+ /// (
313+ /// col("x"),
314+ /// NullableInterval::NotNull {
315+ /// values: Interval::make(Some(3_i64), Some(5_i64)).unwrap(),
316+ /// },
317+ /// ),
318+ /// // y = 3
319+ /// (
320+ /// col("y"),
321+ /// NullableInterval::from(ScalarValue::UInt32(Some(3))),
322+ /// ),
324323 /// ];
325324 /// let simplifier = ExprSimplifier::new(context).with_guarantees(guarantees);
326325 /// let output = simplifier.simplify(expr).unwrap();
@@ -345,24 +344,24 @@ impl<S: SimplifyInfo> ExprSimplifier<S> {
345344 ///
346345 /// ```rust
347346 /// use arrow::datatypes::{DataType, Field, Schema};
348- /// use datafusion_expr::{col, lit, Expr};
349- /// use datafusion_expr::interval_arithmetic::{Interval, NullableInterval};
350347 /// use datafusion_common::{Result, ScalarValue, ToDFSchema};
351348 /// use datafusion_expr::execution_props::ExecutionProps;
349+ /// use datafusion_expr::interval_arithmetic::{Interval, NullableInterval};
352350 /// use datafusion_expr::simplify::SimplifyContext;
351+ /// use datafusion_expr::{col, lit, Expr};
353352 /// use datafusion_optimizer::simplify_expressions::ExprSimplifier;
354353 ///
355354 /// let schema = Schema::new(vec![
356- /// Field::new("a", DataType::Int64, false),
357- /// Field::new("b", DataType::Int64, false),
358- /// Field::new("c", DataType::Int64, false),
359- /// ])
360- /// .to_dfschema_ref().unwrap();
355+ /// Field::new("a", DataType::Int64, false),
356+ /// Field::new("b", DataType::Int64, false),
357+ /// Field::new("c", DataType::Int64, false),
358+ /// ])
359+ /// .to_dfschema_ref()
360+ /// .unwrap();
361361 ///
362362 /// // Create the simplifier
363363 /// let props = ExecutionProps::new();
364- /// let context = SimplifyContext::new(&props)
365- /// .with_schema(schema);
364+ /// let context = SimplifyContext::new(&props).with_schema(schema);
366365 /// let simplifier = ExprSimplifier::new(context);
367366 ///
368367 /// // Expression: a = c AND 1 = b
@@ -376,9 +375,9 @@ impl<S: SimplifyInfo> ExprSimplifier<S> {
376375 ///
377376 /// // If canonicalization is disabled, the expression is not changed
378377 /// let non_canonicalized = simplifier
379- /// .with_canonicalize(false)
380- /// .simplify(expr.clone())
381- /// .unwrap();
378+ /// .with_canonicalize(false)
379+ /// .simplify(expr.clone())
380+ /// .unwrap();
382381 ///
383382 /// assert_eq!(non_canonicalized, expr);
384383 /// ```
@@ -437,7 +436,6 @@ impl<S: SimplifyInfo> ExprSimplifier<S> {
437436 /// assert_eq!(simplified_expr.data, lit(true));
438437 /// // Only 1 cycle was executed
439438 /// assert_eq!(count, 1);
440- ///
441439 /// ```
442440 pub fn with_max_cycles ( mut self , max_simplifier_cycles : u32 ) -> Self {
443441 self . max_simplifier_cycles = max_simplifier_cycles;
0 commit comments