You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/10/28 16:49:30 UTC

[GitHub] [arrow-datafusion] isidentical commented on a diff in pull request #3969: [Part1] Partition and Sort Enforcement, PhysicalExpr enhancement

isidentical commented on code in PR #3969:
URL: https://github.com/apache/arrow-datafusion/pull/3969#discussion_r1008265133


##########
datafusion/physical-expr/src/expressions/cast.rs:
##########
@@ -93,6 +94,36 @@ impl PhysicalExpr for CastExpr {
         let value = self.expr.evaluate(batch)?;
         cast_column(&value, &self.cast_type, &self.cast_options)
     }
+
+    fn children(&self) -> Vec<Arc<dyn PhysicalExpr>> {
+        vec![self.expr.clone()]
+    }
+
+    fn with_new_children(
+        self: Arc<Self>,
+        children: Vec<Arc<dyn PhysicalExpr>>,
+    ) -> Result<Arc<dyn PhysicalExpr>> {
+        Ok(Arc::new(CastExpr::new(
+            children[0].clone(),
+            self.cast_type.clone(),
+            CastOptions {
+                safe: self.cast_options.safe,
+            },
+        )))
+    }
+}
+
+impl PartialEq<dyn Any> for CastExpr {
+    fn eq(&self, other: &dyn Any) -> bool {
+        down_cast_any_ref(other)
+            .downcast_ref::<Self>()
+            .map(|x| {
+                self.expr.eq(&x.expr)
+                    && self.cast_type == x.cast_type
+                    && self.cast_options.safe == x.cast_options.safe

Review Comment:
   This seems to be a bit error-prone, considering that `cast_options` might get new members and this part will not count them. Can we consider adding equality comparison support to `CastOptions` directly?



-- 
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-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org