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/04 05:00:44 UTC

[GitHub] [arrow-datafusion] wangxiaoying opened a new issue, #2147: No field named when table name is quoted in FROM clause

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

   **Describe the bug**
   `ExecutionContext::sql` function result in following error when the table name is quoted in FROM clause:
   ```
   thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Plan("No field named 't1.id'. Valid fields are '\"t1\".id'.")'
   ```
   
   **To Reproduce**
   ```rust
   use arrow::array::Int32Array;
   use arrow::datatypes::{DataType, Field, Schema};
   use arrow::record_batch::RecordBatch;
   use datafusion::datasource::MemTable;
   use datafusion::prelude::*;
   use std::sync::Arc;
   
   fn main() {
       let id_array = Int32Array::from(vec![1, 2, 3, 4, 5]);
       let schema = Schema::new(vec![Field::new("id", DataType::Int32, false)]);
       let batch = RecordBatch::try_new(Arc::new(schema), vec![Arc::new(id_array)]).unwrap();
   
       let mut ctx = ExecutionContext::new();
       let sql = "select * from \"t1\" where \"t1\".\"id\" > 3"; // q1 not work
       // let sql = "select * from t1 where \"t1\".\"id\" > 3"; // q2 works
       // let sql = "select * from t1 where t1.id > 3"; // q3 works
       // let sql = "select * from \"t1\""; // q4 works
       let db1 = MemTable::try_new(batch.schema(), vec![vec![batch]]).unwrap();
       ctx.register_table("t1", Arc::new(db1)).unwrap();
   
       let rt = Arc::new(tokio::runtime::Runtime::new().expect("Failed to create runtime"));
       let df = rt.block_on(ctx.sql(sql)).unwrap();
   }
   ```
   
   **Expected behavior**
   q1 should work the same with q2 and q3 without any error.
   
   **Additional context**
   In postgres, quoted table names like q1 works:
   <img width="759" alt="image" src="https://user-images.githubusercontent.com/5569610/161476776-05c596ff-d09d-49d0-baf9-e58390d19f40.png">
   
   


-- 
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] WinkerDu commented on issue #2147: No field named when table name is quoted in FROM clause

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

   As discuss in #2267 , quoted table time should be handled in [sqlparser](https://github.com/sqlparser-rs/sqlparser-rs).
   I'll update reply if there is some follow up commit


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