This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new 12c0a1e2e2 chore: Minor cleanup `simplify_demo()` example (#11576)
12c0a1e2e2 is described below
commit 12c0a1e2e21a750e2672bf3109e244836a12b399
Author: Kaviraj Kanagaraj <[email protected]>
AuthorDate: Mon Jul 22 14:27:07 2024 +0200
chore: Minor cleanup `simplify_demo()` example (#11576)
* chore: fix examples and comments
Signed-off-by: Kaviraj <[email protected]>
* remove unused `b` field
Signed-off-by: Kaviraj <[email protected]>
* fix the number of days
Signed-off-by: Kaviraj <[email protected]>
---------
Signed-off-by: Kaviraj <[email protected]>
---
datafusion-examples/examples/expr_api.rs | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
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)))
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]