You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/04/12 14:00:51 UTC

[GitHub] [arrow-datafusion] ReggieFan opened a new issue, #2210: ‘Invalid identifier #xxx’ caused by Case-to-case conversion in SQL

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: github-unsubscribe@arrow.apache.org.apache.org

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


[GitHub] [arrow-datafusion] ReggieFan closed issue #2210: ‘Invalid identifier #xxx’ caused by Case-to-case conversion in SQL

Posted by GitBox <gi...@apache.org>.
ReggieFan closed issue #2210: ‘Invalid identifier #xxx’ caused by Case-to-case conversion in SQL
URL: https://github.com/apache/arrow-datafusion/issues/2210


-- 
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-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-datafusion] alamb commented on issue #2210: ‘Invalid identifier #xxx’ caused by Case-to-case conversion in SQL

Posted by GitBox <gi...@apache.org>.
alamb commented on issue #2210:
URL: https://github.com/apache/arrow-datafusion/issues/2210#issuecomment-1099113763

   I don't think this is a bug. Namely I think the query as you have written it should fail.
   
   The correct (SQL standard) way to write a query that refers to the `"Level"` column I think is:
   
   ```sql
   select * from table1 where "Level"='INFO'
   ```
   
   Which is consistent with what postgres does.


-- 
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-unsubscribe@arrow.apache.org

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