You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "brayanjuls (via GitHub)" <gi...@apache.org> on 2025/05/10 17:04:13 UTC

[I] Include datatypes in logicalplan for inferred statements [datafusion]

brayanjuls opened a new issue, #16018:
URL: https://github.com/apache/datafusion/issues/16018

   Given a prepare statement: `PREPARE my_plan AS SELECT id, age FROM person WHERE age BETWEEN $1 AND $2`
   
   The generated logical plan would look like this:

   ``` 
   Prepare: "my_plan" [] 
     Projection: person.id, person.age
       Filter: person.age BETWEEN $1 AND $2
         TableScan: person
   ```	
   
   As you can see from the previous plan we don’t include the datatypes in it, so when we try to replace the params with values to assert the replacement it will fail. 
   
   replace params with values:
   ```rust
       let param_values = vec![ScalarValue::Int32(Some(10)), ScalarValue::Int32(Some(30))];
       let plan_with_params = plan.with_param_values(param_values).unwrap(); // This execution will fail as the input param values and the data types are of different size
   
       assert_snapshot!(
           plan_with_params,
           @r"
       Projection: person.id, person.age
         Filter: person.age BETWEEN Int32(10) AND Int32(30)
           TableScan: person
       "
       );
   ```
   
   It is expected the datatypes to be included in the logicalplan by inferring them when they are not explicitly declared. The discussion around this happened in the following [PR](https://github.com/apache/datafusion/pull/15743).


-- 
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-unsubscribe@datafusion.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [I] Include datatypes in logicalplan for inferred statements [datafusion]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb closed issue #16018: Include datatypes in logicalplan for inferred statements
URL: https://github.com/apache/datafusion/issues/16018


-- 
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-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org


Re: [I] Include datatypes in logicalplan for inferred statements [datafusion]

Posted by "brayanjuls (via GitHub)" <gi...@apache.org>.
brayanjuls commented on issue #16018:
URL: https://github.com/apache/datafusion/issues/16018#issuecomment-2869031591

   take


-- 
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-unsubscribe@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org