Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CT-3141] [Regression] 'BaseResult' object has no attribute 'node' #8689

Closed
2 tasks done
katarinagacnik opened this issue Sep 22, 2023 · 3 comments
Closed
2 tasks done
Labels
bug Something isn't working

Comments

@katarinagacnik
Copy link

Is this a regression in a recent version of dbt-core?

  • I believe this is a regression in dbt-core functionality
  • I have searched the existing issues, and I could not find an existing issue for this regression

Current Behavior

Hi,

I recently upgraded to dbt core 1.5.3 and dbt snowflake 1.5.2 and I started receiving a python error using exceptions.raise_compile_error in a on-run-start hook macro. Everything was working fine before the upgrade (using 1.3.1 version).

I found another issue #6796 written on this topic in January this year and at that time it was said that the bug will be fixed with the new 1.4.x version. However the same bug is still present in the newer versions of dbt.

Expected/Previous Behavior

This setup worked before. If a single row was returned by the query, an error would be raised and dbt run would not start at all.

Steps To Reproduce

In macros folder, create an export_table_check.sql file with the following content (change table name and column name based on your own table in sf).

{% macro export_table_check() %}

{% set table = '12_exported_records' %}

{% set query %}
    SELECT column_name
    FROM {{ref(table)}}
    LIMIT 1
{% endset %}

{%- if flags.WHICH in ('run', 'build') -%}
    {% set results = run_query(query) %}
    {% if execute %}
        {%- if results.rows -%}
            {{ exceptions.raise_compiler_error("ON_RUN_START_CHECK_NOT_PASSED: Data already exported. DBT Run aborted.") }}
        {% else -%}
            {{ log("No data found in " ~ table ~ " for current day and runtime region. Proceeding...", true) }}
        {%- endif -%}
    {%- endif -%}
{%- endif -%}
{% endmacro %}

In dbt_project:

on-run-start: 
    - "{{ export_table_check() }}"

Relevant log output

07:32:46  Finished running 60 incremental models, 30 view models, 2 hooks in 0 hours 1 minutes and 15.57 seconds (75.57s).
07:32:47  
07:32:47  Completed with 2 errors and 0 warnings:
07:32:47
07:32:47  on-run-start failed, error:
07:32:47   Previous run did not finish successfully. Abort the process.
07:32:47
07:32:47  on-run-end failed, error:
07:32:47   'dbt.contracts.results.BaseResult object' has no attribute 'node'
07:32:47
07:32:47  Done. PASS=90 WARN=0 ERROR=2 SKIP=0 TOTAL=92

Environment

- Python: 3.10.5
- dbt (working version): 1.3.1
- dbt (regression version): 1.5.3

Which database adapter are you using with dbt?

snowflake

Additional Context

No response

@katarinagacnik katarinagacnik added bug Something isn't working regression triage labels Sep 22, 2023
@github-actions github-actions bot changed the title [Regression] 'BaseResult' object has no attribute 'node' [CT-3141] [Regression] 'BaseResult' object has no attribute 'node' Sep 22, 2023
@jtcohen6
Copy link
Contributor

@katarinagacnik Thanks for opening!

From the information you've provided, it looks like two things are going on.

Since upgrading, the error being raised in the on-run-start hook is no longer preventing subsequent models from running. This is a known behavior change, although I ended up calling it an enhancement rather than a regression because it had never been officially documented or guaranteed behavior: #7045#7387

The actual error you're seeing ('BaseResult' object has no attribute 'node') is in the on-run-end hook. I'm not sure what's being called in that hook - could you share that as well, so we can figure out what the issue there is?

Otherwise, I'm inclined to close this as a duplicate of the issues I linked above. I agree that we should try to restore this behavior, to enable this sort of "pre-flight" check via an on-run-start hook.

@katarinagacnik
Copy link
Author

Hi @jtcohen6,

thank you for responsing to my issue!

Maybe my output is not very descriptive - sorry about that. But by your answer I see you got the problem I am dealing with.

Macro in the prehook was doing some process validation (checking if the previous run is still running or if it ended with an error) and in a case of a problem immediately stopped the run therefore making sure that concurrent runs (even from different users) were not possible.
It was used in a simillar way as throw/raise error or exit() does in some other programming languages.

Now since this behavior changed, we lost the ability to forcefully end the run.
Do you have any alternative solutions for this? How could we force exit() dbt run automatically when certain conditions are met?

Thanks in advance!

@dbeatty10
Copy link
Contributor

@katarinagacnik thanks for that info!

Based on that, I'm going to close this as a duplicate of #7387, and I copied your last two questions over to the comment threads there.

Just let me know if you think this issue is unique from #7387 and we can consider re-opening this.

@dbeatty10 dbeatty10 closed this as not planned Won't fix, can't repro, duplicate, stale Oct 5, 2023
@dbeatty10 dbeatty10 removed the triage label Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants