Github user sureshsubbiah commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/624#discussion_r72823287
--- Diff: core/sql/optimizer/NormRelExpr.cpp ---
@@ -3044,14 +3044,23 @@ Join::pullUpGroupByTransformation()
// a copy of join as the child. The original tree has not
changed.
// The predicates in the new groupBy and the new Join will have
// changed according to the comments above.
+//
------------------------------------------------------------------------------*/
GroupByAgg* Join::pullUpGroupByTransformation(NormWA& normWARef)
{
CollHeap *stmtHeap = CmpCommon::statementHeap() ;
- // Determine a set of unique columns for the left sub-tree
+ // Determine a set of unique columns for the left sub-tree.
+
+ // Note: Scans and joins synthesize uniqueness constraints even for
+ // columns that are not in the characteristic outputs. Other
+ // operators such as groupby or union don't. We make use of these
+ // extra uniqeness constraints here. Any needed columns not yet
+ // added to the characteristic outputs will be added later, in
+ // method getMoreOutputsIfPossible().
+
ValueIdSet leftUniqueCols ;
- if (NOT (child(0)-getGroupAttr()->findUniqueCols(leftUniqueCols)))
+ if (NOT (child(0)->getGroupAttr()->findUniqueCols(leftUniqueCols)))
--- End diff --
Good catch Hans. Amazing that this has remained undetected for about 9
years!
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---