Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow expr_to_sql unparsing with no quotes #10197

Closed
Tracked by #9726
phillipleblanc opened this issue Apr 23, 2024 · 0 comments · Fixed by #10198
Closed
Tracked by #9726

Allow expr_to_sql unparsing with no quotes #10197

phillipleblanc opened this issue Apr 23, 2024 · 0 comments · Fixed by #10198
Labels
bug Something isn't working

Comments

@phillipleblanc
Copy link
Contributor

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

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant