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

   ### Describe the bug
   
   When using a parameterized query with a placeholder indicating the value in 
the `LIMIT` clause, the datatype is not inferred.
   
   ### To Reproduce
   
   ```rust
   let schema = Arc::new(Schema::new(vec![Field::new("A", DataType::Int32, 
true)]));
   let source = Arc::new(LogicalTableSource::new(schema.clone()));
   
   let placeholder_value = "$1";
   
   // SELECT * FROM my_table LIMIT $1
   let plan = LogicalPlan::Limit(Limit {
       skip: None,
       fetch: Some(Box::new(Expr::Placeholder(Placeholder {
           id: placeholder_value.to_string(),
           data_type: None,
       }))),
       input: Arc::new(LogicalPlan::TableScan(TableScan {
           table_name: TableReference::from("my_table"),
           source,
           projected_schema: Arc::new(DFSchema::try_from(schema.clone())?),
           projection: None,
           filters: vec![],
           fetch: None,
       })),
   });
   
   let params = plan.get_parameter_types().expect("to infer type");
   assert_eq!(params.len(), 1);
   
   let parameter_type = params
       .clone()
       .get(placeholder_value)
       .expect("to get type")
       .clone();
   assert_eq!(parameter_type, Some(DataType::Int64));
   ```
   
   ```shell
   assertion `left == right` failed
     left: None
    right: Some(Int64)
   ```
   
   ### Expected behavior
   
   Assertion passes.
   
   ### Additional context
   
   _No response_


-- 
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.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