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

morningman pushed a commit to branch dev-1.1.2
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/dev-1.1.2 by this push:
     new 9b53f809d7 [dev-1.1.2][feature](http) get create table stmt for a 
given query #11979 (#12126)
9b53f809d7 is described below

commit 9b53f809d7b6baae28faea9bf356c55947da6589
Author: Mingyu Chen <[email protected]>
AuthorDate: Mon Aug 29 09:03:34 2022 +0800

    [dev-1.1.2][feature](http) get create table stmt for a given query #11979 
(#12126)
---
 .../java/org/apache/doris/analysis/InsertStmt.java |   3 +-
 .../java/org/apache/doris/analysis/QueryStmt.java  |  13 +-
 .../java/org/apache/doris/analysis/SelectStmt.java |  28 +++--
 .../apache/doris/analysis/SetOperationStmt.java    |   8 +-
 .../java/org/apache/doris/analysis/WithClause.java |  15 ++-
 .../java/org/apache/doris/catalog/Catalog.java     |  12 +-
 .../doris/httpv2/rest/StmtExecutionAction.java     | 136 ++++++++++++++++-----
 .../java/org/apache/doris/qe/StmtExecutor.java     |   4 +-
 .../java/org/apache/doris/qe/StmtExecutorTest.java |  10 +-
 9 files changed, 151 insertions(+), 78 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/InsertStmt.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/InsertStmt.java
index ba063440cd..c505f6c3bf 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/InsertStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/InsertStmt.java
@@ -55,7 +55,6 @@ import com.google.common.base.Strings;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
-
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
@@ -190,7 +189,7 @@ public class InsertStmt extends DdlStmt {
 
     public void getTables(Analyzer analyzer, Map<Long, Table> tableMap, 
Set<String> parentViewNameSet) throws AnalysisException {
         // get dbs of statement
-        queryStmt.getTables(analyzer, tableMap, parentViewNameSet);
+        queryStmt.getTables(analyzer, false, tableMap, parentViewNameSet);
         tblName.analyze(analyzer);
         String dbName = tblName.getDb();
         String tableName = tblName.getTbl();
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/QueryStmt.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/QueryStmt.java
index 8a0862f0a8..5aeae20bbd 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/QueryStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/QueryStmt.java
@@ -28,7 +28,6 @@ import org.apache.doris.rewrite.ExprRewriter;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
-
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
@@ -440,17 +439,17 @@ public abstract class QueryStmt extends StatementBase {
         }
         if (pos > resultExprs.size()) {
             throw new AnalysisException(
-                    errorPrefix + ": ordinal exceeds number of items in select 
list: "
-                            + expr.toSql());
+                    errorPrefix + ": ordinal exceeds number of items in select 
list: " + expr.toSql());
         }
 
         // Create copy to protect against accidentally shared state.
         return resultExprs.get((int) pos - 1).clone();
     }
 
-    public void getWithClauseTables(Analyzer analyzer, Map<Long, Table> 
tableMap, Set<String> parentViewNameSet) throws AnalysisException {
+    public void getWithClauseTables(Analyzer analyzer, boolean expandView, 
Map<Long, Table> tableMap,
+            Set<String> parentViewNameSet) throws AnalysisException {
         if (withClause_ != null) {
-            withClause_.getTables(analyzer, tableMap, parentViewNameSet);
+            withClause_.getTables(analyzer, expandView, tableMap, 
parentViewNameSet);
         }
     }
 
@@ -462,6 +461,7 @@ public abstract class QueryStmt extends StatementBase {
 
     /**
      * collect all exprs of a QueryStmt to a map
+     *
      * @param exprMap
      */
     public void collectExprs(Map<String, Expr> exprMap) {
@@ -526,7 +526,8 @@ public abstract class QueryStmt extends StatementBase {
     //                "left join (select siteid, citycode from tmp) b on 
a.siteid = b.siteid;";
     // tmp in child stmt "(select siteid, citycode from tmp)" do not contain 
with_Clause
     // so need to check is view name by parentViewNameSet. issue link: 
https://github.com/apache/incubator-doris/issues/4598
-    public abstract void getTables(Analyzer analyzer, Map<Long, Table> tables, 
Set<String> parentViewNameSet) throws AnalysisException;
+    public abstract void getTables(Analyzer analyzer, boolean expandView, 
Map<Long, Table> tables,
+            Set<String> parentViewNameSet) throws AnalysisException;
 
     // get TableRefs in this query, including physical TableRefs of this 
statement and
     // nested statements of inline views and with_Clause.
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
index 54734359c3..e93abce7fc 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
@@ -290,13 +290,14 @@ public class SelectStmt extends QueryStmt {
     }
 
     @Override
-    public void getTables(Analyzer analyzer, Map<Long, Table> tableMap, 
Set<String> parentViewNameSet) throws AnalysisException {
-        getWithClauseTables(analyzer, tableMap, parentViewNameSet);
+    public void getTables(Analyzer analyzer, boolean expandView, Map<Long, 
Table> tableMap,
+            Set<String> parentViewNameSet) throws AnalysisException {
+        getWithClauseTables(analyzer, expandView, tableMap, parentViewNameSet);
         for (TableRef tblRef : fromClause_) {
             if (tblRef instanceof InlineViewRef) {
                 // Inline view reference
                 QueryStmt inlineStmt = ((InlineViewRef) tblRef).getViewStmt();
-                inlineStmt.getTables(analyzer, tableMap, parentViewNameSet);
+                inlineStmt.getTables(analyzer, expandView, tableMap, 
parentViewNameSet);
             } else {
                 String dbName = tblRef.getName().getDb();
                 String tableName = tblRef.getName().getTbl();
@@ -317,16 +318,19 @@ public class SelectStmt extends QueryStmt {
                 Database db = 
analyzer.getCatalog().getDbOrAnalysisException(dbName);
                 Table table = db.getTableOrAnalysisException(tableName);
 
-                // check auth
-                if 
(!Catalog.getCurrentCatalog().getAuth().checkTblPriv(ConnectContext.get(), 
dbName,
-                        tableName,
-                        PrivPredicate.SELECT)) {
-                    
ErrorReport.reportAnalysisException(ErrorCode.ERR_TABLEACCESS_DENIED_ERROR, 
"SELECT",
-                            ConnectContext.get().getQualifiedUser(),
-                            ConnectContext.get().getRemoteIP(),
-                            dbName + ": " + tableName);
+                if (expandView && (table instanceof View)) {
+                    View view = (View) table;
+                    view.getQueryStmt().getTables(analyzer, expandView, 
tableMap, parentViewNameSet);
+                } else {
+                    // check auth
+                    if (!Catalog.getCurrentCatalog().getAuth()
+                            .checkTblPriv(ConnectContext.get(), dbName, 
tableName, PrivPredicate.SELECT)) {
+                        
ErrorReport.reportAnalysisException(ErrorCode.ERR_TABLEACCESS_DENIED_ERROR, 
"SELECT",
+                                ConnectContext.get().getQualifiedUser(), 
ConnectContext.get().getRemoteIP(),
+                                dbName + ": " + tableName);
+                    }
+                    tableMap.put(table.getId(), table);
                 }
-                tableMap.put(table.getId(), table);
             }
         }
     }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/SetOperationStmt.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/SetOperationStmt.java
index acdd28e595..bcd13c373d 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SetOperationStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SetOperationStmt.java
@@ -24,7 +24,6 @@ import org.apache.doris.rewrite.ExprRewriter;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
-
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
@@ -179,10 +178,11 @@ public class SetOperationStmt extends QueryStmt {
     public List<Expr> getSetOpsResultExprs() { return setOpsResultExprs_; }
 
     @Override
-    public void getTables(Analyzer analyzer, Map<Long, Table> tableMap, 
Set<String> parentViewNameSet) throws AnalysisException {
-        getWithClauseTables(analyzer, tableMap, parentViewNameSet);
+    public void getTables(Analyzer analyzer, boolean expandView, Map<Long, 
Table> tableMap,
+            Set<String> parentViewNameSet) throws AnalysisException {
+        getWithClauseTables(analyzer, expandView, tableMap, parentViewNameSet);
         for (SetOperand op : operands) {
-            op.getQueryStmt().getTables(analyzer, tableMap, parentViewNameSet);
+            op.getQueryStmt().getTables(analyzer, expandView, tableMap, 
parentViewNameSet);
         }
     }
 
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/WithClause.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/WithClause.java
index 57710eb38a..5d777c3bb2 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/WithClause.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/WithClause.java
@@ -21,6 +21,7 @@ import org.apache.doris.catalog.Table;
 import org.apache.doris.catalog.View;
 import org.apache.doris.common.AnalysisException;
 import org.apache.doris.common.UserException;
+
 import com.google.common.base.Joiner;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
@@ -95,21 +96,23 @@ public class WithClause implements ParseNode {
     private WithClause(WithClause other) {
         Preconditions.checkNotNull(other);
         views_ = Lists.newArrayList();
-        for (View view: other.views_) {
-            views_.add(new View(view.getName(), view.getQueryStmt().clone(),
-                    view.getOriginalColLabels()));
+        for (View view : other.views_) {
+            views_.add(new View(view.getName(), view.getQueryStmt().clone(), 
view.getOriginalColLabels()));
         }
     }
 
     public void reset() {
-        for (View view: views_) view.getQueryStmt().reset();
+        for (View view : views_) {
+            view.getQueryStmt().reset();
+        }
     }
 
-    public void getTables(Analyzer analyzer, Map<Long, Table> tableMap, 
Set<String> parentViewNameSet) throws AnalysisException {
+    public void getTables(Analyzer analyzer, boolean expandView, Map<Long, 
Table> tableMap,
+            Set<String> parentViewNameSet) throws AnalysisException {
         for (View view : views_) {
             QueryStmt stmt = view.getQueryStmt();
             parentViewNameSet.add(view.getName());
-            stmt.getTables(analyzer, tableMap, parentViewNameSet);
+            stmt.getTables(analyzer, expandView, tableMap, parentViewNameSet);
         }
     }
 
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
index aef7c4a792..94aa682236 100755
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
@@ -264,7 +264,6 @@ import com.google.common.collect.Sets;
 import com.sleepycat.je.rep.InsufficientLogException;
 import com.sleepycat.je.rep.NetworkRestore;
 import com.sleepycat.je.rep.NetworkRestoreConfig;
-
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.hadoop.hive.metastore.HiveMetaStoreClient;
@@ -272,7 +271,6 @@ import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.codehaus.jackson.map.ObjectMapper;
 
-import javax.annotation.Nullable;
 import java.io.BufferedReader;
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
@@ -298,6 +296,7 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.stream.Collectors;
+import javax.annotation.Nullable;
 
 public class Catalog {
     private static final Logger LOG = LogManager.getLogger(Catalog.class);
@@ -4132,8 +4131,7 @@ public class Catalog {
         if (table.getType() == TableType.VIEW) {
             View view = (View) table;
             sb.append("CREATE VIEW `").append(table.getName()).append("` AS 
").append(view.getInlineViewDef());
-            sb.append(";");
-            createTableStmt.add(sb.toString());
+            createTableStmt.add(sb + ";");
             return;
         }
 
@@ -4431,7 +4429,7 @@ public class Catalog {
             sb.append("\n)");
         }
 
-        createTableStmt.add(sb.toString());
+        createTableStmt.add(sb + ";");
 
         // 2. add partition
         if (separatePartition && (table instanceof OlapTable) && ((OlapTable) 
table).getPartitions().size() > 1) {
@@ -4464,7 +4462,7 @@ public class Catalog {
                     sb.append(partition.getVisibleVersion())
                             .append("\"");
                     sb.append(");");
-                    addPartitionStmt.add(sb.toString());
+                    addPartitionStmt.add(sb + ";");
                 }
             }
         }
@@ -4491,7 +4489,7 @@ public class Catalog {
                     }
                 }
                 sb.append(");");
-                createRollupStmt.add(sb.toString());
+                createRollupStmt.add(sb + ";");
             }
         }
     }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/StmtExecutionAction.java
 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/StmtExecutionAction.java
index ea6a9df6e8..b2ffd17935 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/StmtExecutionAction.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/StmtExecutionAction.java
@@ -17,30 +17,46 @@
 
 package org.apache.doris.httpv2.rest;
 
-import org.apache.doris.common.DdlException;
+import org.apache.doris.analysis.Analyzer;
+import org.apache.doris.analysis.QueryStmt;
+import org.apache.doris.analysis.SqlParser;
+import org.apache.doris.analysis.SqlScanner;
+import org.apache.doris.analysis.StatementBase;
+import org.apache.doris.catalog.Catalog;
+import org.apache.doris.catalog.Table;
+import org.apache.doris.common.util.SqlParserUtils;
 import org.apache.doris.httpv2.entity.ResponseEntityBuilder;
 import org.apache.doris.httpv2.util.ExecutionResultSet;
 import org.apache.doris.httpv2.util.StatementSubmitter;
 import org.apache.doris.qe.ConnectContext;
 import org.apache.doris.system.SystemInfoService;
 
+import com.google.common.base.Joiner;
+import com.google.common.base.Strings;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
+import org.jetbrains.annotations.NotNull;
+import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
-import com.google.common.base.Strings;
-import com.google.gson.Gson;
-import com.google.gson.reflect.TypeToken;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+import java.io.StringReader;
 import java.lang.reflect.Type;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 
 /**
  * For execute stmt via http
@@ -50,9 +66,6 @@ public class StmtExecutionAction extends RestBaseController {
     private static final Logger LOG = 
LogManager.getLogger(StmtExecutionAction.class);
     private static StatementSubmitter stmtSubmitter = new StatementSubmitter();
 
-    private static final String PARAM_SYNC = "sync";
-    private static final String PARAM_LIMIT = "limit";
-
     private static final long DEFAULT_ROW_LIMIT = 1000;
     private static final long MAX_ROW_LIMIT = 10000;
 
@@ -60,48 +73,74 @@ public class StmtExecutionAction extends RestBaseController 
{
      * Execute a SQL.
      * Request body:
      * {
-     *     "stmt" : "select * from tbl1"
+     * "is_sync": 1,   // optional
+     * "limit" : 1000  // optional
+     * "stmt" : "select * from tbl1"   // required
      * }
      */
     @RequestMapping(path = "/api/query/{" + NS_KEY + "}/{" + DB_KEY + "}", 
method = {RequestMethod.POST})
-    public Object executeSQL(
-            @PathVariable(value = NS_KEY) String ns,
-            @PathVariable(value = DB_KEY) String dbName,
-            HttpServletRequest request, HttpServletResponse response,
-            @RequestBody String stmtBody) throws DdlException {
+    public Object executeSQL(@PathVariable(value = NS_KEY) String ns, 
@PathVariable(value = DB_KEY) String dbName,
+            HttpServletRequest request, HttpServletResponse response, 
@RequestBody String body) {
         ActionAuthorizationInfo authInfo = checkWithCookie(request, response, 
false);
 
         if (!ns.equalsIgnoreCase(SystemInfoService.DEFAULT_CLUSTER)) {
             return ResponseEntityBuilder.badRequest("Only support 
'default_cluster' now");
         }
 
-        boolean isSync = true;
-        String syncParam = request.getParameter(PARAM_SYNC);
-        if (!Strings.isNullOrEmpty(syncParam)) {
-            isSync = syncParam.equals("1");
-        }
-
-        String limitParam = request.getParameter(PARAM_LIMIT);
-        long limit = DEFAULT_ROW_LIMIT;
-        if (!Strings.isNullOrEmpty(limitParam)) {
-            limit = Math.min(Long.valueOf(limitParam), MAX_ROW_LIMIT);
-        }
-
         Type type = new TypeToken<StmtRequestBody>() {
         }.getType();
-        StmtRequestBody stmtRequestBody = new Gson().fromJson(stmtBody, type);
+        StmtRequestBody stmtRequestBody = new Gson().fromJson(body, type);
 
         if (Strings.isNullOrEmpty(stmtRequestBody.stmt)) {
             return ResponseEntityBuilder.badRequest("Missing statement request 
body");
         }
         LOG.info("stmt: {}", stmtRequestBody.stmt);
 
+        LOG.info("stmt: {}, isSync:{}, limit: {}", stmtRequestBody.stmt, 
stmtRequestBody.is_sync,
+                stmtRequestBody.limit);
+
         ConnectContext.get().setDatabase(getFullDbName(dbName));
+        return executeQuery(authInfo, stmtRequestBody.is_sync, 
stmtRequestBody.limit, stmtRequestBody);
+    }
 
-        // 2. Submit stmt
-        StatementSubmitter.StmtContext stmtCtx = new 
StatementSubmitter.StmtContext(
-                stmtRequestBody.stmt, authInfo.fullUserName, 
authInfo.password, limit
-        );
+    /**
+     * Get all create table stmt of a SQL
+     *
+     * @param ns
+     * @param dbName
+     * @param request
+     * @param response
+     * @param sql plain text of sql
+     * @return plain text of create table stmts
+     */
+    @RequestMapping(path = "/api/query_schema/{" + NS_KEY + "}/{" + DB_KEY + 
"}", method = {RequestMethod.POST})
+    public String querySchema(@PathVariable(value = NS_KEY) String ns, 
@PathVariable(value = DB_KEY) String dbName,
+            HttpServletRequest request, HttpServletResponse response, 
@RequestBody String sql) {
+        checkWithCookie(request, response, false);
+
+        if (!ns.equalsIgnoreCase(SystemInfoService.DEFAULT_CLUSTER)) {
+            return "";
+        }
+        LOG.info("sql: {}", sql);
+
+        ConnectContext.get().setDatabase(getFullDbName(dbName));
+        return getSchema(sql);
+    }
+
+    /**
+     * Execute a query
+     *
+     * @param authInfo
+     * @param isSync
+     * @param limit
+     * @param stmtRequestBody
+     * @return
+     */
+    @NotNull
+    private ResponseEntity executeQuery(ActionAuthorizationInfo authInfo, 
boolean isSync, long limit,
+            StmtRequestBody stmtRequestBody) {
+        StatementSubmitter.StmtContext stmtCtx = new 
StatementSubmitter.StmtContext(stmtRequestBody.stmt,
+                authInfo.fullUserName, authInfo.password, limit);
         Future<ExecutionResultSet> future = stmtSubmitter.submit(stmtCtx);
 
         if (isSync) {
@@ -120,7 +159,38 @@ public class StmtExecutionAction extends 
RestBaseController {
         }
     }
 
+    @NotNull
+    private String getSchema(String sql) {
+        SqlParser parser = new SqlParser(new SqlScanner(new 
StringReader(sql)));
+        StatementBase stmt = null;
+        try {
+            stmt = SqlParserUtils.getStmt(parser, 0);
+            if (!(stmt instanceof QueryStmt)) {
+                return "Only support query stmt";
+            }
+            Analyzer analyzer = new Analyzer(Catalog.getCurrentCatalog(), 
ConnectContext.get());
+            QueryStmt queryStmt = (QueryStmt) stmt;
+            Map<Long, Table> tableMap = Maps.newHashMap();
+            Set<String> parentViewNameSet = Sets.newHashSet();
+            queryStmt.getTables(analyzer, true, tableMap, parentViewNameSet);
+
+            List<String> createStmts = Lists.newArrayList();
+            for (Table tbl : tableMap.values()) {
+                List<String> createTableStmts = Lists.newArrayList();
+                Catalog.getDdlStmt(tbl, createTableStmts, null, null, false, 
true);
+                if (!createTableStmts.isEmpty()) {
+                    createStmts.add(createTableStmts.get(0));
+                }
+            }
+            return Joiner.on("\n\n").join(createStmts);
+        } catch (Exception e) {
+            return "Error:" + e.getMessage();
+        }
+    }
+
     private static class StmtRequestBody {
+        public Boolean is_sync = true; // CHECKSTYLE IGNORE THIS LINE
+        public Long limit = DEFAULT_ROW_LIMIT;
         public String stmt;
     }
 }
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 da7e7a9821..132da10d62 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
@@ -565,11 +565,11 @@ public class StmtExecutor implements ProfileWriter {
             Set<String> parentViewNameSet = Sets.newHashSet();
             if (parsedStmt instanceof QueryStmt) {
                 queryStmt = (QueryStmt) parsedStmt;
-                queryStmt.getTables(analyzer, tableMap, parentViewNameSet);
+                queryStmt.getTables(analyzer, false, tableMap, 
parentViewNameSet);
             } else if (parsedStmt instanceof CreateTableAsSelectStmt) {
                 CreateTableAsSelectStmt parsedStmt = (CreateTableAsSelectStmt) 
this.parsedStmt;
                 queryStmt = parsedStmt.getQueryStmt();
-                queryStmt.getTables(analyzer, tableMap, parentViewNameSet);
+                queryStmt.getTables(analyzer, false, tableMap, 
parentViewNameSet);
             } else {
                 InsertStmt insertStmt = (InsertStmt) parsedStmt;
                 insertStmt.getTables(analyzer, tableMap, parentViewNameSet);
diff --git a/fe/fe-core/src/test/java/org/apache/doris/qe/StmtExecutorTest.java 
b/fe/fe-core/src/test/java/org/apache/doris/qe/StmtExecutorTest.java
index 0ab38a3fbd..95fa283556 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/qe/StmtExecutorTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/qe/StmtExecutorTest.java
@@ -45,7 +45,9 @@ import org.apache.doris.thrift.TUniqueId;
 
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
-
+import java_cup.runtime.Symbol;
+import mockit.Expectations;
+import mockit.Mocked;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -59,10 +61,6 @@ import java.util.List;
 import java.util.SortedMap;
 import java.util.concurrent.atomic.AtomicBoolean;
 
-import java_cup.runtime.Symbol;
-import mockit.Expectations;
-import mockit.Mocked;
-
 public class StmtExecutorTest {
     private ConnectContext ctx;
     private QueryState state;
@@ -198,7 +196,7 @@ public class StmtExecutorTest {
                 minTimes = 0;
                 result = false;
 
-                queryStmt.getTables((Analyzer) any, (SortedMap) any, 
Sets.newHashSet());
+                queryStmt.getTables((Analyzer) any, anyBoolean, (SortedMap) 
any, Sets.newHashSet());
                 minTimes = 0;
 
                 queryStmt.getRedirectStatus();


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

Reply via email to