alamb commented on code in PR #4642: URL: https://github.com/apache/arrow-datafusion/pull/4642#discussion_r1050090530
########## datafusion/expr/src/expr.rs: ########## @@ -433,6 +428,22 @@ impl Cast { } } +/// TryCast Expression +#[derive(Clone, PartialEq, Eq, Hash)] +pub struct TryCast { + /// The expression being cast + pub expr: Box<Expr>, + /// The `DataType` the expression will yield + pub data_type: DataType, +} + +impl TryCast { + /// Create a new TryCast expression + pub fn new(expr: Box<Expr>, data_type: DataType) -> Self { + Self { expr, data_type } + } +} Review Comment: the API might be nicer if it did the boxing as if you already have a `Box` you can create the struct directly via `TryCast { expr, data_type}` 🤔 ```suggestion impl TryCast { /// Create a new TryCast expression pub fn new(expr: Expr, data_type: DataType) -> Self { Self { expr: Box::new(expr), data_type } } } ``` -- 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-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org