gortiz commented on code in PR #13733:
URL: https://github.com/apache/pinot/pull/13733#discussion_r1747183652


##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/operator/MultiStageOperator.java:
##########
@@ -167,6 +173,26 @@ protected TransferableBlock 
updateEosBlock(TransferableBlock upstreamEos, StatMa
     return upstreamEos;
   }
 
+  @Override
+  public ExplainInfo getExplainInfo() {
+    return new ExplainInfo(getExplainName(), getExplainAttributes(), 
getChildrenExplainInfo());
+  }
+
+  protected List<ExplainInfo> getChildrenExplainInfo() {
+    return getChildOperators().stream()
+        .filter(Objects::nonNull)
+        .map(Operator::getExplainInfo)
+        .collect(Collectors.toList());
+  }
+
+  protected String getExplainName() {
+    return toExplainString();
+  }
+
+  protected Map<String, Plan.ExplainNode.AttributeValue> 
getExplainAttributes() {
+    return Collections.emptyMap();
+  }

Review Comment:
   That is what I tried on the first iteration but... these method should be 
public, which is something I don't like because that is not part of the 
`Operator` interface. We could create another abstract class that extended by 
both `BaseOperator` and `MultiStageOperator`. I'm open to add that change, but 
I think this is simpler for now.
   
   BTW, you can see that V1 explain faced the same problem. In that case 
developers decided to add methods as `default` in the interface. As a result, 
the `Operator` methods related to explain are pretty complex and callers don't 
actually know what they should call and what they should not. Should they call 
`toExplainString`? `explainPlan`? Should they call `prepareForExplainPlan` and 
`postExplainPlan` before/after calling the other two methods? 
   
   Another side effect is that like 1/3 of the methods in `Operator` are 
related to explain, when probably callers only care about 1 or 2. If we add 
these 3 protected methods in the interface the relation would be closer to 
`1/2`!



-- 
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: commits-unsubscr...@pinot.apache.org

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


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

Reply via email to