trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sure...@apache.org
Subject [2/3] incubator-trafodion git commit: Address rework suggested by Hans.
Date Wed, 05 Oct 2016 00:44:03 GMT
Address rework suggested by Hans.


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/fd8f8d9f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/fd8f8d9f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/fd8f8d9f

Branch: refs/heads/master
Commit: fd8f8d9fdf436968fd3573112ec14bbfa2c2288f
Parents: 22cd2cb
Author: Suresh Subbiah <sureshs@apache.org>
Authored: Tue Oct 4 16:01:15 2016 +0000
Committer: Suresh Subbiah <sureshs@apache.org>
Committed: Tue Oct 4 16:01:15 2016 +0000

----------------------------------------------------------------------
 core/sql/optimizer/NormRelExpr.cpp | 29 +++++++----------------------
 core/sql/optimizer/RelJoin.h       |  2 +-
 2 files changed, 8 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/fd8f8d9f/core/sql/optimizer/NormRelExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NormRelExpr.cpp b/core/sql/optimizer/NormRelExpr.cpp
index ea43e69..620839c 100644
--- a/core/sql/optimizer/NormRelExpr.cpp
+++ b/core/sql/optimizer/NormRelExpr.cpp
@@ -3957,19 +3957,15 @@ RelExpr* GroupByAgg::nullPreserveMyExprs( NormWA& normWARef)
 //             an aggregate from the original groupBy.
 
 -------------------------------------------------------------------------------*/
-GroupByAgg* Join::moveUpGroupByTransformation(const GroupByAgg* topGrby, 
+GroupByAgg* Join::moveUpGroupByTransformation(GroupByAgg* topGrby, 
                                               NormWA & normWARef)
 {
   GroupByAgg *moveUpGrby;
   ValueIdSet emptySet ;
-  GroupByAgg *movedUpGrbyTail = (GroupByAgg*) topGrby;
-  GroupByAgg *subQGrby = NULL;
+  GroupByAgg *movedUpGrbyTail = topGrby;
   RelExpr * joinRightChild = child(1)->castToRelExpr();
   CollHeap *stmtHeap = CmpCommon::statementHeap() ;
 
-  if (((RelExpr*)topGrby->child(0))->getOperatorType() == REL_GROUPBY)
-    subQGrby = (GroupByAgg *) topGrby->child(0)->castToRelExpr();
-
   MapValueIds *moveUpMap = NULL;
   while ((joinRightChild->getOperatorType() == REL_GROUPBY) &&
         (((GroupByAgg*) joinRightChild)->requiresMoveUp()) || 
@@ -4028,20 +4024,12 @@ GroupByAgg* Join::moveUpGroupByTransformation(const GroupByAgg* topGrby,
 
     if (NOT safeToMoveGrby )
     { 
-        // The join contains aggregates
-        // Skip such this subquery .
-      
+      // The join contains aggregates, skip this subquery.
        return NULL ;
     }
     child(1) = joinRightChild ;
     moveUpGrby->child(0) = this ;
 
-    if (subQGrby) 
-    {
-      movedUpGrbyTail = subQGrby ;
-      subQGrby = NULL ;
-    }
-
     if (moveUpMap != NULL) 
       movedUpGrbyTail->child(0) = moveUpMap  ;
     else 
@@ -4605,18 +4593,18 @@ RelExpr * Join::semanticQueryOptimizeNode(NormWA & normWARef)
     // two or more levels of nesting. If moveUpGroupBy is not needed
     // movedUpGroupByTail will be set to newGrby.
     RelExpr* gbChild = newGrby->child(0)->castToRelExpr();
-    NABoolean nestedAggInSubQ = FALSE;
     Join * newJoin = NULL;
+    GroupByAgg * newJoinParent = newGrby;
     if (gbChild->getOperatorType() == REL_GROUPBY) 
     {
       newJoin = (Join*) gbChild->child(0)->castToRelExpr();
-      nestedAggInSubQ = TRUE;
+      newJoinParent = (GroupByAgg*) gbChild;
     }
     else
       newJoin = (Join*) gbChild;
 
     GroupByAgg* movedUpGrbyTail = 
-      newJoin->moveUpGroupByTransformation(newGrby, normWARef);
+      newJoin->moveUpGroupByTransformation(newJoinParent, normWARef);
 
     NABoolean hasNoErrors;
     if (movedUpGrbyTail != NULL) 
@@ -4643,10 +4631,7 @@ RelExpr * Join::semanticQueryOptimizeNode(NormWA & normWARef)
     {
       newJoin = newJoin->leftLinearizeJoinTree(normWARef, 
                                                UNNESTING); // Unnesting
-      if (nestedAggInSubQ)
-	movedUpGrbyTail->child(0)->child(0) = newJoin  ;
-      else
-	movedUpGrbyTail->child(0) = newJoin  ;
+      movedUpGrbyTail->child(0) = newJoin  ;
     }
 
       //synthesize logical props for the new nodes.

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/fd8f8d9f/core/sql/optimizer/RelJoin.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/RelJoin.h b/core/sql/optimizer/RelJoin.h
index f7e087b..086f7d0 100644
--- a/core/sql/optimizer/RelJoin.h
+++ b/core/sql/optimizer/RelJoin.h
@@ -780,7 +780,7 @@ public:
   GroupByAgg* pullUpGroupByTransformation(NormWA& NormWARef);
 
   // the other main transformation for subquery unnesting
-  GroupByAgg* moveUpGroupByTransformation(const GroupByAgg* newGrby, 
+  GroupByAgg* moveUpGroupByTransformation(GroupByAgg* newGrby, 
 					  NormWA & normWARef);
 
   // heuristic to unnest subquery if inner table has keyed access.


Mime
View raw message