alamb commented on code in PR #16970:
URL: https://github.com/apache/datafusion/pull/16970#discussion_r2263308403


##########
datafusion/physical-expr/src/scalar_function.rs:
##########
@@ -164,6 +175,42 @@ impl fmt::Display for ScalarFunctionExpr {
     }
 }
 
+impl DynEq for ScalarFunctionExpr {
+    fn dyn_eq(&self, other: &dyn Any) -> bool {
+        other.downcast_ref::<Self>().is_some_and(|o| {
+            self.fun.eq(&o.fun)
+                && self.name.eq(&o.name)
+                && self.args.eq(&o.args)
+                && self.return_field.eq(&o.return_field)
+                && self
+                    .config_options
+                    .entries()
+                    .iter()
+                    .sorted_by(|&l, &r| l.key.cmp(&r.key))

Review Comment:
   > Within eq impl it's easy to do pointer comparison first, but what about 
Hash impl? Is the assumption that eq is called during planning much more often 
than the hash?
   
   I think for the hash implementation we can just return a constant / not hash 
the `config_options` -- while this might result in theoretically more hash 
collisions it will be way faster and still correct



##########
datafusion/physical-expr/src/scalar_function.rs:
##########
@@ -164,6 +175,42 @@ impl fmt::Display for ScalarFunctionExpr {
     }
 }
 
+impl DynEq for ScalarFunctionExpr {
+    fn dyn_eq(&self, other: &dyn Any) -> bool {
+        other.downcast_ref::<Self>().is_some_and(|o| {
+            self.fun.eq(&o.fun)
+                && self.name.eq(&o.name)
+                && self.args.eq(&o.args)
+                && self.return_field.eq(&o.return_field)
+                && self
+                    .config_options
+                    .entries()
+                    .iter()
+                    .sorted_by(|&l, &r| l.key.cmp(&r.key))

Review Comment:
   > Within eq impl it's easy to do pointer comparison first, but what about 
Hash impl? Is the assumption that eq is called during planning much more often 
than the hash?
   
   I think for the hash implementation we can just not hash the 
`config_options` -- while this might result in theoretically more hash 
collisions it will be way faster and still correct



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

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to