tshauck opened a new issue, #9093:
URL: https://github.com/apache/arrow-datafusion/issues/9093
### Describe the bug
This query: `SELECT array_position(a, 1) FROM test` will fail if `a` is a
list of int32s, due to `Error: Plan("array_position received incompatible
types: '[Int32, Int64]'.")`.
I understand that the value to find couldn't be found if `1` was actually a
number bigger than an i32 could old, but it seems to me this should try to
work, then fail in that case.
### To Reproduce
This script should repro:
```rust
use std::sync::Arc;
use datafusion::{
arrow::{
array::{Array, Int32Builder, ListBuilder},
datatypes::{Field, Fields, Schema},
},
datasource::MemTable,
execution::context::SessionContext,
};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut list_builder = ListBuilder::new(Int32Builder::new());
list_builder.append_value([Some(1), Some(2), Some(3)]);
list_builder.append(true);
let list_array = list_builder.finish();
let data_type = list_array.data_type();
let fields = Fields::from(vec![Field::new("a", data_type.clone(),
true)]);
let schema = Arc::new(Schema::new(fields));
let record_batch = datafusion::arrow::record_batch::RecordBatch::try_new(
schema.clone(),
vec![Arc::new(list_array)],
)?;
let table = MemTable::try_new(schema, vec![vec![record_batch]])?;
let ctx = SessionContext::new();
ctx.register_table("test", Arc::new(table))?;
let sql = "SELECT array_position(a, 1) FROM test";
let plan = ctx.sql(sql).await?.collect().await?;
Ok(())
}
```
### Expected behavior
I'd expect `array_position` to give a best effort to find the query value
and fail if the passed value is incompatible due to its magnitude not
immediatly by its type.
### 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]