'Instantiate an SQL aggregate
* col is a column reference describing the subject field
of the aggregate. It can be an alias, or a tuple describing
a table and column name.
* source is the underlying field or aggregate definition for
the column reference. If the aggregate is not an ordinal or
computed type, this reference is used to determine the coerced
output type of the aggregate.
* extra is a dictionary of additional data to provide for the
aggregate definition
Also utilizes the class variables:
* sql_function, the name of the SQL function that implements the
aggregate.
* sql_template, a template string that is used to render the
aggregate into SQL.
* is_ordinal, a boolean indicating if the output of this aggregate
is an integer (e.g., a count)
* is_computed, a boolean indicating if this output of this aggregate
is a computed float (e.g., an average), regardless of the input
type.'

def __init__(self, col, source=None, is_summary=False, **extra):

    self.col = col
    self.source = source
    self.is_summary = is_summary
    self.extra = extra
    tmp = self
    while (tmp and isinstance(tmp, Aggregate)):
        if getattr(tmp, 'is_ordinal', False):
            tmp = ordinal_aggregate_field
        elif getattr(tmp, 'is_computed', False):
            tmp = computed_aggregate_field
        else:
            tmp = tmp.source
    self.field = tmp
