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

Re: [PR] feat: implement more expr_to_sql functionality [arrow-datafusion]

alamb commented on code in PR #9578:
URL: https://github.com/apache/arrow-datafusion/pull/9578#discussion_r1523472311


##########
datafusion/sql/Cargo.toml:
##########
@@ -33,11 +33,13 @@ name = "datafusion_sql"
 path = "src/lib.rs"
 
 [features]
-default = ["unicode_expressions"]
+default = ["unicode_expressions", "unparser"]

Review Comment:
   👍 



##########
datafusion/sql/src/unparser/expr.rs:
##########
@@ -347,7 +585,7 @@ mod tests {
 
         let actual = format!("{}", ast);
 
-        let expected = r#"'a' > 4"#;
+        let expected = r#"('a' > 4)"#;

Review Comment:
   these parens are due to using `Expr::Nested` right? I think it is a good design to add explicit parens to ensure the evaluation order is correctly reflected
   
   



##########
datafusion/sql/src/unparser/expr.rs:
##########
@@ -315,14 +489,78 @@ mod tests {
     #[test]
     fn expr_to_sql_ok() -> Result<()> {
         let tests: Vec<(Expr, &str)> = vec![
-            (col("a").gt(lit(4)), r#"a > 4"#),
+            ((col("a") + col("b")).gt(lit(4)), r#"((a + b) > 4)"#),

Review Comment:
   nice



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