Placeholder datatype not inferred after `LIMIT` clause
- Dominant language
- Rust
- Stars
- 9.3k
- Forks
- 2.4k
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 344
Description
### 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_
Contributor guide
Research direction
Start at LogicalPlan::Limit and Expr::Placeholder, then trace get_parameter_types() for the LIMIT fetch expression. Reproduce the issue with the Rust example in the report and verify that the placeholder map contains Some(DataType::Int64), so the assertion passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100