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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to