alamb commented on issue #11594: URL: https://github.com/apache/datafusion/issues/11594#issuecomment-2242687644
Here is the full example from Discord: ```rust use datafusion::arrow::datatypes::{DataType, Field, Schema, TimeUnit}; use datafusion::optimizer::simplify_expressions::ExprSimplifier; use datafusion::{error::Result, prelude::*}; use datafusion_common::ToDFSchema; use datafusion_expr::execution_props::ExecutionProps; use datafusion_expr::simplify::SimplifyContext; #[tokio::main] async fn main() -> Result<()> { let schema = Schema::new(vec![make_field("i", DataType::Int64)]).to_dfschema_ref()?; let props = ExecutionProps::new(); let context = SimplifyContext::new(&props).with_schema(schema); let simplifier = ExprSimplifier::new(context); // i + (1 + 2) => i + 3 assert_eq!( simplifier.simplify(col("i") + (lit(1) + lit(2)))?, col("i") + lit(3) ); // i + 1 + 2 => i + 3 # not true. Why not? assert_eq!( simplifier.simplify(col("i") + lit(1) + lit(2))?, col("i") + lit(3) ); Ok(()) } fn make_field(name: &str, data_type: DataType) -> Field { let nullable = false; Field::new(name, data_type, nullable) } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org