srh commented on PR #15836:
URL: https://github.com/apache/datafusion/pull/15836#issuecomment-2834607199
@comphead It isn't parser related, it's a bug in evaluation, with this
optimizer.
It seems a query like `"SELECT s.col ILIKE 'A' FROM (SELECT 'a' AS col) AS
s"` will trigger the bug. The query `SELECT 'a' ILIKE 'A'` evaluates to true
because it hits constant folding before ExprSimplifier.
Here is a complete program that reproduces this on 46.0.1:
```
use datafusion::{
arrow::
util::pretty,
prelude::*,
};
use tokio;
#[tokio::main]
async fn main() -> datafusion::error::Result<()> {
let session_config = SessionConfig::new();
let ctx = SessionContext::new_with_config(session_config);
for value in &["a", "A"] {
let query = format!("SELECT s.col ILIKE 'A' FROM (SELECT '{}' AS
col) AS s", value);
let df = ctx.sql(&query).await?;
let results = df.collect().await?;
println!("'{}' ILIKE 'A' result:", value);
pretty::print_batches(&results)?;
}
Ok(())
}
```
```
'a' ILIKE 'A' result:
+-----------------------+
| s.col ILIKE Utf8("A") |
+-----------------------+
| false |
+-----------------------+
'A' ILIKE 'A' result:
+-----------------------+
| s.col ILIKE Utf8("A") |
+-----------------------+
| true |
+-----------------------+
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]