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/04/10 16:23:39 UTC

[GitHub] [pinot] walterddr commented on a diff in pull request #10535: [multi-stage] Query compilation support for SetOperations: UNION/INTERSECT/MINUS(EXCEPT) in multi-stage engine

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


##########
pinot-common/src/main/java/org/apache/pinot/sql/parsers/CalciteSqlParser.java:
##########
@@ -184,6 +184,14 @@ public static List<String> extractTableNamesFromNode(SqlNode sqlNode) {
       }
       tableNames.addAll(extractTableNamesFromNode(((SqlWith) sqlNode).body));
       tableNames.removeAll(aliases);
+    } else if (sqlNode instanceof SqlSetOption) {
+      for (SqlNode node : ((SqlSetOption) sqlNode).getOperandList()) {
+        if (node instanceof SqlIdentifier) {
+          tableNames.addAll(((SqlIdentifier) node).names);

Review Comment:
   did we check we will produce identifier here (as table identifier)? or this is a simple copy paste?



##########
pinot-common/src/test/java/org/apache/pinot/sql/parsers/CalciteSqlCompilerTest.java:
##########
@@ -3072,6 +3072,16 @@ public void testExtractTableNamesFromNode() {
     Assert.assertEquals(tableNames.get(0), "tbl1");
     Assert.assertEquals(tableNames.get(1), "tbl2");
 
+    // query with UNION clause
+    query = "SELECT * FROM tbl1 UNION ALL SELECT * FROM tbl2 UNION ALL SELECT * FROM tbl3";

Review Comment:
   can we add several more for parsing? for example
   `WITH tmpTable AS (...) SELECT * FROM tbl1 UNION ALL tmpTable`
   ^ here tmpTable should not be part of the check



##########
pinot-query-planner/src/main/java/org/apache/pinot/query/planner/logical/StageMetadataVisitor.java:
##########
@@ -0,0 +1,148 @@
+/**
+ * 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.query.planner.logical;
+
+import java.util.HashMap;
+import java.util.List;
+import org.apache.calcite.util.Pair;
+import org.apache.pinot.query.planner.QueryPlan;
+import org.apache.pinot.query.planner.StageMetadata;
+import org.apache.pinot.query.planner.stage.AggregateNode;
+import org.apache.pinot.query.planner.stage.FilterNode;
+import org.apache.pinot.query.planner.stage.JoinNode;
+import org.apache.pinot.query.planner.stage.MailboxReceiveNode;
+import org.apache.pinot.query.planner.stage.MailboxSendNode;
+import org.apache.pinot.query.planner.stage.ProjectNode;
+import org.apache.pinot.query.planner.stage.SetOpNode;
+import org.apache.pinot.query.planner.stage.SortNode;
+import org.apache.pinot.query.planner.stage.StageNode;
+import org.apache.pinot.query.planner.stage.StageNodeVisitor;
+import org.apache.pinot.query.planner.stage.TableScanNode;
+import org.apache.pinot.query.planner.stage.ValueNode;
+import org.apache.pinot.query.planner.stage.WindowNode;
+
+
+/**
+ * {@code StageMetadataVisitor} computes the {@link StageMetadata} for a {@link StageNode}
+ * tree and attaches it in the form of a {@link QueryPlan}.
+ */
+public class StageMetadataVisitor implements StageNodeVisitor<Void, QueryPlan> {
+
+  public static QueryPlan attachMetadata(List<Pair<Integer, String>> fields, StageNode root) {
+    QueryPlan queryPlan = new QueryPlan(fields, new HashMap<>(), new HashMap<>());
+    root.visit(new StageMetadataVisitor(), queryPlan);
+    return queryPlan;
+  }
+
+  /**
+   * Usage of this class should only come through {@link #attachMetadata(List, StageNode)}.
+   */
+  private StageMetadataVisitor() {
+  }

Review Comment:
   stagemetadatavisitor is gone in #10481 i think this is a rebase issue



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