You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "NiwakaDev (via GitHub)" <gi...@apache.org> on 2023/03/26 17:43:04 UTC

[GitHub] [arrow-datafusion] NiwakaDev opened a new issue, #5746: Only single quote string is allowed in where clause?

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

   ### Describe the bug
   
   Right now, I guess that we can't use `double quote` in `where` clause, like so:
   
   ```sql
   SELECT * FROM example where cpu = "host1"
   ```
   
   ### To Reproduce
   
   Execute the following commands on the terminal:
   
   ```
   echo "cpu, memory" > example.csv
   echo "host1, 2" >> example.csv
   ```
   
   And then execute `cargo run` for the following
   ```rust
   
   use datafusion::prelude::*;
   
   
   #[tokio::main]
   async fn main() -> datafusion::error::Result<()> {
     // register the table
     let ctx = SessionContext::new();
     ctx.register_csv("example", "example.csv", CsvReadOptions::new()).await?;
   
     // create a plan to run a SQL query
     let df = ctx.sql(r#"SELECT * FROM example where cpu = "host1""#).await?;
   
     // execute and print results
     df.show().await?;
     Ok(())
   }
   ```
   
   And then we get the following error:
   ```
   Error: SchemaError(FieldNotFound { field: Column { relation: None, name: "host1" }, valid_fields: [Column { relation: Some("example"), name: "cpu" }, Column { relation: Some("example"), name: " memory" }] })
   ```
   
   ### Expected behavior
   
   The expected behavior is to allow users to use `double quote` such as `single quote` in `where` clause, like so:
   
   ```sql
   SELECT * FROM example where cpu = "host1"
   ```
   
   ### Additional context
   
   _No response_


-- 
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] alamb commented on issue #5746: Only single quote string is allowed in where clause?

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on issue #5746:
URL: https://github.com/apache/arrow-datafusion/issues/5746#issuecomment-1484901193

   That is correct -- in sql (at least in postgres), 
   
   ```
   SELECT * FROM example where cpu = "host1"
   ```
   
   The double quote `"` is used for identifiers (aka column names)
   
   A single quote `'` is used for string literals
   
   This is a feature of https://github.com/sqlparser-rs/sqlparser-rs -- you may be able to use a different SQL dialect in sqlparser-rs if you want different quoting behavior


-- 
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] andygrove commented on issue #5746: Only single quote string is allowed in where clause?

Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on issue #5746:
URL: https://github.com/apache/arrow-datafusion/issues/5746#issuecomment-1487287802

   > That is correct -- in sql (at least in postgres),
   
   Also correct in ANSI SQL specification.
   
   Spark SQL differs from ANSI in that it allows double quotes for string literals and uses backticks for identifiers, so maybe you are looking for Spark SQL compatibility.


-- 
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] NiwakaDev closed issue #5746: Only single quote string is allowed in where clause?

Posted by "NiwakaDev (via GitHub)" <gi...@apache.org>.
NiwakaDev closed issue #5746: Only single quote string is allowed in where clause?
URL: https://github.com/apache/arrow-datafusion/issues/5746


-- 
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] NiwakaDev commented on issue #5746: Only single quote string is allowed in where clause?

Posted by "NiwakaDev (via GitHub)" <gi...@apache.org>.
NiwakaDev commented on issue #5746:
URL: https://github.com/apache/arrow-datafusion/issues/5746#issuecomment-1535783794

   Thanks!!!


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