findepi commented on code in PR #13012:
URL: https://github.com/apache/datafusion/pull/13012#discussion_r1810476691
##########
datafusion/expr/src/udaf.rs:
##########
@@ -225,10 +225,10 @@ impl AggregateUDF {
/// See [`AggregateUDFImpl::with_beneficial_ordering`] for more details.
pub fn with_beneficial_ordering(
- self,
+ self: Arc<Self>,
beneficial_ordering: bool,
) -> Result<Option<AggregateUDF>> {
- self.inner
+ Arc::clone(&self.inner)
Review Comment:
The code doesn't explain why `AggregateUDFImpl::with_beneficial_ordering`
takes an Arc (it could as well take `&self`), but that's for later
##########
datafusion/physical-expr/src/aggregate.rs:
##########
@@ -331,17 +331,15 @@ impl AggregateFunctionExpr {
self: Arc<Self>,
beneficial_ordering: bool,
) -> Result<Option<AggregateFunctionExpr>> {
- let Some(updated_fn) = self
- .fun
- .clone()
- .with_beneficial_ordering(beneficial_ordering)?
+ let Some(updated_fn) =
+
Arc::clone(&self.fun).with_beneficial_ordering(beneficial_ordering)?
Review Comment:
```suggestion
self.fun.with_beneficial_ordering(beneficial_ordering)?
```
##########
datafusion/physical-expr/src/aggregate.rs:
##########
@@ -197,12 +197,12 @@ impl AggregateExprBuilder {
/// Physical aggregate expression of a UDAF.
#[derive(Debug, Clone)]
pub struct AggregateFunctionExpr {
- fun: AggregateUDF,
+ fun: Arc<AggregateUDF>,
args: Vec<Arc<dyn PhysicalExpr>>,
/// Output / return type of this aggregate
data_type: DataType,
name: String,
- schema: Schema,
+ schema: Arc<Schema>,
Review Comment:
👍
##########
datafusion/expr/src/udaf.rs:
##########
@@ -225,10 +225,10 @@ impl AggregateUDF {
/// See [`AggregateUDFImpl::with_beneficial_ordering`] for more details.
pub fn with_beneficial_ordering(
- self,
+ self: Arc<Self>,
Review Comment:
What's the benefit of using Arc here?
```suggestion
&self
```
##########
datafusion/physical-expr/src/aggregate.rs:
##########
@@ -474,7 +472,7 @@ impl AggregateFunctionExpr {
AggregateExprBuilder::new(reverse_udf, self.args.to_vec())
.order_by(reverse_ordering_req.to_vec())
- .schema(Arc::new(self.schema.clone()))
+ .schema(Arc::clone(&self.schema))
Review Comment:
❤️
--
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]