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


##########
datafusion/sql/src/unparser/expr.rs:
##########
@@ -561,6 +636,31 @@ mod tests {
                 }),
                 r#"CAST("a" AS INTEGER UNSIGNED)"#,
             ),
+            (
+                Expr::InList(InList {

Review Comment:
   I think you can write this more concisely with the expr API -- 
https://docs.rs/datafusion/latest/datafusion/logical_expr/enum.Expr.html#method.in_list
   
   Something like
   ```rust
   col("a").in(vec![lit(1), lit(2), lit(3)])
   ```
   
   Likewise for NOT IN
   
   ```rust
   col("a").not_in(vec![lit(1), lit(2), lit(3)])
   ```
   
   



##########
datafusion/sql/src/unparser/expr.rs:
##########
@@ -561,6 +636,31 @@ mod tests {
                 }),
                 r#"CAST("a" AS INTEGER UNSIGNED)"#,
             ),
+            (
+                Expr::InList(InList {
+                    expr: Box::new(col("a")),
+                    list: vec![lit(1), lit(2), lit(3)],
+                    negated: false,
+                }),
+                r#""a" IN (1, 2, 3)"#,
+            ),
+            (
+                Expr::InList(InList {
+                    expr: Box::new(col("a")),
+                    list: vec![lit(1), lit(2), lit(3)],
+                    negated: true,
+                }),
+                r#""a" NOT IN (1, 2, 3)"#,
+            ),
+            (
+                Expr::ScalarFunction(ScalarFunction {
+                    func_def: ScalarFunctionDefinition::UDF(Arc::new(
+                        ScalarUDF::new_from_impl(DummyUDF::new()),
+                    )),
+                    args: vec![col("a"), col("b")],
+                }),
+                r#"dummy_udf("a", "b")"#,
+            ),

Review Comment:
   Since there is no code specific to `BuiltInScalarFunction` in the unparser 
code, I agree there is no reason to add a specific test here 



##########
datafusion/sql/src/unparser/expr.rs:
##########
@@ -561,6 +636,31 @@ mod tests {
                 }),
                 r#"CAST("a" AS INTEGER UNSIGNED)"#,
             ),
+            (
+                Expr::InList(InList {
+                    expr: Box::new(col("a")),
+                    list: vec![lit(1), lit(2), lit(3)],
+                    negated: false,
+                }),
+                r#""a" IN (1, 2, 3)"#,
+            ),
+            (
+                Expr::InList(InList {
+                    expr: Box::new(col("a")),
+                    list: vec![lit(1), lit(2), lit(3)],
+                    negated: true,
+                }),
+                r#""a" NOT IN (1, 2, 3)"#,
+            ),
+            (
+                Expr::ScalarFunction(ScalarFunction {
+                    func_def: ScalarFunctionDefinition::UDF(Arc::new(
+                        ScalarUDF::new_from_impl(DummyUDF::new()),
+                    )),
+                    args: vec![col("a"), col("b")],
+                }),

Review Comment:
   How about using the call API 
https://docs.rs/datafusion/latest/datafusion/logical_expr/struct.ScalarUDF.html#method.call
   
   ```rust
   ScalarUDF::new_from_impl(DummyUDF::new())
    .call(vec![col("a"), col("b")])
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to