You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "phillipleblanc (via GitHub)" <gi...@apache.org> on 2024/04/23 14:33:34 UTC
[I] Allow expr_to_sql unparsing with no quotes [datafusion]
phillipleblanc opened a new issue, #10197:
URL: https://github.com/apache/datafusion/issues/10197
### Describe the bug
I'm using the Unparser.expr_to_sql function to translate a DataFusion `Expr` into an expression for Spark Connect. Unlike most SQL engines, Spark doesn't like quoting the column identifiers. I want to be able to generate an expression like `a > 4` but currently I can only get `"a" > 4`
I believe this might be useful beyond Spark for other database systems that can handle unquoted column identifiers.
### To Reproduce
```rust
use datafusion_expr::{col, lit};
use datafusion_sql::unparser::Unparser;
let expr = col("a").gt(lit(4));
let spark_dialect = CustomDialect::new(None);
let unparser = Unparser::new(&spark_dialect);
let sql = unparser.expr_to_sql(&expr).unwrap();
assert_eq!(format!("{}", sql), "(\"a\" > 4)")
```
### Expected behavior
```rust
use datafusion_expr::{col, lit};
use datafusion_sql::unparser::Unparser;
let expr = col("a").gt(lit(4));
let spark_dialect = CustomDialect::new(None);
let unparser = Unparser::new(&spark_dialect);
let sql = unparser.expr_to_sql(&expr).unwrap();
assert_eq!(format!("{}", sql), "(a > 4)")
```
### 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@datafusion.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [I] Allow expr_to_sql unparsing with no quotes [datafusion]
Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb closed issue #10197: Allow expr_to_sql unparsing with no quotes
URL: https://github.com/apache/datafusion/issues/10197
--
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@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org