'Returns a CQL query that can be used to recreate this type.
If `formatted` is set to :const:`True`, extra whitespace will
be added to make the query more readable.'

def as_cql_query(self, formatted=False):

    ret = ('CREATE    TYPE    %s.%s    (%s' % (protect_name(self.keyspace), protect_name(self.name), ('\n' if formatted else '')))
    if formatted:
        field_join = ',\n'
        padding = '                '
    else:
        field_join = ',    '
        padding = ''
    fields = []
    for (field_name, field_type) in zip(self.field_names, self.field_types):
        fields.append(('%s    %s' % (protect_name(field_name), field_type)))
    ret += field_join.join((('%s%s' % (padding, field)) for field in fields))
    ret += ('\n)' if formatted else ')')
    return ret
