Package org.apache.calcite.adapter.pig
Class PigAggregate
- java.lang.Object
-
- org.apache.calcite.rel.AbstractRelNode
-
- org.apache.calcite.rel.SingleRel
-
- org.apache.calcite.rel.core.Aggregate
-
- org.apache.calcite.adapter.pig.PigAggregate
-
- All Implemented Interfaces:
java.lang.Cloneable
,PigRel
,RelOptNode
,RelNode
public class PigAggregate extends Aggregate implements PigRel
Implementation ofAggregate
inPig calling convention
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.calcite.rel.core.Aggregate
Aggregate.AggCallBinding, Aggregate.Group
-
Nested classes/interfaces inherited from interface org.apache.calcite.adapter.pig.PigRel
PigRel.Implementor
-
Nested classes/interfaces inherited from interface org.apache.calcite.rel.RelNode
RelNode.Context
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DISTINCT_FIELD_SUFFIX
-
Fields inherited from class org.apache.calcite.rel.core.Aggregate
aggCalls, groupSet, groupSets, indicator, IS_NOT_GRAND_TOTAL, IS_SIMPLE, NO_INDICATOR
-
Fields inherited from class org.apache.calcite.rel.AbstractRelNode
digest, id, rowType, traitSet
-
Fields inherited from interface org.apache.calcite.adapter.pig.PigRel
CONVENTION
-
-
Constructor Summary
Constructors Constructor Description PigAggregate(RelOptCluster cluster, RelTraitSet traits, RelNode child, boolean indicator, ImmutableBitSet groupSet, java.util.List<ImmutableBitSet> groupSets, java.util.List<AggregateCall> aggCalls)
Creates a PigAggregate.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Aggregate
copy(RelTraitSet traitSet, RelNode input, boolean indicator, ImmutableBitSet groupSet, java.util.List<ImmutableBitSet> groupSets, java.util.List<AggregateCall> aggCalls)
Creates a copy of this aggregate.private java.util.List<java.lang.String>
getArgNames(java.lang.String relAlias, AggregateCall aggCall)
private java.util.List<java.lang.String>
getDistinctCalls(PigRel.Implementor implementor)
A agg function call likeCOUNT(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;
}private java.lang.String
getInputFieldName(int fieldIndex)
private java.lang.String
getInputFieldNameForAggCall(java.lang.String relAlias, AggregateCall aggCall, int fieldIndex)
private java.lang.String
getPigAggregateCall(java.lang.String relAlias, AggregateCall aggCall)
private java.util.List<java.lang.String>
getPigAggregateCalls(PigRel.Implementor implementor)
private java.lang.String
getPigAggregateStatement(PigRel.Implementor implementor)
Generates a GROUP BY statement, followed by an optional FOREACH statement for all aggregate functions used.private java.lang.String
getPigForEachGenerate(PigRel.Implementor implementor)
Generates a FOREACH statement containing invocation of aggregate functions and projection of grouped fields.private java.lang.String
getPigGenerateCall(PigRel.Implementor implementor)
private java.lang.String
getPigGroupBy(PigRel.Implementor implementor)
Generates the GROUP BY statement, e.g.RelOptTable
getTable()
Override this method so it looks down the tree to find the table this node is acting on.void
implement(PigRel.Implementor implementor)
Converts this node to a Pig Latin statement.private PigAggFunction
toPigAggFunc(AggregateCall aggCall)
-
Methods inherited from class org.apache.calcite.rel.core.Aggregate
computeSelfCost, containsDistinctCall, copy, deriveRowType, deriveRowType, estimateRowCount, explainTerms, getAggCallList, getGroupCount, getGroupSet, getGroupSets, getGroupType, getIndicatorCount, getNamedAggCalls, isNotGrandTotal, isSimple, isValid, noIndicator
-
Methods inherited from class org.apache.calcite.rel.SingleRel
childrenAccept, getInput, getInputs, replaceInput
-
Methods inherited from class org.apache.calcite.rel.AbstractRelNode
accept, accept, collectVariablesSet, collectVariablesUsed, computeDigest, computeSelfCost, explain, getChildExps, getCluster, getCollationList, getConvention, getCorrelVariable, getDescription, getDigest, getExpectedInputRowType, getId, getInput, getQuery, getRelTypeName, getRows, getRowType, getTraitSet, getVariablesSet, getVariablesStopped, isDistinct, isKey, isValid, metadata, onRegister, recomputeDigest, register, sole, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.calcite.rel.RelNode
accept, accept, childrenAccept, collectVariablesSet, collectVariablesUsed, computeSelfCost, computeSelfCost, copy, estimateRowCount, explain, getChildExps, getCollationList, getConvention, getCorrelVariable, getExpectedInputRowType, getInput, getInputs, getQuery, getRelTypeName, getRows, getRowType, getVariablesSet, getVariablesStopped, isDistinct, isKey, isValid, isValid, metadata, onRegister, recomputeDigest, register, replaceInput
-
Methods inherited from interface org.apache.calcite.plan.RelOptNode
getCluster, getDescription, getDigest, getId, getTraitSet
-
-
-
-
Field Detail
-
DISTINCT_FIELD_SUFFIX
public static final java.lang.String DISTINCT_FIELD_SUFFIX
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PigAggregate
public PigAggregate(RelOptCluster cluster, RelTraitSet traits, RelNode child, boolean indicator, ImmutableBitSet groupSet, java.util.List<ImmutableBitSet> groupSets, java.util.List<AggregateCall> aggCalls)
Creates a PigAggregate.
-
-
Method Detail
-
copy
public Aggregate copy(RelTraitSet traitSet, RelNode input, boolean indicator, ImmutableBitSet groupSet, java.util.List<ImmutableBitSet> groupSets, java.util.List<AggregateCall> aggCalls)
Description copied from class:Aggregate
Creates a copy of this aggregate.- Specified by:
copy
in classAggregate
- Parameters:
traitSet
- Traitsinput
- Inputindicator
- Whether row type should include indicator fields to indicate which grouping set is active; must be true if aggregate is not simplegroupSet
- Bit set of grouping fieldsgroupSets
- List of all grouping sets; null for justgroupSet
aggCalls
- Collection of calls to aggregate functions- Returns:
- New
Aggregate
if any parameter differs from the value of thisAggregate
, or justthis
if all the parameters are the same - See Also:
Aggregate.copy(org.apache.calcite.plan.RelTraitSet, java.util.List)
-
implement
public void implement(PigRel.Implementor implementor)
Description copied from interface:PigRel
Converts this node to a Pig Latin statement.
-
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 interfaceRelNode
- Overrides:
getTable
in classAbstractRelNode
- 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)
-
toPigAggFunc
private PigAggFunction toPigAggFunc(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 likeCOUNT(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)
-
-