You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/06/23 02:32:11 UTC

[GitHub] [doris] yinzhijian commented on a diff in pull request #10304: [feature](nereids) Integrate nereids into current SQL process framework

yinzhijian commented on code in PR #10304:
URL: https://github.com/apache/doris/pull/10304#discussion_r904463311


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/PlannerAdapter.java:
##########
@@ -0,0 +1,75 @@
+// 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.doris.nereids;
+
+import org.apache.doris.analysis.Analyzer;
+import org.apache.doris.analysis.StatementBase;
+import org.apache.doris.common.UserException;
+import org.apache.doris.nereids.properties.PhysicalProperties;
+import org.apache.doris.nereids.trees.plans.PhysicalPlanTranslator;
+import org.apache.doris.nereids.trees.plans.PlanContext;
+import org.apache.doris.nereids.trees.plans.logical.LogicalPlanAdapter;
+import org.apache.doris.nereids.trees.plans.physical.PhysicalPlan;
+import org.apache.doris.planner.PlanFragment;
+import org.apache.doris.planner.Planner;
+import org.apache.doris.planner.ScanNode;
+import org.apache.doris.qe.ConnectContext;
+import org.apache.doris.thrift.TQueryOptions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * TODO: Abstract a common interface for both nereids and stale.
+ *       optimizer may be better.
+ * This class is used for the compatibility and code reuse in.
+ * @see org.apache.doris.qe.StmtExecutor
+ */
+public class PlannerAdapter extends Planner {
+
+    private final org.apache.doris.nereids.Planner planner;
+    private final ConnectContext ctx;
+    private List<ScanNode> scanNodeList = null;
+
+    public PlannerAdapter(ConnectContext ctx) {
+        this.planner = new org.apache.doris.nereids.Planner();
+        this.ctx = ctx;
+    }
+
+    @Override
+    public void plan(StatementBase queryStmt, Analyzer analyzer, TQueryOptions queryOptions) throws UserException {
+        if (!(queryStmt instanceof LogicalPlanAdapter)) {
+            throw new RuntimeException("Wrong type of queryStmt, expected: <? extends LogicalPlanAdapter>");
+        }
+        LogicalPlanAdapter logicalPlanAdapter = (LogicalPlanAdapter) queryStmt;
+        PhysicalPlan physicalPlan = planner.plan(logicalPlanAdapter.getLogicalPlan(), new PhysicalProperties(), ctx);
+        PhysicalPlanTranslator physicalPlanTranslator = new PhysicalPlanTranslator();
+        PlanContext planContext = new PlanContext();
+        physicalPlanTranslator.translatePlan(physicalPlan, planContext);
+        fragments = new ArrayList<>(planContext.getPlanFragmentList());
+        PlanFragment root = fragments.get(fragments.size() - 1);
+        root.getPlanRoot().convertToVectoriezd();

Review Comment:
   You may need to add ```if (VectorizedUtil.isVectorized()) ``` here



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

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


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