Skip to content

Apache DataFusion SQL Query Engine

chore: Minor cleanup `simplify_demo()` example (#11576)

Kaviraj Kanagaraj12c0a1e2e21a
diff --git a/datafusion-examples/examples/expr_api.rs b/datafusion-examples/examples/expr_api.rs
index a5cf7011f8..a48171c625 100644
--- a/datafusion-examples/examples/expr_api.rs
+++ b/datafusion-examples/examples/expr_api.rs
@@ -177,16 +177,12 @@ fn simplify_demo() -> Result<()> {
);
// here are some other examples of what DataFusion is capable of
- let schema = Schema::new(vec![
- make_field("i", DataType::Int64),
- make_field("b", DataType::Boolean),
- ])
- .to_dfschema_ref()?;
+ let schema = Schema::new(vec![make_field("i", DataType::Int64)]).to_dfschema_ref()?;
let context = SimplifyContext::new(&props).with_schema(schema.clone());
let simplifier = ExprSimplifier::new(context);
// basic arithmetic simplification
- // i + 1 + 2 => a + 3
+ // i + 1 + 2 => i + 3
// (note this is not done if the expr is (col("i") + (lit(1) + lit(2))))
assert_eq!(
simplifier.simplify(col("i") + (lit(1) + lit(2)))?,
@@ -209,7 +205,7 @@ fn simplify_demo() -> Result<()> {
);
// String --> Date simplification
- // `cast('2020-09-01' as date)` --> 18500
+ // `cast('2020-09-01' as date)` --> 18506 # number of days since epoch 1970-01-01
assert_eq!(
simplifier.simplify(lit("2020-09-01").cast_to(&DataType::Date32, &schema)?)?,
lit(ScalarValue::Date32(Some(18506)))