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


##########
pinot-core/src/main/java/org/apache/pinot/core/plan/PinotExplainedRelNode.java:
##########
@@ -0,0 +1,146 @@
+/**
+ * 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.
+ */
+package org.apache.pinot.core.plan;
+
+import com.google.common.collect.Lists;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import org.apache.calcite.plan.RelOptCluster;
+import org.apache.calcite.plan.RelTraitSet;
+import org.apache.calcite.rel.AbstractRelNode;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.RelWriter;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeFactory;
+import org.apache.calcite.rel.type.RelDataTypeField;
+import org.apache.calcite.rel.type.RelDataTypeFieldImpl;
+import org.apache.calcite.rel.type.RelRecordType;
+import org.apache.calcite.rel.type.StructKind;
+import org.apache.pinot.common.proto.Plan;
+import org.apache.pinot.common.utils.DataSchema;
+
+
+/**
+ * This class is a hackish way to adapt Pinot explain plan into Calcite 
explain plan.
+ *
+ * While in Calcite both logical and physical operators are represented by 
classes that extend RelNode, in multi-stage
+ * Pinot plans we first optimize {@link RelNode RelNodes} at logical level in 
the broker and then we transform send
+ * these RelNodes to the server (using {@code 
org.apache.pinot.query.planner.plannode.PlanNode} as intermediate format).
+ *
+ * Servers then extract leaf nodes from the stage, trying to execute as much 
as possible in a leaf operator. In that
+ * leaf operator is where nodes are compiled into single-stage physical 
operators
+ * (aka {@link org.apache.pinot.core.operator.BaseOperator}), which include 
important information like whether indexes
+ * are being used or not.
+ *
+ * {@link PinotExplainedRelNode} is a way to represent these single-stage 
operators in Calcite.
+ * <b>They are not meant to be executed</b>.
+ * Instead, when physical explain is required, the broker ask for the final 
plan to each server. They return
+ * a PlanNode and the broker then converts these PlanNodes into a 
PinotExplainedRelNode. The logical plan is then
+ * modified to substitute the nodes that were converted into single-stage 
physical plans with the corresponding
+ * PinotExplainedRelNode.
+ */
+public class PinotExplainedRelNode extends AbstractRelNode {
+
+  /**
+   * The name of this node, whose role is like a title in the explain plan.
+   */
+  private final String _type;
+  private final Map<String, Plan.ExplainNode.AttributeValue> _attributes;
+  private final List<RelNode> _inputs;
+  private final DataSchema _dataSchema;
+
+  public PinotExplainedRelNode(RelOptCluster cluster, RelTraitSet traitSet, 
String type,

Review Comment:
   Removed



##########
pinot-core/src/main/java/org/apache/pinot/core/plan/PinotExplainedRelNode.java:
##########
@@ -0,0 +1,146 @@
+/**
+ * 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.
+ */
+package org.apache.pinot.core.plan;
+
+import com.google.common.collect.Lists;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import org.apache.calcite.plan.RelOptCluster;
+import org.apache.calcite.plan.RelTraitSet;
+import org.apache.calcite.rel.AbstractRelNode;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.RelWriter;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeFactory;
+import org.apache.calcite.rel.type.RelDataTypeField;
+import org.apache.calcite.rel.type.RelDataTypeFieldImpl;
+import org.apache.calcite.rel.type.RelRecordType;
+import org.apache.calcite.rel.type.StructKind;
+import org.apache.pinot.common.proto.Plan;
+import org.apache.pinot.common.utils.DataSchema;
+
+
+/**
+ * This class is a hackish way to adapt Pinot explain plan into Calcite 
explain plan.
+ *
+ * While in Calcite both logical and physical operators are represented by 
classes that extend RelNode, in multi-stage
+ * Pinot plans we first optimize {@link RelNode RelNodes} at logical level in 
the broker and then we transform send
+ * these RelNodes to the server (using {@code 
org.apache.pinot.query.planner.plannode.PlanNode} as intermediate format).
+ *
+ * Servers then extract leaf nodes from the stage, trying to execute as much 
as possible in a leaf operator. In that
+ * leaf operator is where nodes are compiled into single-stage physical 
operators
+ * (aka {@link org.apache.pinot.core.operator.BaseOperator}), which include 
important information like whether indexes
+ * are being used or not.
+ *
+ * {@link PinotExplainedRelNode} is a way to represent these single-stage 
operators in Calcite.
+ * <b>They are not meant to be executed</b>.
+ * Instead, when physical explain is required, the broker ask for the final 
plan to each server. They return
+ * a PlanNode and the broker then converts these PlanNodes into a 
PinotExplainedRelNode. The logical plan is then
+ * modified to substitute the nodes that were converted into single-stage 
physical plans with the corresponding
+ * PinotExplainedRelNode.
+ */
+public class PinotExplainedRelNode extends AbstractRelNode {
+
+  /**
+   * The name of this node, whose role is like a title in the explain plan.
+   */
+  private final String _type;
+  private final Map<String, Plan.ExplainNode.AttributeValue> _attributes;
+  private final List<RelNode> _inputs;
+  private final DataSchema _dataSchema;
+
+  public PinotExplainedRelNode(RelOptCluster cluster, RelTraitSet traitSet, 
String type,

Review Comment:
   Added



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