Class Aggregate

    • Field Detail

      • IS_SIMPLE

        @Deprecated
        public static final com.google.common.base.Predicate<Aggregate> IS_SIMPLE
        Deprecated.
      • NO_INDICATOR

        @Deprecated
        public static final com.google.common.base.Predicate<Aggregate> NO_INDICATOR
        Deprecated.
      • IS_NOT_GRAND_TOTAL

        @Deprecated
        public static final com.google.common.base.Predicate<Aggregate> IS_NOT_GRAND_TOTAL
        Deprecated.
      • aggCalls

        protected final java.util.List<AggregateCall> aggCalls
      • groupSets

        public final com.google.common.collect.ImmutableList<ImmutableBitSet> groupSets
    • Constructor Detail

      • Aggregate

        protected Aggregate​(RelOptCluster cluster,
                            RelTraitSet traitSet,
                            RelNode input,
                            ImmutableBitSet groupSet,
                            java.util.List<ImmutableBitSet> groupSets,
                            java.util.List<AggregateCall> aggCalls)
        Creates an Aggregate.

        All members of groupSets must be sub-sets of groupSet. For a simple GROUP BY, groupSets is a singleton list containing groupSet.

        If GROUP BY is not specified, or equivalently if GROUP BY () is specified, groupSet will be the empty set, and groupSets will have one element, that empty set.

        If CUBE, ROLLUP or GROUPING SETS are specified, groupSets will have additional elements, but they must each be a subset of groupSet, and they must be sorted by inclusion: (0, 1, 2), (1), (0, 2), (0), ().

        Parameters:
        cluster - Cluster
        traitSet - Trait set
        input - Input relational expression
        groupSet - Bit set of grouping fields
        groupSets - List of all grouping sets; null for just groupSet
        aggCalls - Collection of calls to aggregate functions
      • Aggregate

        protected Aggregate​(RelInput input)
        Creates an Aggregate by parsing serialized output.
    • Method Detail

      • isSimple

        public static boolean isSimple​(Aggregate aggregate)
      • checkIndicator

        public static void checkIndicator​(boolean indicator)
        Used internally; will removed when indicator is removed, before 2.0.
      • isNotGrandTotal

        public static boolean isNotGrandTotal​(Aggregate aggregate)
      • noIndicator

        @Deprecated
        public static boolean noIndicator​(Aggregate aggregate)
        Deprecated.
      • isPredicate

        private boolean isPredicate​(RelNode input,
                                    int index)
      • copy

        public final RelNode copy​(RelTraitSet traitSet,
                                  java.util.List<RelNode> inputs)
        Description copied from interface: RelNode
        Creates a copy of this relational expression, perhaps changing traits and inputs.

        Sub-classes with other important attributes are encouraged to create variants of this method with more parameters.

        Specified by:
        copy in interface RelNode
        Overrides:
        copy in class AbstractRelNode
        Parameters:
        traitSet - Trait set
        inputs - Inputs
        Returns:
        Copy of this relational expression, substituting traits and inputs
      • getAggCallList

        public java.util.List<AggregateCall> getAggCallList()
        Returns a list of calls to aggregate functions.
        Returns:
        list of calls to aggregate functions
      • getNamedAggCalls

        public java.util.List<Pair<AggregateCall,​java.lang.String>> getNamedAggCalls()
        Returns a list of calls to aggregate functions together with their output field names.
        Returns:
        list of calls to aggregate functions and their output field names
      • getGroupCount

        public int getGroupCount()
        Returns the number of grouping fields. These grouping fields are the leading fields in both the input and output records.

        NOTE: The getGroupSet() data structure allows for the grouping fields to not be on the leading edge. New code should, if possible, assume that grouping fields are in arbitrary positions in the input relational expression.

        Returns:
        number of grouping fields
      • getIndicatorCount

        @Deprecated
        public int getIndicatorCount()
        Deprecated.
        Returns the number of indicator fields.

        Always zero.

        Returns:
        number of indicator fields, always zero
      • getGroupSet

        public ImmutableBitSet getGroupSet()
        Returns a bit set of the grouping fields.
        Returns:
        bit set of ordinals of grouping fields
      • getGroupSets

        public com.google.common.collect.ImmutableList<ImmutableBitSet> getGroupSets()
        Returns the list of grouping sets computed by this Aggregate.
        Returns:
        List of all grouping sets; null for just groupSet
      • deriveRowType

        public static RelDataType deriveRowType​(RelDataTypeFactory typeFactory,
                                                RelDataType inputRowType,
                                                boolean indicator,
                                                ImmutableBitSet groupSet,
                                                java.util.List<ImmutableBitSet> groupSets,
                                                java.util.List<AggregateCall> aggCalls)
        Computes the row type of an Aggregate before it exists.
        Parameters:
        typeFactory - Type factory
        inputRowType - Input row type
        indicator - Deprecated, always false
        groupSet - Bit set of grouping fields
        groupSets - List of all grouping sets; null for just groupSet
        aggCalls - Collection of calls to aggregate functions
        Returns:
        Row type of the aggregate
      • allContain

        private static boolean allContain​(java.util.List<ImmutableBitSet> groupSets,
                                          int groupKey)
      • isValid

        public boolean isValid​(Litmus litmus,
                               RelNode.Context context)
        Description copied from interface: RelNode
        Returns whether this relational expression is valid.

        If assertions are enabled, this method is typically called with litmus = THROW, as follows:

        assert rel.isValid(Litmus.THROW)

        This signals that the method can throw an AssertionError if it is not valid.

        Specified by:
        isValid in interface RelNode
        Overrides:
        isValid in class AbstractRelNode
        Parameters:
        litmus - What to do if invalid
        context - Context for validity checking
        Returns:
        Whether relational expression is valid
      • typeMatchesInferred

        private boolean typeMatchesInferred​(AggregateCall aggCall,
                                            Litmus litmus)
        Returns whether the inferred type of an AggregateCall matches the type it was given when it was created.
        Parameters:
        aggCall - Aggregate call
        litmus - What to do if an error is detected (types do not match)
        Returns:
        Whether the inferred and declared types match
      • containsDistinctCall

        public boolean containsDistinctCall()
        Returns whether any of the aggregates are DISTINCT.
        Returns:
        Whether any of the aggregates are DISTINCT
      • getGroupType

        public Aggregate.Group getGroupType()
        Returns the type of roll-up.
        Returns:
        Type of roll-up