

def _format_table(self, expr):
    ctx = self.context
    ref_expr = expr
    op = ref_op = expr.op()
    if isinstance(op, ops.SelfReference):
        ref_expr = op.table
        ref_op = ref_expr.op()
    if isinstance(ref_op, ops.PhysicalTable):
        name = ref_op.name
        if (name is None):
            raise com.RelationError('Table did not have a name: {0!r}'.format(expr))
        result = quote_identifier(name)
        is_subquery = False
    else:
        if ctx.is_extracted(ref_expr):
            alias = ctx.get_ref(expr)
            if isinstance(op, ops.SelfReference):
                return '{0} {1}'.format(ctx.get_ref(ref_expr), alias)
            else:
                return alias
        subquery = ctx.get_compiled_expr(expr)
        result = '(\n{0}\n)'.format(util.indent(subquery, self.indent))
        is_subquery = True
    if (is_subquery or ctx.need_aliases()):
        result += ' {0}'.format(ctx.get_ref(expr))
    return result

dataset/ETHPy150Open cloudera/ibis/ibis/impala/compiler.py _TableSetFormatter._format_table/original