This is an automated email from the ASF dual-hosted git repository.

yangzhg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 8610903  abstract some codes to a new parse method for further 
scalability (#5800)
8610903 is described below

commit 86109039240a33cf75c185152abd91af21483c9b
Author: copperybean <[email protected]>
AuthorDate: Mon May 17 11:52:45 2021 +0800

    abstract some codes to a new parse method for further scalability (#5800)
---
 .../java/org/apache/doris/qe/StmtExecutor.java     | 68 ++++++++++++----------
 1 file changed, 36 insertions(+), 32 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java 
b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
index b5b7588..a2b78a4 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
@@ -431,38 +431,7 @@ public class StmtExecutor implements ProfileWriter {
     public void analyze(TQueryOptions tQueryOptions) throws UserException {
         LOG.info("begin to analyze stmt: {}, forwarded stmt id: {}", 
context.getStmtId(), context.getForwardedStmtId());
 
-        // parsedStmt may already by set when constructing this StmtExecutor();
-        if (parsedStmt == null) {
-            // Parse statement with parser generated by CUP&FLEX
-            SqlScanner input = new SqlScanner(new 
StringReader(originStmt.originStmt), context.getSessionVariable().getSqlMode());
-            SqlParser parser = new SqlParser(input);
-            try {
-                parsedStmt = SqlParserUtils.getStmt(parser, originStmt.idx);
-                parsedStmt.setOrigStmt(originStmt);
-                parsedStmt.setUserInfo(context.getCurrentUserIdentity());
-            } catch (Error e) {
-                LOG.info("error happened when parsing stmt {}, id: {}", 
originStmt, context.getStmtId(), e);
-                throw new AnalysisException("sql parsing error, please check 
your sql");
-            } catch (AnalysisException e) {
-                String syntaxError = parser.getErrorMsg(originStmt.originStmt);
-                LOG.info("analysis exception happened when parsing stmt {}, 
id: {}, error: {}",
-                        originStmt, context.getStmtId(), syntaxError, e);
-                if (syntaxError == null) {
-                    throw  e;
-                } else {
-                    throw new AnalysisException(syntaxError, e);
-                }
-            } catch (Exception e) {
-                // TODO(lingbin): we catch 'Exception' to prevent unexpected 
error,
-                // should be removed this try-catch clause future.
-                LOG.info("unexpected exception happened when parsing stmt {}, 
id: {}, error: {}",
-                        originStmt, context.getStmtId(), 
parser.getErrorMsg(originStmt.originStmt), e);
-                throw new AnalysisException("Unexpected exception: " + 
e.getMessage());
-            }
-
-            analyzeVariablesInStmt();
-        }
-        redirectStatus = parsedStmt.getRedirectStatus();
+        parse();
 
         // yiguolei: insert stmt's grammar analysis will write editlog, so 
that we check if the stmt should be forward to master here
         // if the stmt should be forward to master, then just return here and 
the master will do analysis again
@@ -530,6 +499,41 @@ public class StmtExecutor implements ProfileWriter {
         }
     }
 
+    private void parse() throws AnalysisException, DdlException {
+        // parsedStmt may already by set when constructing this StmtExecutor();
+        if (parsedStmt == null) {
+            // Parse statement with parser generated by CUP&FLEX
+            SqlScanner input = new SqlScanner(new 
StringReader(originStmt.originStmt), context.getSessionVariable().getSqlMode());
+            SqlParser parser = new SqlParser(input);
+            try {
+                parsedStmt = SqlParserUtils.getStmt(parser, originStmt.idx);
+                parsedStmt.setOrigStmt(originStmt);
+                parsedStmt.setUserInfo(context.getCurrentUserIdentity());
+            } catch (Error e) {
+                LOG.info("error happened when parsing stmt {}, id: {}", 
originStmt, context.getStmtId(), e);
+                throw new AnalysisException("sql parsing error, please check 
your sql");
+            } catch (AnalysisException e) {
+                String syntaxError = parser.getErrorMsg(originStmt.originStmt);
+                LOG.info("analysis exception happened when parsing stmt {}, 
id: {}, error: {}",
+                        originStmt, context.getStmtId(), syntaxError, e);
+                if (syntaxError == null) {
+                    throw  e;
+                } else {
+                    throw new AnalysisException(syntaxError, e);
+                }
+            } catch (Exception e) {
+                // TODO(lingbin): we catch 'Exception' to prevent unexpected 
error,
+                // should be removed this try-catch clause future.
+                LOG.info("unexpected exception happened when parsing stmt {}, 
id: {}, error: {}",
+                        originStmt, context.getStmtId(), 
parser.getErrorMsg(originStmt.originStmt), e);
+                throw new AnalysisException("Unexpected exception: " + 
e.getMessage());
+            }
+
+            analyzeVariablesInStmt();
+        }
+        redirectStatus = parsedStmt.getRedirectStatus();
+    }
+
     private void analyzeAndGenerateQueryPlan(TQueryOptions tQueryOptions) 
throws UserException {
         parsedStmt.analyze(analyzer);
         if (parsedStmt instanceof QueryStmt || parsedStmt instanceof 
InsertStmt) {

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to