suremarc opened a new issue, #7959:
URL: https://github.com/apache/arrow-datafusion/issues/7959
### Describe the bug
When passed to `create_physical_expr`, the following expression works as
expected on DataFusion 32.0.0 but fails on the `master` branch:
```rust
col("column").eq(left("value".lit(), 1i64.lit()))
```
The following error appears:
```rust
Error: ArrowError(InvalidArgumentError("Cannot compare arrays of different
lengths, got 4 vs 1"))
```
### To Reproduce
Compile the following piece of Rust code against the current master branch
of DataFusion:
```rust
use std::sync::Arc;
use arrow::{array::StringArray, record_batch::RecordBatch};
use arrow_schema::{DataType, Field, Schema};
use datafusion::physical_expr::{create_physical_expr,
execution_props::ExecutionProps};
use datafusion_common::{DFSchema, Result};
use datafusion_expr::{col, left, Literal};
#[tokio::main]
async fn main() -> Result<()> {
let expr = col("letter").eq(left("AAPL".lit(), 1i64.lit()));
println!("{expr}");
let schema = Schema::new(vec![Field::new("letter", DataType::Utf8,
false)]);
let df_schema = DFSchema::try_from_qualified_schema("data", &schema)?;
let p = create_physical_expr(&expr, &df_schema, &schema,
&ExecutionProps::new())?;
println!("{p}");
let batch = RecordBatch::try_new(
Arc::new(schema),
vec![Arc::new(StringArray::from_iter_values(vec![
"A", "B", "C", "D",
]))],
)?;
let z = p.evaluate(&batch)?;
println!("{z:?}");
Ok(())
}
// letter = left(Utf8("AAPL"), Int64(1))
// letter@0 = left(AAPL, 1)
// Error: ArrowError(InvalidArgumentError("Cannot compare arrays of
different lengths, got 4 vs 1"))
```
### Expected behavior
`create_physical_expr` should produce a valid physical expression from the
provided logical expression
### 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]