mcassels opened a new issue #1434:
URL: https://github.com/apache/arrow-datafusion/issues/1434
**Describe the bug**
`SELECT * FROM table WHERE <condition0> OR <condition1> OR ...` succeeds
with 50 conditions but overflows stack with 100 conditions.
**To Reproduce**
Adding this test to arrow-datafusion/datafusion/tests/sql.rs demonstrates
the issue:
```
#[tokio::test]
async fn query_with_many_conditions() -> Result<()> {
let schema = Arc::new(Schema::new(vec![Field::new("c1", DataType::Utf8,
true)]));
let data = RecordBatch::try_new(
schema.clone(),
vec![Arc::new(StringArray::from(vec!["foo", "bar"]))],
)
.unwrap();
let table = MemTable::try_new(schema, vec![vec![data]])?;
let mut ctx = ExecutionContext::new();
ctx.register_table("test", Arc::new(table)).unwrap();
let num_conditions = 50;
println!("attempted a query with {:?} conditions...", num_conditions);
let where_clause = (0..num_conditions)
.map(|i| format!("c1 = 'value{:?}'", i))
.collect::<Vec<String>>()
.join(" OR ");
let sql = format!("SELECT * from test where {};", where_clause);
execute_to_batches(&mut ctx, &sql).await;
println!("query succeeded with {:?} conditions", num_conditions);
let num_conditions = 100;
println!("attempted a query with {:?} conditions...", num_conditions);
let where_clause = (0..num_conditions)
.map(|i| format!("c1 = 'value{:?}'", i))
.collect::<Vec<String>>()
.join(" OR ");
let sql = format!("SELECT * from test where {};", where_clause);
execute_to_batches(&mut ctx, &sql).await;
println!("query succeeded with {:?} conditions", num_conditions);
Ok(())
}
```
Output:
```
running 1 test
attempted a query with 50 conditions...
query succeeded with 50 conditions
attempted a query with 100 conditions...
thread 'query_with_many_conditions' has overflowed its stack
fatal runtime error: stack overflow
error: test failed, to rerun pass '--test sql'
```
**Expected behavior**
Expected query to succeed.
--
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]