You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "walterddr (via GitHub)" <gi...@apache.org> on 2023/05/02 04:02:39 UTC

[GitHub] [pinot] walterddr commented on a diff in pull request #10622: [multistage] UNION/INTERSECT/EXCEPT implementation

walterddr commented on code in PR #10622:
URL: https://github.com/apache/pinot/pull/10622#discussion_r1182060916


##########
pinot-query-planner/src/main/java/org/apache/calcite/rel/rules/PinotSetOpExchangeNodeInsertRule.java:
##########
@@ -0,0 +1,84 @@
+/**
+ * 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.calcite.rel.rules;
+
+import com.google.common.collect.ImmutableList;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.calcite.plan.RelOptRule;
+import org.apache.calcite.plan.RelOptRuleCall;
+import org.apache.calcite.rel.RelDistributions;
+import org.apache.calcite.rel.RelNode;
+import org.apache.calcite.rel.core.SetOp;
+import org.apache.calcite.rel.logical.LogicalExchange;
+import org.apache.calcite.rel.logical.LogicalIntersect;
+import org.apache.calcite.rel.logical.LogicalMinus;
+import org.apache.calcite.rel.logical.LogicalUnion;
+import org.apache.calcite.tools.RelBuilderFactory;
+
+
+/**
+ * Special rule for Pinot, this rule is fixed to always insert exchange after SetOp node.
+ */
+public class PinotSetOpExchangeNodeInsertRule extends RelOptRule {
+  public static final PinotSetOpExchangeNodeInsertRule INSTANCE =
+      new PinotSetOpExchangeNodeInsertRule(PinotRuleUtils.PINOT_REL_FACTORY);
+
+  public PinotSetOpExchangeNodeInsertRule(RelBuilderFactory factory) {
+    super(operand(SetOp.class, any()), factory, null);
+  }
+
+  @Override
+  public boolean matches(RelOptRuleCall call) {
+    if (call.rels.length < 1) {
+      return false;
+    }
+    if (call.rel(0) instanceof SetOp) {
+      SetOp setOp = call.rel(0);
+      for (RelNode input : setOp.getInputs()) {
+        if (PinotRuleUtils.isExchange(input)) {
+          return false;
+        }
+      }
+      return true;
+    }
+    return false;
+  }
+
+  @Override
+  public void onMatch(RelOptRuleCall call) {
+    SetOp setOp = call.rel(0);
+    List<RelNode> newInputs = new ArrayList<>();
+    for (RelNode input : setOp.getInputs()) {
+      RelNode exchange = LogicalExchange.create(input, RelDistributions.hash(ImmutableList.of(0)));

Review Comment:
   this is basically sending all data to a single server? wouldn't it cause blow up?



##########
pinot-query-runtime/src/main/java/org/apache/pinot/query/runtime/plan/PhysicalPlanVisitor.java:
##########
@@ -105,8 +110,24 @@ public MultiStageOperator visitWindow(WindowNode node, PlanRequestContext contex
 
   @Override
   public MultiStageOperator visitSetOp(SetOpNode setOpNode, PlanRequestContext context) {
-    throw new UnsupportedOperationException(
-        "Stage node of type SetOpNode: " + setOpNode.getSetOpType() + " is not supported!");
+    List<MultiStageOperator> inputs = new ArrayList<>();
+    for (StageNode input : setOpNode.getInputs()) {
+      MultiStageOperator visited = input.visit(this, context);
+      inputs.add(visited);
+    }
+    switch (setOpNode.getSetOpType()) {
+      case UNION:
+        return new UnionOperator(context.getOpChainExecutionContext(), inputs,
+            setOpNode.getInputs().get(0).getDataSchema());

Review Comment:
   this and others below: seems like it is assuming it always gets Union "all=true"?
   do we plan to support all=false going forward? if so can we add check on `setOp.all` ? and also add a ignored test in SetOp.json test cases?



-- 
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-unsubscribe@pinot.apache.org

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


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