code: def as_cql_query(self, formatted=False):
          
          sep = '\n    ' if formatted else ' '
          keyspace = protect_name(self.keyspace)
          name = protect_name(self.name)
          type_list = ', '.join(self.argument_types)
          state_func = protect_name(self.state_func)
          state_type = self.state_type
  
          ret = "CREATE AGGREGATE %(keyspace)s.%(name)s(%(type_list)s)%(sep)s" \
                "SFUNC %(state_func)s%(sep)s" \
                "STYPE %(state_type)s" % locals()
  
          ret += ''.join((sep, 'FINALFUNC ', protect_name(self.final_func))) if self.final_func else ''
          ret += ''.join((sep, 'INITCOND ', self.initial_condition)) if self.initial_condition is not None else ''
  
          return ret
docs: Returns a CQL query that can be used to recreate this aggregate.
          If `formatted` is set to :const:`True`, extra whitespace will
          be added to make the query more readable.