@toolz.memoize
def alias_it(s):
 if (hasattr(s, '_group_by_clause') and (s._group_by_clause is not None) and len(s._group_by_clause)):
  return s.alias(next(aliases))
 else:
  return s

@ toolz . memoize def alias_it ( s ) : if ( hasattr ( s , '_group_by_clause' ) and ( s . _group_by_clause is not None ) and len ( s . _group_by_clause ) ) : return s . alias ( next ( aliases ) ) else : return s
alias a selectable if it has a group by clause .