Skip to content

[Bug] temporary table not dropped when error is raised #169

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

Open
1 task done
fabrcav opened this issue Mar 21, 2025 · 2 comments
Open
1 task done

[Bug] temporary table not dropped when error is raised #169

fabrcav opened this issue Mar 21, 2025 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@fabrcav
Copy link

fabrcav commented Mar 21, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

if an error occurs during an incremental model execution the temporary table O$PT_ is not dropped

Expected Behavior

if an error occurs all temporary tables are dropped.

Steps To Reproduce

  1. create model materialized='incremental'
  2. put an inconsistency in the model

Relevant log output using --debug flag enabled

...
Database Error in model target_table (models/target_table.sql)
  ORA-01400: cannot insert NULL into ("ADMIN"."TARGET_TABLE"."C2")
  Help: https://docs.oracle.com/error-help/db/ora-01400/
  compiled code at target/run/dbt_error_example/models/target_table.sql
15:41:53  Sending event: {'category': 'dbt', 'action': 'run_model', 'label': '89902985-b71a-4396-9275-cf076bfb142f', 'context': [<snowplow_tracker.self_describing_json.SelfDescribingJson object at 0x7126987acc10>]}
15:41:53  1 of 1 ERROR creating sql incremental model admin.target_table ................. [ERROR in 0.46s]
15:41:53  Finished running node model.dbt_error_example.target_table
15:41:53  Marking all children of 'model.dbt_error_example.target_table' to be skipped because of status 'error'.  Reason: Database Error in model target_table (models/target_table.sql)
  ORA-01400: cannot insert NULL into ("ADMIN"."TARGET_TABLE"."C2")
  Help: https://docs.oracle.com/error-help/db/ora-01400/

Environment

- OS: Ubuntu 22.04.5 LTS
- Python: 3.10.16
- dbt: 1.9.3
  - dbt-oracle: 1.9.0

What Oracle database version are you using dbt with?

19.0.0.0.0

Additional Context

the search for the bug lead me to this other closed bug that seems very similar (if not the same)
i prepared an example repo were you can test the exact case if you need to

@fabrcav fabrcav added the bug Something isn't working label Mar 21, 2025
@aosingh aosingh self-assigned this Mar 21, 2025
@aosingh
Copy link
Member

aosingh commented Mar 26, 2025

Hi @fabrcav

I am checking this.

Ideally, I would have liked some try..finally block equivalent in dbt macros which I have not found

@fabrcav
Copy link
Author

fabrcav commented Mar 27, 2025

Hello @aosingh,
thank you for loking into this. seems like a package that implements try...finally blocks for jinja exists maybe this can be integrated?

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

2 participants