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

stigahuang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git

commit e8e8a5150e21c9b1f92ad5d04a94e8812cdd29dd
Author: Steve Carlin <[email protected]>
AuthorDate: Fri May 17 10:35:02 2024 -0700

    IMPALA-13441: Support explain statements in Impala planner
    
    This adds support for explain statements for the Calcite planner.
    This also fixes up the Parser.jj file so that statements not
    processed by Calcite planner will fail, like "describe" and other
    non-select statements.  The parser will now only handle "select"
    and "explain" as the first keyword.
    
    If the parser fails, we need to do an additional check within Impala.
    We run the statement through the Impala parser and check the statement
    type.  If the statement type is anything other than SelectStmt,
    we run the query within the original Impala planner. If it is a SelectStmt,
    we fail the query because we want all select statements to go through
    the Calcite parser.
    
    Change-Id: Iea6afaa1f1698a300ad047c8820691cf7e8eb44b
    Reviewed-on: http://gerrit.cloudera.org:8080/21923
    Reviewed-by: Impala Public Jenkins <[email protected]>
    Tested-by: Impala Public Jenkins <[email protected]>
---
 .../java/org/apache/impala/planner/Planner.java    | 17 ++--
 .../java/org/apache/impala/service/Frontend.java   |  2 +-
 .../src/main/codegen/templates/Parser.jj           | 57 ++-----------
 .../impala/calcite/service/CalciteJniFrontend.java | 54 +++++-------
 .../impala/calcite/service/ExecRequestCreator.java | 23 +++---
 .../queries/QueryTest/calcite.test                 | 95 ++++++++++++++++++++++
 6 files changed, 144 insertions(+), 104 deletions(-)

diff --git a/fe/src/main/java/org/apache/impala/planner/Planner.java 
b/fe/src/main/java/org/apache/impala/planner/Planner.java
index 91c824ae3..131a268e6 100644
--- a/fe/src/main/java/org/apache/impala/planner/Planner.java
+++ b/fe/src/main/java/org/apache/impala/planner/Planner.java
@@ -361,7 +361,8 @@ public class Planner {
     if (ctx_.getAnalysisResult().isExplainStmt() || 
RuntimeEnv.INSTANCE.isTestEnv()) {
       explainLevel = ctx_.getQueryOptions().getExplain_level();
     }
-    return getExplainString(fragments, request, explainLevel);
+    return getExplainString(fragments, request, explainLevel, 
ctx_.getQueryOptions(),
+        ctx_.getQueryStmt());
   }
 
   /**
@@ -369,8 +370,9 @@ public class Planner {
    * explicit explain level.
    * Includes the estimated resource requirements from the request if set.
    */
