You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2023/07/07 08:01:42 UTC

[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #6726: feat: Add graphviz display format for execution plan.

alamb commented on code in PR #6726:
URL: https://github.com/apache/arrow-datafusion/pull/6726#discussion_r1255410337


##########
datafusion/common/src/display/graphviz.rs:
##########
@@ -0,0 +1,105 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+//! Logic related to creating DOT language graphs.
+
+use std::fmt;
+
+#[derive(Default)]
+pub struct GraphvizBuilder {
+    id_gen: usize,
+}
+
+impl GraphvizBuilder {
+    // Generate next id in graphviz.
+    pub fn next_id(&mut self) -> usize {
+        self.id_gen += 1;
+        self.id_gen
+    }
+
+    // Write out the start of whole graph.
+    pub fn start_graph(&mut self, f: &mut fmt::Formatter) -> fmt::Result {
+        writeln!(
+            f,
+            r#"
+// Begin DataFusion GraphViz Plan,
+// display it online here: https://dreampuf.github.io/GraphvizOnline

Review Comment:
   👍 



##########
datafusion/expr/src/logical_plan/plan.rs:
##########
@@ -1850,31 +1845,46 @@ mod tests {
     fn test_display_graphviz() -> Result<()> {
         let plan = display_plan()?;
 
+        let expected_graphviz = r###"
+// Begin DataFusion GraphViz Plan,
+// display it online here: https://dreampuf.github.io/GraphvizOnline
+
+digraph {

Review Comment:
   I tried it and it looks great 👍 
   
   <img width="1382" alt="Screenshot 2023-07-07 at 4 00 51 AM" src="https://github.com/apache/arrow-datafusion/assets/490673/92ffea6e-8169-4b45-9b75-3d937bef4d0c">
   



##########
datafusion/core/src/physical_plan/display.rs:
##########
@@ -110,6 +112,49 @@ impl<'a> DisplayableExecutionPlan<'a> {
         }
     }
 
+    /// Returns a `format`able structure that produces graphviz format for execution plan, which can
+    /// be directly visualized [here](http://magjac.com/graphviz-visual-editor/).

Review Comment:
   I don't know if it is intentional but the PR suggests a different URL elsewhere:
   
   ```
   // display it online here: https://dreampuf.github.io/GraphvizOnline
   ```



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