Skip to content

Commit 0689515

Browse files
Allow expr_to_sql unparsing with no quotes (#10198)
* Allow expr_to_sql unparsing with no quotes * Add test
1 parent 767bbca commit 0689515

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

datafusion/sql/src/unparser/dialect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub struct DefaultDialect {}
2626

2727
impl Dialect for DefaultDialect {
2828
fn identifier_quote_style(&self) -> Option<char> {
29-
None
29+
Some('"')
3030
}
3131
}
3232

datafusion/sql/src/unparser/expr.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ impl Unparser<'_> {
358358
pub(super) fn new_ident(&self, str: String) -> ast::Ident {
359359
ast::Ident {
360360
value: str,
361-
quote_style: Some(self.dialect.identifier_quote_style().unwrap_or('"')),
361+
quote_style: self.dialect.identifier_quote_style(),
362362
}
363363
}
364364

@@ -965,4 +965,20 @@ mod tests {
965965

966966
Ok(())
967967
}
968+
969+
#[test]
970+
fn custom_dialect_none() -> Result<()> {
971+
let dialect = CustomDialect::new(None);
972+
let unparser = Unparser::new(&dialect);
973+
974+
let expr = col("a").gt(lit(4));
975+
let ast = unparser.expr_to_sql(&expr)?;
976+
977+
let actual = format!("{}", ast);
978+
979+
let expected = r#"(a > 4)"#;
980+
assert_eq!(actual, expected);
981+
982+
Ok(())
983+
}
968984
}

0 commit comments

Comments
 (0)