qstommyshu commented on code in PR #15743: URL: https://github.com/apache/datafusion/pull/15743#discussion_r2054082743
########## datafusion/sql/tests/sql_integration.rs: ########## @@ -4673,16 +4675,17 @@ fn test_infer_types_from_predicate() { } #[test] -fn test_infer_types_from_between_predicate() { - let sql = "SELECT id, age FROM person WHERE age BETWEEN $1 AND $2"; +fn test_prepare_statement_infer_types_from_between_predicate() { + let sql = "PREPARE my_plan AS SELECT id, age FROM person WHERE age BETWEEN $1 AND $2"; let plan = logical_plan(sql).unwrap(); assert_snapshot!( plan, @r#" - Projection: person.id, person.age - Filter: person.age BETWEEN $1 AND $2 - TableScan: person + Prepare: "my_plan" [] Review Comment: Hi @brayanjuls , I've taken a look at your tests. The reason why this happen is there is no parameters being passed to the sql, but the sql itself contains positional arguments like `$1` and `$2`, please refer to https://datafusion.apache.org/user-guide/sql/prepared_statements.html#inferred-types. The simple way you can fix it is by adding the position arguments type to the `sql` like how it was done in [`test_prepare_statement_to_plan_one_param`](https://github.com/apache/datafusion/blob/main/datafusion/sql/tests/sql_integration.rs). If you want to dig into the details about it, you can check [how planner parse `PREPARE` statement](https://github.com/apache/datafusion/blob/main/datafusion/sql/src/planner.rs) and transfer it into a logical plan. -- 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