Class PigAggregate

    • Field Detail

      • DISTINCT_FIELD_SUFFIX

        public static final java.lang.String DISTINCT_FIELD_SUFFIX
        See Also:
        Constant Field Values
    • Method Detail

      • implement

        public void implement​(PigRel.Implementor implementor)
        Description copied from interface: PigRel
        Converts this node to a Pig Latin statement.
        Specified by:
        implement in interface PigRel
      • getPigAggregateStatement

        private java.lang.String getPigAggregateStatement​(PigRel.Implementor implementor)
        Generates a GROUP BY statement, followed by an optional FOREACH statement for all aggregate functions used. e.g.
         
         A = GROUP A BY owner;
         A = FOREACH A GENERATE group, SUM(A.pet_num);
         
         
      • getTable

        public RelOptTable getTable()
        Override this method so it looks down the tree to find the table this node is acting on.
        Specified by:
        getTable in interface RelNode
        Overrides:
        getTable in class AbstractRelNode
        Returns:
        If this relational expression represents an access to a table, returns that table, otherwise returns null
      • getPigGroupBy

        private java.lang.String getPigGroupBy​(PigRel.Implementor implementor)
        Generates the GROUP BY statement, e.g. A = GROUP A BY (f1, f2);
      • getPigForEachGenerate

        private java.lang.String getPigForEachGenerate​(PigRel.Implementor implementor)
        Generates a FOREACH statement containing invocation of aggregate functions and projection of grouped fields. e.g. A = FOREACH A GENERATE group, SUM(A.pet_num);
        See Also:
        documentation for special meaning of the "group" field after GROUP BY.
      • getPigGenerateCall

        private java.lang.String getPigGenerateCall​(PigRel.Implementor implementor)
      • getPigAggregateCalls

        private java.util.List<java.lang.String> getPigAggregateCalls​(PigRel.Implementor implementor)
      • getPigAggregateCall

        private java.lang.String getPigAggregateCall​(java.lang.String relAlias,
                                                     AggregateCall aggCall)
      • getArgNames

        private java.util.List<java.lang.String> getArgNames​(java.lang.String relAlias,
                                                             AggregateCall aggCall)
      • getInputFieldNameForAggCall

        private java.lang.String getInputFieldNameForAggCall​(java.lang.String relAlias,
                                                             AggregateCall aggCall,
                                                             int fieldIndex)
      • getDistinctCalls

        private java.util.List<java.lang.String> getDistinctCalls​(PigRel.Implementor implementor)
        A agg function call like COUNT(DISTINCT COL) in Pig is achieved via two statements in a FOREACH that follows a GROUP statement:
        TABLE = GROUP TABLE ALL;
        TABLE = FOREACH TABLE {
          COL.DISTINCT = DISTINCT COL;
          GENERATE COUNT(COL.DISTINCT) AS C;

        }
      • getInputFieldName

        private java.lang.String getInputFieldName​(int fieldIndex)