

def format_postamble(self):
    buf = StringIO()
    lines = 0
    if (len(self.order_by) > 0):
        buf.write('ORDER BY ')
        formatted = []
        for expr in self.order_by:
            key = expr.op()
            translated = self._translate(key.expr)
            if (not key.ascending):
                translated += ' DESC'
            formatted.append(translated)
        buf.write(', '.join(formatted))
        lines += 1
    if (self.limit is not None):
        if lines:
            buf.write('\n')
        (n, offset) = (self.limit['n'], self.limit['offset'])
        buf.write('LIMIT {0}'.format(n))
        if ((offset is not None) and (offset != 0)):
            buf.write(' OFFSET {0}'.format(offset))
        lines += 1
    if (not lines):
        return None
    return buf.getvalue()

dataset/ETHPy150Open cloudera/ibis/ibis/impala/compiler.py ImpalaSelect.format_postamble/original