-  public String getExplainString(List<PlanFragment> fragments,
-      TQueryExecRequest request, TExplainLevel explainLevel) {
+  public static String getExplainString(List<PlanFragment> fragments,
+      TQueryExecRequest request, TExplainLevel explainLevel,
+      TQueryOptions options, QueryStmt queryStmt) {
     StringBuilder str = new StringBuilder();
     boolean hasHeader = false;
 
@@ -452,9 +454,10 @@ public class Planner {
       hasHeader = true;
     }
 
-    if (explainLevel.ordinal() >= TExplainLevel.EXTENDED.ordinal()) {
+    if (explainLevel.ordinal() >= TExplainLevel.EXTENDED.ordinal() &&
+        queryStmt != null) {
       // In extended explain include the analyzed query text showing implicit 
casts
-      String queryText = ctx_.getQueryStmt().toSql(SHOW_IMPLICIT_CASTS);
+      String queryText = queryStmt.toSql(SHOW_IMPLICIT_CASTS);
       String wrappedText = PrintUtils.wrapString("Analyzed query: " + 
queryText, 80);
       str.append(wrappedText).append("\n");
       hasHeader = true;
@@ -467,12 +470,12 @@ public class Planner {
 
     if (explainLevel.ordinal() < TExplainLevel.VERBOSE.ordinal()) {
       // Print the non-fragmented parallel plan.
-      str.append(fragments.get(0).getExplainString(ctx_.getQueryOptions(), 
explainLevel));
+      str.append(fragments.get(0).getExplainString(options, explainLevel));
     } else {
       // Print the fragmented parallel plan.
       for (int i = 0; i < fragments.size(); ++i) {
         PlanFragment fragment = fragments.get(i);
-        str.append(fragment.getExplainString(ctx_.getQueryOptions(), 
explainLevel));
+        str.append(fragment.getExplainString(options, explainLevel));
         if (i < fragments.size() - 1) str.append("\n");
       }
     }
diff --git a/fe/src/main/java/org/apache/impala/service/Frontend.java 
b/fe/src/main/java/org/apache/impala/service/Frontend.java
index 9b8dab55a..ae398128b 100644
--- a/fe/src/main/java/org/apache/impala/service/Frontend.java
+++ b/fe/src/main/java/org/apache/impala/service/Frontend.java
@@ -3017,7 +3017,7 @@ public class Frontend {
   /**
    * Attaches the explain result to the TExecRequest.
    */
-  private void createExplainRequest(String explainString, TExecRequest result) 
{
+  public static void createExplainRequest(String explainString, TExecRequest 
result) {
     // update the metadata - one string column
     TColumn colDesc = new TColumn("Explain String", Type.STRING.toThrift());
     TResultSetMetadata metadata = new 
TResultSetMetadata(Lists.newArrayList(colDesc));
diff --git a/java/calcite-planner/src/main/codegen/templates/Parser.jj 
b/java/calcite-planner/src/main/codegen/templates/Parser.jj
index 6a59388dd..f21f912c1 100644
--- a/java/calcite-planner/src/main/codegen/templates/Parser.jj
+++ b/java/calcite-planner/src/main/codegen/templates/Parser.jj
@@ -1132,43 +1132,9 @@ SqlNode SqlStmt() :
 }
 {
     (
-<#-- Add methods to parse additional statements here -->
-<#list (parser.statementParserMethods!default.parser.statementParserMethods) 
as method>
-        LOOKAHEAD(2) stmt = ${method}
-    |
-</#list>
-        stmt = SqlSetOption(Span.of(), null)
-    |
-        stmt = SqlAlter()
-    |
-<#if 
(parser.createStatementParserMethods!default.parser.createStatementParserMethods)?size
 != 0>
-        stmt = SqlCreate()
-    |
-</#if>
-<#if 
(parser.dropStatementParserMethods!default.parser.dropStatementParserMethods)?size
 != 0>
-        stmt = SqlDrop()
-    |
-</#if>
-<#if 
(parser.truncateStatementParserMethods!default.parser.truncateStatementParserMethods)?size
 != 0>
-        LOOKAHEAD(2)
-        stmt = SqlTruncate()
-    |
-</#if>
         stmt = OrderedQueryOrExpr(ExprContext.ACCEPT_QUERY)
     |
         stmt = SqlExplain()
-    |
-        stmt = SqlDescribe()
-    |
-        stmt = SqlInsert()
-    |
-        stmt = SqlDelete()
-    |
-        stmt = SqlUpdate()
-    |
-        stmt = SqlMerge()
-    |
-        stmt = SqlProcedureCall()
     )
     {
         return stmt;
@@ -1395,26 +1361,13 @@ SqlNode SqlExplain() :
     final SqlExplainFormat format;
 }
 {
-    <EXPLAIN> <PLAN>
-    [ detailLevel = ExplainDetailLevel() ]
-    depth = ExplainDepth()
-    (
-        LOOKAHEAD(2)
-        <AS> <XML> { format = SqlExplainFormat.XML; }
-    |
-        LOOKAHEAD(2)
-        <AS> <JSON> { format = SqlExplainFormat.JSON; }
-    |
-        <AS> <DOT_FORMAT> { format = SqlExplainFormat.DOT; }
-    |
-        { format = SqlExplainFormat.TEXT; }
-    )
-    <FOR> stmt = SqlQueryOrDml() {
+    <EXPLAIN>
+    stmt = SqlQueryOrDml() {
         return new SqlExplain(getPos(),
             stmt,
-            detailLevel.symbol(SqlParserPos.ZERO),
-            depth.symbol(SqlParserPos.ZERO),
-            format.symbol(SqlParserPos.ZERO),
+            SqlExplainLevel.ALL_ATTRIBUTES.symbol(SqlParserPos.ZERO),
+            SqlExplain.Depth.PHYSICAL.symbol(SqlParserPos.ZERO),
+            SqlExplainFormat.TEXT.symbol(SqlParserPos.ZERO),
             nDynamicParams);
     }
 }
diff --git 
a/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteJniFrontend.java
 
b/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteJniFrontend.java
index 54b582a94..44708ac37 100644
--- 
a/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteJniFrontend.java
+++ 
b/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteJniFrontend.java
@@ -22,7 +22,11 @@ import org.apache.calcite.rel.RelNode;
 import org.apache.calcite.rel.metadata.DefaultRelMetadataProvider;
 import org.apache.calcite.rel.metadata.JaninoRelMetadataProvider;
 import org.apache.calcite.rel.metadata.RelMetadataQuery;
+import org.apache.calcite.sql.SqlExplain;
 import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.parser.SqlParseException;
+import org.apache.impala.analysis.Parser;
+import org.apache.impala.analysis.SelectStmt;
 import org.apache.impala.calcite.functions.FunctionResolver;
 import org.apache.impala.calcite.operators.ImpalaOperatorTable;
 import org.apache.impala.calcite.rel.node.NodeWithExprs;
@@ -85,9 +89,6 @@ public class CalciteJniFrontend extends JniFrontend {
     
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
 
     QueryContext queryCtx = new QueryContext(thriftQueryContext, 
getFrontend());
-    if (!canStmtBePlannedThroughCalcite(queryCtx)) {
-      return runThroughOriginalPlanner(thriftQueryContext, queryCtx);
-    }
 
     try (FrontendProfile.Scope scope = FrontendProfile.createNewWithScope()) {
       LOG.info("Using Calcite Planner for the following query: " + 
queryCtx.getStmt());
@@ -104,6 +105,11 @@ public class CalciteJniFrontend extends JniFrontend {
           new CalciteMetadataHandler(parsedSqlNode, queryCtx);
       markEvent(mdHandler, null, queryCtx, "Loaded tables");
 
+      boolean isExplain = false;
+      if (parsedSqlNode instanceof SqlExplain) {
+        isExplain = true;
+        parsedSqlNode = ((SqlExplain) parsedSqlNode).getExplicandum();
+      }
       // Validate the parsed query
       CalciteValidator validator = new CalciteValidator(mdHandler, queryCtx);
       SqlNode validatedNode = validator.validate(parsedSqlNode);
@@ -127,7 +133,7 @@ public class CalciteJniFrontend extends JniFrontend {
 
       // Create exec request for the server
       ExecRequestCreator execRequestCreator =
-          new ExecRequestCreator(physPlanCreator, queryCtx, mdHandler);
+          new ExecRequestCreator(physPlanCreator, queryCtx, mdHandler, 
isExplain);
       TExecRequest execRequest = execRequestCreator.create(rootNode);
       markEvent(mdHandler, execRequest, queryCtx, "Created exec request");
 
@@ -136,6 +142,16 @@ public class CalciteJniFrontend extends JniFrontend {
       queryCtx.getTimeline().markEvent("Serialized request");
 
       return serializedRequest;
+    } catch (SqlParseException e) {
+      // do a quick parse just to make sure it's not a select stmt. If it is
+      // a select statement, we fail the query since all select statements
+      // should be run through the Calcite Planner.
+      if (Parser.parse(queryCtx.getStmt()) instanceof SelectStmt) {
+        throw new InternalException(e.getMessage());
+      }
+      LOG.info("Calcite planner failed to parse query: " + queryCtx.getStmt());
+      LOG.info("Going to use original Impala planner.");
+      return runThroughOriginalPlanner(thriftQueryContext, queryCtx);
     } catch (Exception e) {
       LOG.info("Calcite planner failed.");
       LOG.info("Exception: " + e);
@@ -147,36 +163,6 @@ public class CalciteJniFrontend extends JniFrontend {
     }
   }
 
-  /**
-   * Use information about the query syntax to see if this can be handled
-   * by Calcite
-   */
-  private boolean canStmtBePlannedThroughCalcite(QueryContext queryCtx) {
-    String stringWithFirstRealWord = queryCtx.getStmt();
-    String[] lines = stringWithFirstRealWord.split("\n");
-    // Get rid of comments and blank lines which start the query. We need to 
find
-    // the first real word.
-    // TODO: IMPALA-12976: need to make this more generic. Certain patterns 
aren't caught
-    // here like /* */
-    for (String line : lines) {
-      if (line.trim().startsWith("--") || line.trim().equals("")) {
-        stringWithFirstRealWord = stringWithFirstRealWord.replaceFirst(line + 
"\n", "");
-      } else {
-        break;
-      }
-    }
-    stringWithFirstRealWord = stringWithFirstRealWord.trim();
-    String beforeStripString;
-    do {
-      beforeStripString = stringWithFirstRealWord;
-      stringWithFirstRealWord = 
StringUtils.stripStart(stringWithFirstRealWord, "(");
-      stringWithFirstRealWord = 
StringUtils.stripStart(stringWithFirstRealWord, null);
-    } while (!stringWithFirstRealWord.equals(beforeStripString));
-    return StringUtils.startsWithIgnoreCase(stringWithFirstRealWord, "select") 
||
-        StringUtils.startsWithIgnoreCase(stringWithFirstRealWord, "values") ||
-        StringUtils.startsWithIgnoreCase(stringWithFirstRealWord, "with");
-  }
-
   /**
    * Fallback planner method
    */
diff --git 
a/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/ExecRequestCreator.java
 
b/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/ExecRequestCreator.java
index 96c0a990c..36cb3d9fc 100644
--- 
a/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/ExecRequestCreator.java
+++ 
b/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/ExecRequestCreator.java
@@ -87,12 +87,15 @@ public class ExecRequestCreator implements CompilerStep {
   private final CalcitePhysPlanCreator physPlanCreator;
   private final CalciteJniFrontend.QueryContext queryCtx;
   private final CalciteMetadataHandler mdHandler;
+  private final boolean isExplain;
 
   public ExecRequestCreator(CalcitePhysPlanCreator physPlanCreator,
-      CalciteJniFrontend.QueryContext queryCtx, CalciteMetadataHandler 
mdHandler) {
+      CalciteJniFrontend.QueryContext queryCtx, CalciteMetadataHandler 
mdHandler,
+      boolean isExplain) {
     this.physPlanCreator = physPlanCreator;
     this.queryCtx = queryCtx;
     this.mdHandler = mdHandler;
+    this.isExplain = isExplain;
   }
 
   /**
@@ -146,18 +149,15 @@ public class ExecRequestCreator implements CompilerStep {
     List<PlanFragment> allFragments = planFragmentRoot.getNodesPreOrder();
     // to mimic the original planner behavior, use EXTENDED mode explain 
except for
     // EXPLAIN statements.
-    // TODO: support explain plans
-    // TExplainLevel explainLevel =
-    //     isExplain ? plannerContext.getQueryOptions().getExplain_level() :
-    //     TExplainLevel.EXTENDED;
-    TExplainLevel explainLevel = TExplainLevel.EXTENDED;
-    // if (isExplain) {
-    //   result.setStmt_type(TStmtType.EXPLAIN);
-    // }
+    TExplainLevel explainLevel =
+        isExplain ? plannerContext.getQueryOptions().getExplain_level() :
+        TExplainLevel.EXTENDED;
+    if (isExplain) {
+      result.setStmt_type(TStmtType.EXPLAIN);
+    }
     String explainString = getExplainString(allFragments, explainLevel, 
plannerContext);
     queryExecRequest.setQuery_plan(explainString);
 
-
     queryCtx.setDesc_tbl_serialized(
         plannerContext.getRootAnalyzer().getDescTbl().toSerializedThrift());
 
@@ -170,6 +170,9 @@ public class ExecRequestCreator implements CompilerStep {
     this.queryCtx.getFrontend().addPlannerToProfile("CalcitePlanner");
     result.setProfile(FrontendProfile.getCurrent().emitAsThrift());
     
result.setProfile_children(FrontendProfile.getCurrent().emitChildrenAsThrift());
+    if (isExplain) {
+      this.queryCtx.getFrontend().createExplainRequest(explainString, result);
+    }
     return result;
   }
 
diff --git a/testdata/workloads/functional-query/queries/QueryTest/calcite.test 
b/testdata/workloads/functional-query/queries/QueryTest/calcite.test
index 05a4a8c93..207af6d07 100644
--- a/testdata/workloads/functional-query/queries/QueryTest/calcite.test
+++ b/testdata/workloads/functional-query/queries/QueryTest/calcite.test
@@ -132,6 +132,8 @@ select bigint_col, abs(cast(-3 as bigint)), 
abs(-3000000000) from functional.all
 10,3,3000000000
 ---- TYPES
 bigint,bigint,bigint
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 # Tiny test for Calcite. At the point of this commit, very few functions work. 
This
@@ -150,6 +152,8 @@ select cast(cast('2005-12-13 08:00:00' as string)  AS 
TIMESTAMP) from functional
 2005-12-13 08:00:00
 ---- TYPES
 timestamp
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 select * from calcite_alltypes where bigint_col = 20;
@@ -157,6 +161,8 @@ select * from calcite_alltypes where bigint_col = 20;
 2,true,2,2,2,20,2.200000047683716,20.2,'01/01/09','2',2009-01-01 
00:02:00.100000000,2009,1
 ---- TYPES
 
int,boolean,tinyint,smallint,int,bigint,float,double,string,string,timestamp,int,int
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 select tinyint_col from calcite_alltypes where bigint_col = 20;
@@ -164,6 +170,8 @@ select tinyint_col from calcite_alltypes where bigint_col = 
20;
 2
 ---- TYPES
 tinyint
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 # Values test
@@ -172,6 +180,8 @@ select abs(cast(-8 as bigint));
 8
 ---- TYPES
 bigint
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 select 'hello'
@@ -179,6 +189,8 @@ select 'hello'
 'hello'
 ---- TYPES
 string
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 # Union test
@@ -188,6 +200,8 @@ select 3 union select 4;
 4
 ---- TYPES
 tinyint
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 select * from (values (1)) union (values (2), (3));
@@ -208,6 +222,8 @@ select id, abs(bigint_col) from functional.alltypestiny 
where id > 3 order by ab
 7,10
 ---- TYPES
 int, bigint
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 # sort test
@@ -220,6 +236,8 @@ select id, abs(bigint_col) from functional.alltypestiny 
where id >= 3 order by a
 7,10
 ---- TYPES
 int, bigint
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 # sort test
@@ -230,6 +248,8 @@ select id, abs(bigint_col) from functional.alltypestiny 
where id < 3 order by ab
 1,10
 ---- TYPES
 int, bigint
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 # sort test
@@ -241,6 +261,8 @@ select id, abs(bigint_col) from functional.alltypestiny 
where id <= 3 order by a
 3,10
 ---- TYPES
 int, bigint
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 # sort test
@@ -255,6 +277,8 @@ select id, abs(bigint_col) from functional.alltypestiny 
where id != 3 order by a
 7,10
 ---- TYPES
 int, bigint
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 # sort test
@@ -269,6 +293,8 @@ select id, abs(bigint_col) from functional.alltypestiny 
where id != 3 order by a
 6,0
 ---- TYPES
 int, bigint
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 # sort test
@@ -281,6 +307,8 @@ select group_str, some_nulls from functional.nullrows where 
group_str = 'a' orde
 'a','a'
 ---- TYPES
 string, string
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 # sort test
@@ -293,6 +321,8 @@ select group_str, some_nulls from functional.nullrows where 
group_str = 'a' orde
 'a','NULL'
 ---- TYPES
 string, string
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 # limit test
@@ -312,6 +342,8 @@ select id, abs(bigint_col) from functional.alltypestiny 
where id > 2 order by ab
 3,10
 ---- TYPES
 int, bigint
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 # aggregation test
@@ -320,6 +352,8 @@ select sum(bigint_col) from functional.alltypestiny;
 40
 ---- TYPES
 bigint
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 # aggregation test
@@ -335,6 +369,8 @@ select id, sum(bigint_col) from functional.alltypestiny 
group by id order by id;
 7,10
 ---- TYPES
 int, bigint
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 # aggregation test
@@ -347,6 +383,8 @@ having sum(bigint_col) > cast(5 as bigint)  order by id;
 7,10
 ---- TYPES
 int, bigint
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 # aggregation test
@@ -375,6 +413,8 @@ NULL,0,0
 NULL,10,40
 ---- TYPES
 int, bigint, bigint
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 # having test
@@ -386,6 +426,8 @@ select id, sum(bigint_col) from functional.alltypestiny 
group by id having sum(b
 7,10
 ---- TYPES
 int, bigint
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 # join test
@@ -404,6 +446,8 @@ on (a.id = b.id) order by a.id;
 7,10,70
 ---- TYPES
 int, bigint, bigint
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 # join inequality test
@@ -423,6 +467,8 @@ order by a.id;
 7,0,10,0
 ---- TYPES
 int, int, bigint,  bigint
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 # cross join test
@@ -449,6 +495,8 @@ order by a.id, b.id;
 7,1,10,10
 ---- TYPES
 int, int, bigint, bigint
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 # left outer join test
@@ -481,6 +529,8 @@ order by a.id
 19,90,NULL
 ---- TYPES
 int, bigint, bigint
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 select bigint_col + bigint_col, int_col + int_col, smallint_col + smallint_col,
@@ -497,6 +547,8 @@ from functional.alltypestiny;
 20,2,2,2,2
 ---- TYPES
 bigint, bigint, int, smallint, int
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 select float_col + int_col, float_col + 3.0, 3.0 + 3.0
@@ -512,6 +564,8 @@ from functional.alltypestiny;
 2.10000002384,4.10000002,6.0
 ---- TYPES
 double, decimal, decimal
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 select bigint_col - bigint_col, int_col - int_col, smallint_col - smallint_col,
@@ -654,6 +708,8 @@ select 3 union select 458;
 458
 ---- TYPES
 smallint
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 # case test
@@ -669,6 +725,8 @@ select tinyint_col, case tinyint_col when 1 then 5 else 458 
end from functional.
 1,5
 ---- TYPES
 tinyint,smallint
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 # case test
@@ -684,6 +742,8 @@ select tinyint_col, case tinyint_col when 1 then 5 when 2 
then 7 else 458 end fr
 1,5
 ---- TYPES
 tinyint,smallint
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 # case test
@@ -699,6 +759,8 @@ select tinyint_col, case tinyint_col when 0 then 458 else 5 
end from functional.
 1,5
 ---- TYPES
 tinyint,smallint
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 # case test
@@ -714,6 +776,8 @@ select tinyint_col, case tinyint_col when 0 then 458 end 
from functional.alltype
 1,NULL
 ---- TYPES
 tinyint,smallint
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 # case test other format (the calcite rexnode should be the same)
@@ -729,6 +793,8 @@ select tinyint_col, case when tinyint_col=00 then 458 else 
5 end from functional
 1,5
 ---- TYPES
 tinyint,smallint
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 # or test
@@ -744,6 +810,8 @@ true
 true
 ---- TYPES
 boolean
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 # and test
@@ -759,6 +827,8 @@ true
 true
 ---- TYPES
 boolean
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 # sum cast tinyint agg test
@@ -767,6 +837,8 @@ select sum(tinyint_col) from functional.alltypestiny;
 4
 ---- TYPES
 bigint
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 # duplicate test from analytics-fn.test, delete when it is activated.
@@ -801,6 +873,8 @@ order by date_part;
 9999-12-31,2,9999-12-01,9999-12-31
 ---- TYPES
 DATE, BIGINT, DATE, DATE
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
 ====
 ---- QUERY
 # Test ROWS windows with start boundaries
@@ -846,3 +920,24 @@ select "1" as "hello";
 '1'
 ---- TYPES
 string
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
+====
+---- QUERY
+explain select * from functional.alltypestiny;
+---- RESULTS: VERIFY_IS_SUBSET
+row_regex:.*01:EXCHANGE.*
+row_regex:.*00:SCAN HDFS.*
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
+====
+---- QUERY
+set explain_level=3;
+explain select * from functional.alltypestiny;
+---- RESULTS: VERIFY_IS_SUBSET
+row_regex:.*01:EXCHANGE.*
+row_regex:.*00:SCAN HDFS.*
+row_regex:.*HDFS partitions=4/4.*
+---- RUNTIME_PROFILE
+row_regex: .*PlannerType: CalcitePlanner.*
+====

Reply via email to