trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lium...@apache.org
Subject [3/4] incubator-trafodion git commit: fix more review comments for TRAFODION-2270
Date Sat, 12 Nov 2016 00:35:48 GMT
fix more review comments for TRAFODION-2270


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

Branch: refs/heads/master
Commit: 91390a3f579274758a27dcceb31e1964457b0b36
Parents: 0bba8d6
Author: Liu Ming <ovis_poly@sina.com>
Authored: Thu Nov 10 09:18:42 2016 -0500
Committer: Liu Ming <ovis_poly@sina.com>
Committed: Thu Nov 10 09:18:42 2016 -0500

----------------------------------------------------------------------
 core/sql/optimizer/BindRelExpr.cpp    |  4 ++-
 core/sql/optimizer/NormRelExpr.cpp    |  6 ++--
 core/sql/optimizer/OptPhysRelExpr.cpp | 44 +++++++++++++++---------------
 core/sql/optimizer/RelGrby.h          |  3 +-
 4 files changed, 30 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/91390a3f/core/sql/optimizer/BindRelExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/BindRelExpr.cpp b/core/sql/optimizer/BindRelExpr.cpp
index 4a56d4e..f82d238 100644
--- a/core/sql/optimizer/BindRelExpr.cpp
+++ b/core/sql/optimizer/BindRelExpr.cpp
@@ -4553,7 +4553,9 @@ RelRoot * RelRoot::transformGroupByWithOrdinalPhase2(BindWA *bindWA)
         if( ((PivotGroup*)vid.getItemExpr())->orderBy() ) 
         {
           grby->setExtraGrpOrderby(((PivotGroup*)vid.getItemExpr())->getOrderbyItemExpr());
-          grby->getExtraGrpOrderby()->convertToValueIdList(grby->extraOrderExpr(),
bindWA, ITM_ITEM_LIST);
+          ValueIdList tmpList;
+          grby->getExtraGrpOrderby()->convertToValueIdList(tmpList, bindWA, ITM_ITEM_LIST);
+          grby->setExtraOrderExpr(tmpList);
         }
       }
     }

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/91390a3f/core/sql/optimizer/NormRelExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NormRelExpr.cpp b/core/sql/optimizer/NormRelExpr.cpp
index d83bb81..252deac 100644
--- a/core/sql/optimizer/NormRelExpr.cpp
+++ b/core/sql/optimizer/NormRelExpr.cpp
@@ -5218,9 +5218,9 @@ void GroupByAgg::rewriteNode(NormWA & normWARef)
   if (rollupGroupExprList().normalizeNode(normWARef))
     {
     }
-  if (extraOrderExpr().normalizeNode(normWARef))
-    {
-    }
+ 
+  normalizeExtraOrderExpr(normWARef);
+
   // ---------------------------------------------------------------------
   // Rewrite the expressions that are aggregate expressions
   // ---------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/91390a3f/core/sql/optimizer/OptPhysRelExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/OptPhysRelExpr.cpp b/core/sql/optimizer/OptPhysRelExpr.cpp
index 91d67cc..5d87610 100644
--- a/core/sql/optimizer/OptPhysRelExpr.cpp
+++ b/core/sql/optimizer/OptPhysRelExpr.cpp
@@ -11808,29 +11808,30 @@ void SortGroupBy::addArrangementAndOrderRequirements(
   // A GROUP BY ROLLUP needs the exact order as specified.
   if (isRollup() && (NOT rollupGroupExprList().isEmpty()))
     {
-      rg.addSortKey(rollupGroupExprList());
+      if( NOT extraOrderExpr().isEmpty())
+      {
+        ValueIdList groupExprCpy(rollupGroupExprList());
+        groupExprCpy.insert(extraOrderExpr());
+        rg.addSortKey(groupExprCpy);
+      }
+      else
+        rg.addSortKey(rollupGroupExprList());
     }
   else if (NOT groupExpr().isEmpty())
-  {
-    // Shouldn't/Can't add a sort order type requirement
-    // if we are in DP2
-
-   if( NOT extraOrderExpr().isEmpty())
-   {
-     ValueIdList groupExprCpy(groupExpr());
-     for (CollIndex i=0; i< extraOrderExpr().entries(); i++)
-     {
-       groupExprCpy.insert(extraOrderExpr().at(i));   
-     }
-     rg.addSortKey(groupExprCpy);
-   }
-   else {
-     if (rg.getStartRequirements()->executeInDP2())
-       rg.addArrangement(groupExpr(),NO_SOT);
-     else
-       rg.addArrangement(groupExpr(),ESP_SOT);
-   }
-  }
+    {
+      if( NOT extraOrderExpr().isEmpty())
+      {
+        ValueIdList groupExprCpy(groupExpr());
+        groupExprCpy.insert(extraOrderExpr());
+        rg.addSortKey(groupExprCpy);
+      }
+      else {
+        if (rg.getStartRequirements()->executeInDP2())
+          rg.addArrangement(groupExpr(),NO_SOT);
+        else
+          rg.addArrangement(groupExpr(),ESP_SOT);
+      }
+    }
 }
 
 //<pb>
@@ -11868,7 +11869,6 @@ SortGroupBy::synthPhysicalProperty(const Context* myContext,
                                                              planNumber,
                                                              pws);
 
-      //PhysicalProperty(((isRollup() ||NOT extraOrderExpr().isEmpty()) ? ValueIdList() :
sppOfChild->getSortKey()),
   PhysicalProperty* sppForMe =
     new (CmpCommon::statementHeap())
       PhysicalProperty((isRollup() ? ValueIdList() : sppOfChild->getSortKey()),

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/91390a3f/core/sql/optimizer/RelGrby.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/RelGrby.h b/core/sql/optimizer/RelGrby.h
index b493dd6..fe4c96a 100644
--- a/core/sql/optimizer/RelGrby.h
+++ b/core/sql/optimizer/RelGrby.h
@@ -154,8 +154,9 @@ public:
   inline void setGroupExpr(ValueIdSet &expr) { groupExpr_ = expr;}
   inline void addGroupExpr(ValueIdSet &expr) { groupExpr_ += expr;}
 
-  inline ValueIdList & extraOrderExpr() { return extraOrderExpr_; }
+  inline void setExtraOrderExpr(const ValueIdList &newExtraOrder) { extraOrderExpr_ =
newExtraOrder; }
   inline const ValueIdList & extraOrderExpr() const { return extraOrderExpr_; }
+  void normalizeExtraOrderExpr( NormWA & normWARef  ) { extraOrderExpr_.normalizeNode(normWARef);
}
   
   ValueIdList & rollupGroupExprList() { return rollupGroupExprList_; }
   const ValueIdList & rollupGroupExprList() const { return rollupGroupExprList_; }


Mime
View raw message