mingmwang commented on code in PR #3969:
URL: https://github.com/apache/arrow-datafusion/pull/3969#discussion_r1006881904
##########
datafusion/physical-expr/src/expressions/binary.rs:
##########
@@ -649,6 +650,30 @@ impl PhysicalExpr for BinaryExpr {
right: Arc::clone(self.right()),
})
}
+
+ fn children(&self) -> Vec<Arc<dyn PhysicalExpr>> {
+ vec![self.left.clone(), self.right.clone()]
+ }
+
+ fn with_new_children(
+ self: Arc<Self>,
+ children: Vec<Arc<dyn PhysicalExpr>>,
+ ) -> Result<Arc<dyn PhysicalExpr>> {
+ Ok(Arc::new(BinaryExpr::new(
Review Comment:
I already add the length check in the method
`with_new_children_if_necessary()`, and expr.with_new_children() should not be
called directly. This is also aligned with the ExecutionPlan.
````
pub fn with_new_children_if_necessary(
expr: Arc<dyn PhysicalExpr>,
children: Vec<Arc<dyn PhysicalExpr>>,
) -> Result<Arc<dyn PhysicalExpr>> {
if children.len() != expr.children().len() {
Err(DataFusionError::Internal(
"PhysicalExpr: Wrong number of children".to_string(),
))
} else if children.is_empty()
|| children
.iter()
.zip(expr.children().iter())
.any(|(c1, c2)| !Arc::ptr_eq(c1, c2))
{
expr.with_new_children(children)
} else {
Ok(expr)
}
}
````
--
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]