

def format_select_set(self):
    context = self.context
    formatted = []
    for expr in self.select_set:
        if isinstance(expr, ir.ValueExpr):
            expr_str = self._translate(expr, named=True)
        elif isinstance(expr, ir.TableExpr):
            if context.need_aliases():
                alias = context.get_ref(expr)
                expr_str = ('{0}.*'.format(alias) if alias else '*')
            else:
                expr_str = '*'
        formatted.append(expr_str)
    buf = StringIO()
    line_length = 0
    max_length = 70
    tokens = 0
    for (i, val) in enumerate(formatted):
        if val.count('\n'):
            if i:
                buf.write(',')
            buf.write('\n')
            indented = util.indent(val, self.indent)
            buf.write(indented)
            line_length = len(indented.split('\n')[(- 1)])
            tokens = 1
        elif ((tokens > 0) and line_length and ((len(val) + line_length) > max_length)):
            (buf.write(',\n       ') if i else buf.write('\n'))
            buf.write(val)
            line_length = (len(val) + 7)
            tokens = 1
        else:
            if i:
                buf.write(',')
            buf.write(' ')
            buf.write(val)
            tokens += 1
            line_length += (len(val) + 2)
    if tokens.distinct:
        select_key = 'SELECT DISTINCT'
    else:
        select_key = 'SELECT'
    return '{0}{1}'.format(select_key, buf.getvalue())

dataset/ETHPy150Open cloudera/ibis/ibis/impala/compiler.py ImpalaSelect.format_select_set/VarMisuse@341/406 `self`->`tokens`