alamb commented on code in PR #13427:
URL: https://github.com/apache/datafusion/pull/13427#discussion_r1844331548


##########
datafusion/sql/src/unparser/expr.rs:
##########
@@ -2167,6 +2174,39 @@ mod tests {
         }
     }
 
+    #[test]
+    fn test_cast_value_to_binary_expr() {
+        let tests = [
+            (
+                Expr::Cast(Cast {
+                    expr: Box::new(Expr::Literal(ScalarValue::Utf8(Some(
+                        "blah".to_string(),
+                    )))),
+                    data_type: DataType::Binary,
+                }),

Review Comment:
   I think you can write this more concisely with `lit`
   
   ```suggestion
                   Expr::Cast(Cast {
                       expr: Box::new(lit("blah"))
                       data_type: DataType::Binary,
                   }),
   ```
   
   
   
   
   You could also try to use 
https://docs.rs/datafusion/latest/datafusion/logical_expr/enum.Expr.html#method.cast_to
  but that requires a valid schema



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to