You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by st...@apache.org on 2022/02/12 07:02:25 UTC

[impala] 03/03: IMPALA-10982: fix unable to explain the set operation statement

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 c36ff0cdd7d03b0a511c78d941a32d4e78718654
Author: xqhe <he...@126.com>
AuthorDate: Sat Jan 29 11:36:11 2022 +0800

    IMPALA-10982: fix unable to explain the set operation statement
    
    For SetOperationStmt we will replace the query statement with the
    rewritten version, but we haven’t set the explain flag if the
    original is explain statement.
    
    Tests:
      -- Using impala-shell to test the explain statement of set operation.
      -- Add new test case in the explain_level tests
    
    Change-Id: I19264dfa794ffd5ed7355acfef0ac35f17c809d3
    Reviewed-on: http://gerrit.cloudera.org:8080/18179
    Reviewed-by: Impala Public Jenkins <im...@cloudera.com>
    Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
 fe/src/main/java/org/apache/impala/analysis/AnalysisContext.java | 5 ++++-
 .../functional-query/queries/QueryTest/explain-level0.test       | 8 ++++++++
 .../functional-query/queries/QueryTest/explain-level1.test       | 8 ++++++++
 .../functional-query/queries/QueryTest/explain-level2.test       | 9 +++++++++
 4 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/fe/src/main/java/org/apache/impala/analysis/AnalysisContext.java b/fe/src/main/java/org/apache/impala/analysis/AnalysisContext.java
index 8d60f80..f0c7fe9 100644
--- a/fe/src/main/java/org/apache/impala/analysis/AnalysisContext.java
+++ b/fe/src/main/java/org/apache/impala/analysis/AnalysisContext.java
@@ -556,12 +556,15 @@ public class AnalysisContext {
     if (!shouldReAnalyze) return;
 
     // For SetOperationStmt we must replace the query statement with the rewritten version
-    // before re-analysis.
+    // before re-analysis and set the explain flag of the rewritten version if the
+    // original is explain statement.
     if (analysisResult_.requiresSetOperationRewrite()) {
       if (analysisResult_.isSetOperationStmt()) {
         if (((SetOperationStmt) analysisResult_.getStmt()).hasRewrittenStmt()) {
+          boolean isExplain = analysisResult_.isExplainStmt();
           analysisResult_.stmt_ =
             ((SetOperationStmt) analysisResult_.getStmt()).getRewrittenStmt();
+          if (isExplain) analysisResult_.stmt_.setIsExplain();
         }
       }
     }
diff --git a/testdata/workloads/functional-query/queries/QueryTest/explain-level0.test b/testdata/workloads/functional-query/queries/QueryTest/explain-level0.test
index 400124a..6ee4c0e 100644
--- a/testdata/workloads/functional-query/queries/QueryTest/explain-level0.test
+++ b/testdata/workloads/functional-query/queries/QueryTest/explain-level0.test
@@ -26,3 +26,11 @@ where t1.month = 1 and t2.year = 2009 and t3.bool_col = false
 'WARNING: The following tables are missing relevant table and/or column statistics.'
 'functional_avro.alltypes, functional_parquet.alltypessmall'
 ====
+---- QUERY
+# Tests the set operation statement rewrite
+explain select year, month from functional.alltypes
+  intersect
+select year, month from functional.alltypes where year=2009;
+---- RESULTS: VERIFY_IS_SUBSET
+'04:HASH JOIN [LEFT SEMI JOIN, PARTITIONED]'
+====
\ No newline at end of file
diff --git a/testdata/workloads/functional-query/queries/QueryTest/explain-level1.test b/testdata/workloads/functional-query/queries/QueryTest/explain-level1.test
index 9a6dea3..476dabc 100644
--- a/testdata/workloads/functional-query/queries/QueryTest/explain-level1.test
+++ b/testdata/workloads/functional-query/queries/QueryTest/explain-level1.test
@@ -39,3 +39,11 @@ where t1.month = 1 and t2.year = 2009 and t3.bool_col = false
 'WARNING: The following tables are missing relevant table and/or column statistics.'
 'functional_avro.alltypes, functional_parquet.alltypessmall'
 ====
+---- QUERY
+# Tests the set operation statement rewrite
+explain select year, month from functional.alltypes
+  intersect
+select year, month from functional.alltypes where year=2009;
+---- RESULTS: VERIFY_IS_SUBSET
+'04:HASH JOIN [LEFT SEMI JOIN, PARTITIONED]'
+====
\ No newline at end of file
diff --git a/testdata/workloads/functional-query/queries/QueryTest/explain-level2.test b/testdata/workloads/functional-query/queries/QueryTest/explain-level2.test
index 6670ca0..d65e4f6 100644
--- a/testdata/workloads/functional-query/queries/QueryTest/explain-level2.test
+++ b/testdata/workloads/functional-query/queries/QueryTest/explain-level2.test
@@ -85,3 +85,12 @@ where t1.month = 1 and t2.year = 2009 and t3.bool_col = false
 'WARNING: The following tables are missing relevant table and/or column statistics.'
 'functional_avro.alltypes, functional_parquet.alltypessmall'
 ====
+---- QUERY
+# Tests the set operation statement rewrite
+explain select year, month from functional.alltypes
+  intersect
+select year, month from functional.alltypes where year=2009;
+---- RESULTS: VERIFY_IS_SUBSET
+'Per-Host Resources: mem-estimate=13.97MB mem-reservation=5.88MB thread-reservation=1 runtime-filters-memory=2.00MB'
+'04:HASH JOIN [LEFT SEMI JOIN, PARTITIONED]'
+====
\ No newline at end of file