ReggieFan opened a new issue, #2210:
URL: https://github.com/apache/arrow-datafusion/issues/2210

   **Describe the bug**
   ExecutionContext::sql function result in following error when execute sql 
"select * from table1 where Level='INFO'", while field name is 'Level'.
   `thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: 
Plan("Invalid identifier '#level' for schema table1.timestamp, table1.Level, 
table1.content")' `
   
   **To Reproduce**
   ```
   use datafusion::arrow::array::{Int64Array, StringArray};
   use datafusion::arrow::datatypes::{DataType, Field, Schema};
   use datafusion::arrow::record_batch::RecordBatch;
   use datafusion::datasource::MemTable;
   use datafusion::prelude::*;
   use std::sync::Arc;
   
   #[tokio::main]
   async fn main() {
       let fields = vec![
           Field::new("timestamp", DataType::Int64, true),
           Field::new("Level", DataType::Utf8, true),
           Field::new("content", DataType::Utf8, true),
       ];
       let schema = Schema::new(fields);
       let a = Int64Array::from(vec![1648211794523]);
       let b = StringArray::from(vec!["INFO"]);
       let c = StringArray::from(vec!["content1"]);
   
       let record_batch = RecordBatch::try_new(
           Arc::new(schema),
           vec![Arc::new(a), Arc::new(b), Arc::new(c)],
       ).unwrap();
       let sql = "select * from table1 where Level='INFO'";
       let mut ctx = ExecutionContext::new();
       let mem_db = MemTable::try_new(record_batch.schema(), 
vec![vec![record_batch]]).unwrap();
       ctx.register_table("table1", Arc::new(mem_db)).unwrap();
       ctx.sql(sql).await.unwrap();
   }
   ```
   
   **Expected behavior**
   "select * from table1 where Level='INFO'" or "select * from table1 where 
level='INFO'" should be executed successfully.
   


-- 
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]

Reply via email to