def convert_value(value, tpe):
    """
    Cast to specified type
    :param value: value to cast
    :param tpe: name of the type as returned by bq
    :return: casted value or the input value if it is falsey
    """
    if value:
        if tpe == 'INTEGER':
            return int(value)
        if tpe == 'FLOAT':
            return float(value)
    return value