protected AbstractPlanNode checkLimitPushDownViability ( AbstractPlanNode root ) { AbstractPlanNode receiveNode = root ; List < ParsedColInfo > orderBys = m_parsedSelect . orderByColumns ( ) ; boolean orderByCoversAllGroupBy = m_parsedSelect . groupByIsAnOrderByPermutation ( ) ; while ( ! ( receiveNode instanceof ReceivePlanNode ) ) { // Limitation: can only push past some nodes (see above comment) // Delete the aggregate node case to handle ENG-6485, // or say we don't push down meeting aggregate node // TODO: We might want to optimize/push down "limit" for some cases if ( ! ( receiveNode instanceof OrderByPlanNode ) && ! ( receiveNode instanceof ProjectionPlanNode ) && ! isValidAggregateNodeForLimitPushdown ( receiveNode , orderBys , orderByCoversAllGroupBy ) ) { return null ; } if ( receiveNode instanceof OrderByPlanNode ) { // if grouping by the partition key, // limit can still push down if ordered by aggregate values. if ( ! m_parsedSelect . hasPartitionColumnInGroupby ( ) && isOrderByAggregationValue ( m_parsedSelect . orderByColumns ( ) ) ) { return null ; } } // Traverse... if ( receiveNode . getChildCount ( ) == 0 ) { return null ; } // nothing that allows pushing past has multiple inputs assert ( receiveNode . getChildCount ( ) == 1 ) ; receiveNode = receiveNode . getChild ( 0 ) ; } return receiveNode . getChild ( 0 ) ; }
Check if we can push the limit node down .