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

[GitHub] [arrow-datafusion] liurenjie1024 opened a new pull request, #6726: feat: Add graphviz display format for execution plan.

liurenjie1024 opened a new pull request, #6726:
URL: https://github.com/apache/arrow-datafusion/pull/6726

   # Which issue does this PR close?
   
   Part of #3606 . 
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #.
   
   # Rationale for this change
   
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   # What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   # Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   # Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->


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


[GitHub] [arrow-datafusion] alamb merged pull request #6726: feat: Add graphviz display format for execution plan.

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #6726:
URL: https://github.com/apache/arrow-datafusion/pull/6726


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


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

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #6726:
URL: https://github.com/apache/arrow-datafusion/pull/6726#discussion_r1235693855


##########
Cargo.toml:
##########
@@ -51,6 +51,9 @@ arrow-buffer = { version = "41.0.0", default-features = false }
 arrow-schema = { version = "41.0.0", default-features = false }
 arrow-array = { version = "41.0.0", default-features = false, features = ["chrono-tz"] }
 parquet = { version = "41.0.0", features = ["arrow", "async", "object_store"] }
+graphviz-rust = "0.6.2"

Review Comment:
   These crates appear to be relatively new and from a single author -- 
   
   https://crates.io/crates/graphviz-rust
   https://crates.io/crates/dot-structures
   https://crates.io/crates/dot-generator
   
   Could you comment on how much value they add rather than implementing the relevant portions within datafusion (graphviz is not a complicated format and doesn't typically need a library to create, in my experience)



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


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

Posted by "alamb (via GitHub)" <gi...@apache.org>.
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


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

Posted by "liurenjie1024 (via GitHub)" <gi...@apache.org>.
liurenjie1024 commented on PR #6726:
URL: https://github.com/apache/arrow-datafusion/pull/6726#issuecomment-1599734499

   @alamb Yes, I have read that before, but I prefer this approach because it's more structural, type safe, and easier to maintain.


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


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

Posted by "liurenjie1024 (via GitHub)" <gi...@apache.org>.
liurenjie1024 commented on code in PR #6726:
URL: https://github.com/apache/arrow-datafusion/pull/6726#discussion_r1243062679


##########
Cargo.toml:
##########
@@ -51,6 +51,9 @@ arrow-buffer = { version = "41.0.0", default-features = false }
 arrow-schema = { version = "41.0.0", default-features = false }
 arrow-array = { version = "41.0.0", default-features = false, features = ["chrono-tz"] }
 parquet = { version = "41.0.0", features = ["arrow", "async", "object_store"] }
+graphviz-rust = "0.6.2"

Review Comment:
   Ok, I will rewrite the build without dependencies.



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


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

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #6726:
URL: https://github.com/apache/arrow-datafusion/pull/6726#issuecomment-1601263853

   >  @alamb Yes, I have read that before, but I prefer this approach because it's more structural, type safe, and easier to maintain. And I'm planning to modify logical pla n graphviz format later.
   
   That makes sense -- thank you for the explanation. As long as we don't have two different ways of making graphviz I think your approach makes sense
   


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


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

Posted by "liurenjie1024 (via GitHub)" <gi...@apache.org>.
liurenjie1024 commented on code in PR #6726:
URL: https://github.com/apache/arrow-datafusion/pull/6726#discussion_r1255420014


##########
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:
   Thanks for pointing it out, fixed.



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


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

Posted by "liurenjie1024 (via GitHub)" <gi...@apache.org>.
liurenjie1024 commented on PR #6726:
URL: https://github.com/apache/arrow-datafusion/pull/6726#issuecomment-1624566880

   cc @alamb @Dandandan I think this is now ready for review and merging.


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


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

Posted by "liurenjie1024 (via GitHub)" <gi...@apache.org>.
liurenjie1024 commented on PR #6726:
URL: https://github.com/apache/arrow-datafusion/pull/6726#issuecomment-1602323506

   I will fix the condlicts after vacation.


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


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

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #6726:
URL: https://github.com/apache/arrow-datafusion/pull/6726#discussion_r1242659098


##########
Cargo.toml:
##########
@@ -51,6 +51,9 @@ arrow-buffer = { version = "41.0.0", default-features = false }
 arrow-schema = { version = "41.0.0", default-features = false }
 arrow-array = { version = "41.0.0", default-features = false, features = ["chrono-tz"] }
 parquet = { version = "41.0.0", features = ["arrow", "async", "object_store"] }
+graphviz-rust = "0.6.2"

Review Comment:
   @liurenjie1024  -- do we really need new dependencies? I would prefer to avoid this if at all possible



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