Repository: trafodion
Updated Branches:
  refs/heads/master a5b67c9e9 -> 330235a0b


[TRAFODION-3066] Fix bug that causes 2053 warning on deeply nested subqueries


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

Branch: refs/heads/master
Commit: 3d54d5ac8ab797335e32bd6bbefff4150452bd15
Parents: 008f4af
Author: Dave Birdsall <[email protected]>
Authored: Wed May 9 23:15:17 2018 +0000
Committer: Dave Birdsall <[email protected]>
Committed: Wed May 9 23:15:17 2018 +0000

----------------------------------------------------------------------
 core/sql/optimizer/GroupAttr.h     | 15 ++++++++++++++-
 core/sql/optimizer/NormRelExpr.cpp |  2 ++
 2 files changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafodion/blob/3d54d5ac/core/sql/optimizer/GroupAttr.h
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/GroupAttr.h b/core/sql/optimizer/GroupAttr.h
index 5878417..854ba0c 100644
--- a/core/sql/optimizer/GroupAttr.h
+++ b/core/sql/optimizer/GroupAttr.h
@@ -812,9 +812,22 @@ private:
 
   // values used to avoid bushy join trees
   Int32          numBaseTables_;    // # of base tables involved in this 
subtree
-  Int32          numJoinedTables_;  // # of tables in join backbone
+  Int32          numJoinedTables_;  // # of tables in join backbone (see note 
below)
   Int32          numTMUDFs_;        // # of table-mapping UDFs in this subtree
 
+  // Note: For numJoinedTables_, we calculate this when we create the
+  // GroupAttributes for an expression for the first time. For most nodes
+  // this will be 1; for a Join node it will be more than 1 in general.
+  // Later, when we form Groups for a given expression, this initial value
+  // applies to the Group. Optimization will in general add more expressions
+  // to a given group. For example, a Group originally associated with a
+  // GroupByAgg node might get a Join expression if the GroupByOnJoinRule
+  // chooses to push a Group By below a Join. When this happens, though,
+  // we leave numJoinedTables_ as 1 in the GroupAttributes (see
+  // Join::synthLogProp), which will inhibit the LeftShiftJoinRule from
+  // firing on that Join. This is important, because we want the large
+  // scope rules to control what join orders are enumerated.
+
   // QSTUFF VV
   // --------------------------------------------------------------------
   // attribute to determine whether RelExpr is a select with an embedded

http://git-wip-us.apache.org/repos/asf/trafodion/blob/3d54d5ac/core/sql/optimizer/NormRelExpr.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/NormRelExpr.cpp 
b/core/sql/optimizer/NormRelExpr.cpp
index 6d1ef4c..974c055 100644
--- a/core/sql/optimizer/NormRelExpr.cpp
+++ b/core/sql/optimizer/NormRelExpr.cpp
@@ -2888,6 +2888,8 @@ RelExpr* Join::transformSemiJoin(NormWA& normWARef)
                                child(1)->castToRelExpr()) ;
        newGrby->setGroupAttr(new (stmtHeap) 
          GroupAttributes(*(child(1)->getGroupAttr())));
+       // must reset numJoinedTables_; we might be copying GroupAttributes 
from a join
+       newGrby->getGroupAttr()->resetNumJoinedTables(1);
        newGrby->getGroupAttr()->clearLogProperties();
          
        newGrby->setGroupExpr(equiJoinCols1);

Reply via email to