You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by su...@apache.org on 2016/10/05 00:44:02 UTC

[1/3] incubator-trafodion git commit: [TRAFODION-2159] Promoting outputs of child with MapValueId node

Repository: incubator-trafodion
Updated Branches:
  refs/heads/master b8dc6da0a -> d223ed9c6


[TRAFODION-2159] Promoting outputs of child with MapValueId node

Promoting outputs of child was not working correctly when the child is a
MapValueId node. Since the promoted outputs are not part of the map, MVI
could not produce the promoted outputs though its child was willing to.
Also fixed another bug recently introduced in the moveUpGrbyTransformation,
when there is a subquery groupby in the correlated subquery.


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

Branch: refs/heads/master
Commit: 22cd2cbf373f5a2622378f5871cd28ecf64f89e3
Parents: 3ae78e5
Author: Suresh Subbiah <su...@apache.org>
Authored: Mon Oct 3 19:48:12 2016 +0000
Committer: Suresh Subbiah <su...@apache.org>
Committed: Mon Oct 3 19:48:12 2016 +0000

----------------------------------------------------------------------
 core/sql/optimizer/NormRelExpr.cpp          | 18 ++++++++++++++++--
 core/sql/optimizer/RelExpr.cpp              |  8 ++++++++
 core/sql/optimizer/RelMisc.h                |  1 +
 core/sql/regress/compGeneral/EXPECTED011.SB | 22 ++++++++++------------
 4 files changed, 35 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/22cd2cbf/core/sql/optimizer/NormRelExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NormRelExpr.cpp b/core/sql/optimizer/NormRelExpr.cpp
index 4cdf154..ea43e69 100644
--- a/core/sql/optimizer/NormRelExpr.cpp
+++ b/core/sql/optimizer/NormRelExpr.cpp
@@ -1142,6 +1142,11 @@ NABoolean RelExpr::getMoreOutputsIfPossible(ValueIdSet& outputsNeeded)
       maxOutputs,
       outputsNeeded);
       child(i)->getGroupAttr()->addCharacteristicOutputs(outputsToAdd);
+      if (getOperatorType() == REL_MAP_VALUEIDS) 
+      {
+	((MapValueIds *)this)->addSameMapEntries(outputsToAdd);
+      }
+
 
      // child(i).getGroupAttr()->computeCharacteristicIO
 //	                                            (emptySet,  // no additional inputs
@@ -3958,9 +3963,12 @@ GroupByAgg* Join::moveUpGroupByTransformation(const GroupByAgg* topGrby,
   GroupByAgg *moveUpGrby;
   ValueIdSet emptySet ;
   GroupByAgg *movedUpGrbyTail = (GroupByAgg*) topGrby;
+  GroupByAgg *subQGrby = NULL;
   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) &&
