You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by jc...@apache.org on 2020/07/25 00:42:29 UTC

[hive] branch master updated: HIVE-23908: Rewrite plan to join back tables: handle root input is an Aggregate (Krisztian Kasa, reviewed by Jesus Camacho Rodriguez)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 72ca978  HIVE-23908: Rewrite plan to join back tables: handle root input is an Aggregate (Krisztian Kasa, reviewed by Jesus Camacho Rodriguez)
72ca978 is described below

commit 72ca978260a7219a9da637047ad0aa64193597ba
Author: kasakrisz <kk...@cloudera.com>
AuthorDate: Sat Jul 25 02:42:21 2020 +0200

    HIVE-23908: Rewrite plan to join back tables: handle root input is an Aggregate (Krisztian Kasa, reviewed by Jesus Camacho Rodriguez)
    
    Closes apache/hive#1302
---
 .../HiveCardinalityPreservingJoinOptimization.java |  4 ---
 .../llap/constraints_optimization.q.out            | 36 +++++++++++++---------
 2 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveCardinalityPreservingJoinOptimization.java b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveCardinalityPreservingJoinOptimization.java
index d7a951b..6ad7724 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveCardinalityPreservingJoinOptimization.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveCardinalityPreservingJoinOptimization.java
@@ -111,10 +111,6 @@ public class HiveCardinalityPreservingJoinOptimization extends HiveRelFieldTrimm
 
       RexBuilder rexBuilder = relBuilder.getRexBuilder();
       RelNode rootInput = root.getInput(0);
-      if (rootInput instanceof Aggregate) {
-        LOG.debug("Root input is Aggregate: not supported.");
-        return root;
-      }
 
       // Build the list of projected fields from root's input RowType
       List<RexInputRef> rootFieldList = new ArrayList<>(rootInput.getRowType().getFieldCount());
diff --git a/ql/src/test/results/clientpositive/llap/constraints_optimization.q.out b/ql/src/test/results/clientpositive/llap/constraints_optimization.q.out
index f4a4ea0..dd07139 100644
--- a/ql/src/test/results/clientpositive/llap/constraints_optimization.q.out
+++ b/ql/src/test/results/clientpositive/llap/constraints_optimization.q.out
@@ -2683,13 +2683,17 @@ POSTHOOK: Input: default@store_sales
 #### A masked pattern was here ####
 CBO PLAN:
 HiveProject(c_customer_id=[$1])
-  HiveAggregate(group=[{0, 1}])
-    HiveJoin(condition=[=($0, $8)], joinType=[inner], algorithm=[none], cost=[not available])
-      HiveProject(c_customer_sk=[$0], c_customer_id=[$1], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10], c_birth_country=[$14], c_login=[$15], c_email_address=[$16])
-        HiveTableScan(table=[[default, customer]], table:alias=[customer])
-      HiveProject(ss_customer_sk=[$3])
-        HiveFilter(condition=[IS NOT NULL($3)])
-          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+  HiveSemiJoin(condition=[=($0, $2)], joinType=[semi])
+    HiveProject(c_customer_sk=[$0], c_customer_id=[$1])
+      HiveTableScan(table=[[default, customer]], table:alias=[customer])
+    HiveProject(c_customer_sk=[$0])
+      HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[CommonJoin], cost=[not available])
+        HiveProject(c_customer_sk=[$0], c_customer_id=[$1])
+          HiveTableScan(table=[[default, customer]], table:alias=[customer])
+        HiveProject(ss_customer_sk=[$0])
+          HiveFilter(condition=[IS NOT NULL($0)])
+            HiveProject(ss_customer_sk=[$3])
+              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
 
 PREHOOK: query: EXPLAIN	CBO
 SELECT
@@ -2733,13 +2737,17 @@ POSTHOOK: Input: default@store_sales
 #### A masked pattern was here ####
 CBO PLAN:
 HiveProject(c_first_name=[$1])
-  HiveAggregate(group=[{0, 1}])
-    HiveJoin(condition=[=($0, $7)], joinType=[inner], algorithm=[none], cost=[not available])
-      HiveProject(c_customer_sk=[$0], c_first_name=[$8], c_last_name=[$9], c_preferred_cust_flag=[$10], c_birth_country=[$14], c_login=[$15], c_email_address=[$16])
-        HiveTableScan(table=[[default, customer]], table:alias=[customer])
-      HiveProject(ss_customer_sk=[$3])
-        HiveFilter(condition=[IS NOT NULL($3)])
-          HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
+  HiveSemiJoin(condition=[=($0, $2)], joinType=[semi])
+    HiveProject(c_customer_sk=[$0], c_first_name=[$8])
+      HiveTableScan(table=[[default, customer]], table:alias=[customer])
+    HiveProject(c_customer_sk=[$0])
+      HiveJoin(condition=[=($0, $2)], joinType=[inner], algorithm=[CommonJoin], cost=[not available])
+        HiveProject(c_customer_sk=[$0], c_first_name=[$8])
+          HiveTableScan(table=[[default, customer]], table:alias=[customer])
+        HiveProject(ss_customer_sk=[$0])
+          HiveFilter(condition=[IS NOT NULL($0)])
+            HiveProject(ss_customer_sk=[$3])
+              HiveTableScan(table=[[default, store_sales]], table:alias=[store_sales])
 
 PREHOOK: query: EXPLAIN	CBO
 SELECT