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

    
https://github.com/apache/incubator-trafodion/pull/1250#discussion_r142300367
  
    --- Diff: core/sql/optimizer/RelExpr.cpp ---
    @@ -1078,7 +1078,33 @@ void RelExpr::pushDownGenericUpdateRootOutputs( 
const ValueIdSet &outputs)
     //QSTUFF
     
     void RelExpr::needSortedNRows(NABoolean val)
    -{
    +{ 
    +  // The operators listed below can create OR propogate a GET_N
    +  // request. Other operatots will turn a GET_N request into GET_ALL
    +  // There are a few exceptions like right side of NJ for semi join etc.
    +  // but these are not relevant for FirstN sort
    +  // This method should only in the generator since we are using 
    +  // physical node types.
    +  OperatorTypeEnum operatorType = getOperatorType();
    +  if ((operatorType != REL_FIRST_N) &&
    +      (operatorType != REL_EXCHANGE) &&
    +      (operatorType != REL_MERGE_UNION) &&
    +      (operatorType != REL_PROBE_CACHE) &&
    +      (operatorType != REL_ROOT) && 
    +      (operatorType != REL_LEFT_NESTED_JOIN) &&
    +      (operatorType != REL_LEFT_TSJ) &&
    +      (operatorType != REL_MAP_VALUEIDS))
    +    return ;
    +      
    --- End diff --
    
    Thank you for the review. I think there are more operators that change 
GET_N to GET_ALL, than those that preserve a GET_N. I like to think of it as 
most operators may need more than N rows to produce N rows (say a join or a 
groupby). There are fewer that can guarantee N rows, every time they receive N 
rows.


---

Reply via email to