@@ -4028,6 +4036,12 @@ GroupByAgg* Join::moveUpGroupByTransformation(const GroupByAgg* topGrby,
     child(1) = joinRightChild ;
     moveUpGrby->child(0) = this ;
 
+    if (subQGrby) 
+    {
+      movedUpGrbyTail = subQGrby ;
+      subQGrby = NULL ;
+    }
+
     if (moveUpMap != NULL) 
       movedUpGrbyTail->child(0) = moveUpMap  ;
     else 
@@ -4070,7 +4084,7 @@ GroupByAgg* Join::moveUpGroupByTransformation(const GroupByAgg* topGrby,
 
     // Sometimes the moveUpMap ends up being empty after being moved
     // on top of a Join. Eliminate it if we don't need it, otherwise 
-    // it will impeeded output flow.
+    // it will impede output flow.
 
     if ( moveUpMap != NULL && 
          moveUpMap->getGroupAttr()->getCharacteristicOutputs().isEmpty()) 
@@ -4135,7 +4149,7 @@ GroupByAgg* Join::moveUpGroupByTransformation(const GroupByAgg* topGrby,
 // sufficient outputs cannot be produced to compute left side's 
 // unique columns
 //
-// Expects: Child(0) to be a Join.
+// Expects: Child(0) to be a Join or a subQ groupby.
 // Sideffects: recomputed inputs and outputs of the join child's children
 //             recomputed inputs and outputs of the join.
 //             pushes any of the groupBy's predicates down that can go down.

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/22cd2cbf/core/sql/optimizer/RelExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/RelExpr.cpp b/core/sql/optimizer/RelExpr.cpp
index a6d00fe..9928f88 100644
--- a/core/sql/optimizer/RelExpr.cpp
+++ b/core/sql/optimizer/RelExpr.cpp
@@ -11998,6 +11998,14 @@ void MapValueIds::getPotentialOutputValues(ValueIdSet & outputValues) const
   outputValues.insertList((getMap2()).getTopValues());
 } // MapValueIds::getPotentialOutputValues()
 
+void MapValueIds::addSameMapEntries(const ValueIdSet & newTopBottomValues)
+{
+  for (ValueId x = newTopBottomValues.init();
+	    newTopBottomValues.next(x);
+	    newTopBottomValues.advance(x))
+    addMapEntry(x,x);
+}
+
 void MapValueIds::addLocalExpr(LIST(ExprNode *) &xlist,
 			       LIST(NAString) &llist) const
 {

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/22cd2cbf/core/sql/optimizer/RelMisc.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/RelMisc.h b/core/sql/optimizer/RelMisc.h
index e4632bf..6ec680c 100644
--- a/core/sql/optimizer/RelMisc.h
+++ b/core/sql/optimizer/RelMisc.h
@@ -1508,6 +1508,7 @@ public:
                                       { valuesNeededForVEGRewrite_ += v; }
   inline void clearValuesForVEGRewrite()
                                    { valuesNeededForVEGRewrite_.clear(); }
+  void addSameMapEntries(const ValueIdSet & newTopBottomValues);
 
   // Method to compute child's characteristic outputs
   virtual

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/22cd2cbf/core/sql/regress/compGeneral/EXPECTED011.SB
----------------------------------------------------------------------
diff --git a/core/sql/regress/compGeneral/EXPECTED011.SB b/core/sql/regress/compGeneral/EXPECTED011.SB
index f70659d..77c9d8a 100644
--- a/core/sql/regress/compGeneral/EXPECTED011.SB
+++ b/core/sql/regress/compGeneral/EXPECTED011.SB
@@ -1106,8 +1106,6 @@ A
 
 *** WARNING[2997]  (Attempting to unnest Subquery)
 
-*** WARNING[2997]  (Subquery was not unnested. Reason: Left subtree cannot produce output values required for grouping.)
-
 --- SQL command prepared.
 >>execute explainIt;
 
@@ -1840,9 +1838,9 @@ ss          ?
 A           (EXPR)    
 ----------  ----------
 
+ss          ?         
 xx          ?         
 xx          ?         
-ss          ?         
 
 --- 3 row(s) selected.
 >>
@@ -1856,8 +1854,8 @@ A           (EXPR)
 ----------  ----------
 
 xx          ?         
-xx          ?         
 ss          ?         
+xx          ?         
 
 --- 3 row(s) selected.
 >>
@@ -1910,6 +1908,14 @@ abcd      abc%     abcdefg
 abcd      abc%     abcdefgh
 abcd      abc%     abcedf  
 abcd      abcdef%  aaa     
+abcde     abc%     aaa     
+abcde     abc%     abc     
+abcde     abc%     abcd    
+abcde     abc%     abcde   
+abcde     abc%     abcdefg 
+abcde     abc%     abcdefgh
+abcde     abc%     abcedf  
+abcde     abcdef%  aaa     
 abcdefg   abc%     aaa     
 abcdefg   abc%     abc     
 abcdefg   abc%     abcd    
@@ -1934,14 +1940,6 @@ abcedf    abc%     abcdefg
 abcedf    abc%     abcdefgh
 abcedf    abc%     abcedf  
 abcedf    abcdef%  aaa     
-abcde     abc%     aaa     
-abcde     abc%     abc     
-abcde     abc%     abcd    
-abcde     abc%     abcde   
-abcde     abc%     abcdefg 
-abcde     abc%     abcdefgh
-abcde     abc%     abcedf  
-abcde     abcdef%  aaa     
 
 --- 56 row(s) selected.
 >>


[3/3] incubator-trafodion git commit: Merge [TRAFODION-2159] PR-739 Outputs not promoted when MapValueId node is present

Posted by su...@apache.org.
Merge [TRAFODION-2159] PR-739 Outputs not promoted when MapValueId node is present


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

Branch: refs/heads/master
Commit: d223ed9c6cbc22bdd335e9fe16f87338f23979b1
Parents: b8dc6da fd8f8d9
Author: Suresh Subbiah <su...@apache.org>
Authored: Wed Oct 5 00:40:50 2016 +0000
Committer: Suresh Subbiah <su...@apache.org>
Committed: Wed Oct 5 00:40:50 2016 +0000

----------------------------------------------------------------------
 core/sql/optimizer/NormRelExpr.cpp          | 29 ++++++++++++------------
 core/sql/optimizer/RelExpr.cpp              |  8 +++++++
 core/sql/optimizer/RelJoin.h                |  2 +-
 core/sql/optimizer/RelMisc.h                |  1 +
 core/sql/regress/compGeneral/EXPECTED011.SB | 22 ++++++++----------
 5 files changed, 34 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d223ed9c/core/sql/optimizer/NormRelExpr.cpp
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d223ed9c/core/sql/optimizer/RelExpr.cpp
----------------------------------------------------------------------


[2/3] incubator-trafodion git commit: Address rework suggested by Hans.

Posted by su...@apache.org.
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 <su...@apache.org>
Authored: Tue Oct 4 16:01:15 2016 +0000
Committer: Suresh Subbiah <su...@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.