This is an automated email from the ASF dual-hosted git repository.

vladimirsitnikov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git


The following commit(s) were added to refs/heads/master by this push:
     new aa65a82  Improve Graphviz dump in CannotPlanException: make boxes 
shorter, print composite traits if they were simplified
aa65a82 is described below

commit aa65a82eae624a4606056e4790140448e155b8e9
Author: Vladimir Sitnikov <[email protected]>
AuthorDate: Wed Feb 27 16:02:52 2019 +0300

    Improve Graphviz dump in CannotPlanException: make boxes shorter, print 
composite traits if they were simplified
---
 .../apache/calcite/plan/volcano/VolcanoPlanner.java  | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git 
a/core/src/main/java/org/apache/calcite/plan/volcano/VolcanoPlanner.java 
b/core/src/main/java/org/apache/calcite/plan/volcano/VolcanoPlanner.java
index cb88de3..bf8336d 100644
--- a/core/src/main/java/org/apache/calcite/plan/volcano/VolcanoPlanner.java
+++ b/core/src/main/java/org/apache/calcite/plan/volcano/VolcanoPlanner.java
@@ -1250,13 +1250,29 @@ public class VolcanoPlanner extends 
AbstractRelOptPlanner {
       Util.printJavaString(pw, "Set " + set.id + " " + 
set.subsets.get(0).getRowType(), false);
       pw.print(";\n");
       for (RelNode rel : set.rels) {
-        String traits = "." + rel.getTraitSet().toString();
         pw.print("\t\trel");
         pw.print(rel.getId());
         pw.print(" [label=");
         RelMetadataQuery mq = rel.getCluster().getMetadataQuery();
+
+        // Note: rel traitset could be different from its subset.traitset
+        // It can happen due to RelTraitset#simplify
+        // If the traits are different, we want to keep them on a graph
+        String traits = "." + getSubset(rel).getTraitSet().toString();
+        String title = rel.getDescription().replace(traits, "");
+        if (title.endsWith(")")) {
+          int openParen = title.indexOf('(');
+          if (openParen != -1) {
+            // Title is like 
rel#12:LogicalJoin(left=RelSubset#4,right=RelSubset#3,
+            // condition==($2, $0),joinType=inner)
+            // so we remove the parenthesis, and wrap parameters to the second 
line
+            // This avoids "too wide" Graphiz boxes, and makes the graph 
easier to follow
+            title = title.substring(0, openParen) + '\n'
+                + title.substring(openParen + 1, title.length() - 1);
+          }
+        }
         Util.printJavaString(pw,
-            rel.getDescription().replace(traits, "")
+            title
                 + "\nrows=" + mq.getRowCount(rel) + ", cost=" + getCost(rel, 
mq), false);
         RelSubset relSubset = getSubset(rel);
         if (!(rel instanceof AbstractConverter)) {

Reply via email to