findepi commented on code in PR #17643:
URL: https://github.com/apache/datafusion/pull/17643#discussion_r2360676333
##########
datafusion-examples/examples/expr_api.rs:
##########
@@ -518,10 +518,7 @@ fn type_coercion_demo() -> Result<()> {
HashMap::new(),
)?;
let i8_array = Int8Array::from_iter_values(vec![0, 1, 2]);
- let batch = RecordBatch::try_new(
- Arc::new(df_schema.as_arrow().to_owned()),
- vec![Arc::new(i8_array) as _],
- )?;
+ let batch = RecordBatch::try_new((&df_schema).into(),
vec![Arc::new(i8_array) as _])?;
Review Comment:
i agree explicit is better than implicit
the existing code used `into` quite a lot, so it looks there is natural
gravity towards this API. I want the most obvious and easiest code to write to
be most likely correct. that's why i added new From/Into forms that should be
easy to write and cheap to execute.
alternatively, we could remove/reduce From/Into and these way be more
explicit always.
> I would personally find it easier to understand there were no clones going
on using this syntax
in `(&df_schema).into()`, it's clear we pass a ref into `into()`. we're
giving a cheap object in, so the operation should be cheap.
--
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]