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 , 
   
   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/2f7cc9beb15c467320e5baf75def0d79f9558ee2/datafusion/sql/tests/sql_integration.rs#L4828-L4855).
 If you want to dig into the details about it, you can check [how planner parse 
`PREPARE` 
statement](https://github.com/apache/datafusion/blob/2f7cc9beb15c467320e5baf75def0d79f9558ee2/datafusion/sql/src/planner.rs#L194-L208)
 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

Reply via email to