

def _truncate(translator, expr):
    op = expr.op()
    arg = translator.translate(op.args[0])
    _impala_unit_names = {
        'M': 'MONTH',
        'D': 'J',
        'J': 'D',
        'H': 'HH',
    }
    unit = op.args[1]
    unit = _impala_unit_names.get(unit, unit)
    return "trunc({0!s}, '{1!s}')".format(arg, unit)

dataset/ETHPy150Open cloudera/ibis/ibis/impala/compiler.py _truncate/original