[ 
https://issues.apache.org/jira/browse/TRAFODION-2130?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15399410#comment-15399410
 ] 

ASF GitHub Bot commented on TRAFODION-2130:
-------------------------------------------

Github user selvaganesang commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/624#discussion_r72800580
  
    --- 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 --
    
    Interesting.  Just curious what did the C++ compiler do earlier?


> Incorrect subquery transformation for tables w/o key
> ----------------------------------------------------
>
>                 Key: TRAFODION-2130
>                 URL: https://issues.apache.org/jira/browse/TRAFODION-2130
>             Project: Apache Trafodion
>          Issue Type: Bug
>          Components: sql-cmp
>    Affects Versions: 1.2-incubating
>            Reporter: Hans Zeller
>            Assignee: Hans Zeller
>
> Some of the subquery unnesting transformations rely on a unique key on the 
> result of the main query. It turns out, however, that the transformation 
> happens even if there is no unique key. Example:
> select *
> from (values (1,1), (1,1), (2,2)) T(a,b)
> where t.a in (select max(a)
>               from (values (1,1), (1,1), (3,3)) S(a,b)
>               where S.b = T.b);
> This should return two rows, but it actually just returns one, because it 
> does not include a unique key for the main query, T.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to