'None' has no attribute 'table'

I’m trying to create a macro to do some checks before performing a calculation with the field. but when checking the return of the qury I can’t, it gives an error.
How can I do this?
Follows my macro in a generic way

{% macro fn_verifica_id(id, ds_campo_pesquisar) %}

        {% set query %}
            select
                1 as resultado
        {% endset %}

        {% set resultado = run_query(query) %}

        {% if resultado == 1 %}
            ({{id}} + 1000 * (-1))
        {% else %}
            ({{id}})
        {% endif %}

{% endmacro %}