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/21 12:47:08 UTC

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

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


##########
fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java:
##########
@@ -471,6 +473,15 @@ public class SessionVariable implements Serializable, Writable {
     @VariableMgr.VarAttr(name = ENABLE_ARRAY_TYPE)
     private boolean enableArrayType = false;
 
+    /**
+     * as the new optimizer is not mature yet, use this var
+     * to control whether to use new optimizer, remove it when
+     * the new optimizer is fully developed. I hope that day
+     * would be coming soon.
+     */
+    @VariableMgr.VarAttr(name = ENABLE_NEREIDS)
+    private boolean enableNereids = true;

Review Comment:
   enableNereids
   ```suggestion
       private boolean enableNereids = false;
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/parser/NereidsParser.java:
##########
@@ -0,0 +1,108 @@
+// 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.parser;
+
+import org.apache.doris.analysis.StatementBase;
+import org.apache.doris.nereids.DorisLexer;
+import org.apache.doris.nereids.DorisParser;
+import org.apache.doris.nereids.exceptions.ParsingException;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.plans.logical.LogicalPlan;
+import org.apache.doris.nereids.trees.plans.logical.LogicalPlanAdapter;
+
+import org.antlr.v4.runtime.CharStreams;
+import org.antlr.v4.runtime.CommonTokenStream;
+import org.antlr.v4.runtime.ParserRuleContext;
+import org.antlr.v4.runtime.atn.PredictionMode;
+import org.antlr.v4.runtime.misc.ParseCancellationException;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.function.Function;
+
+/**
+ * Sql parser, convert sql DSL to logical plan.
+ */
+public class NereidsParser {
+
+    /**
+     * In MySQL protocol, client could send multi-statement in.
+     * a single packet.
+     * https://dev.mysql.com/doc/internals/en/com-set-option.html
+     */
+    public List<StatementBase> parseSQL(String originStr) throws Exception {
+        List<LogicalPlan> logicalPlanList = parseMultiple(originStr);
+        List<StatementBase> statementBaseList = new ArrayList<>();
+        for (LogicalPlan logicalPlan : logicalPlanList) {
+            LogicalPlanAdapter logicalPlanAdapter = new LogicalPlanAdapter(logicalPlan);
+            statementBaseList.add(logicalPlanAdapter);
+        }
+        return statementBaseList;
+    }
+
+    /**
+     * parse sql DSL string.
+     *
+     * @param sql sql string
+     * @return logical plan
+     */
+    public LogicalPlan parseSingle(String sql) throws Exception {

Review Comment:
   moving in front of `parseMultiple` is better



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