You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "waynexia (via GitHub)" <gi...@apache.org> on 2023/03/06 03:41:17 UTC

[GitHub] [arrow-datafusion] waynexia commented on a diff in pull request #5450: feat: add name() method to UserDefinedLogicalNode

waynexia commented on code in PR #5450:
URL: https://github.com/apache/arrow-datafusion/pull/5450#discussion_r1125858250


##########
datafusion/expr/src/logical_plan/extension.rs:
##########
@@ -30,6 +30,9 @@ pub trait UserDefinedLogicalNode: fmt::Debug + Send + Sync {
     /// Return a reference to self as Any, to support dynamic downcasting
     fn as_any(&self) -> &dyn Any;
 
+    /// Return the plan's name

Review Comment:
   I ignored the `fmt_for_explain` method... You are right, they are redundant information.
   
   >What would you think about making a function like the following that returned the result of format_for_explain
   
   The returned string (like "TopK: k=1") is also not easy to use for the dispatching purpose, like we need to `.contains()` or `.start_with()` those strings. What do you think about separate name and parameters? E.g.:
   ```rust
   fn name(&self) -> &'str {
     "TopK"
   }
   
   fn fmt_for_params(&self, f: &mut fmt::Formatter) -> fmt::Result { 
      write!(f, "k={}", self.k) 
   }
   
   // this can be provided as default implementation
   fn fmt_for_explain(&self, f: &mut fmt::Formatter) -> fmt::Result { 
      write!(f, "{}: {}", self.name(), self.fmt_for_params()) 
   }
   ```



-- 
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