-
Notifications
You must be signed in to change notification settings - Fork 20
[Bug] don't drop temporary table o$pt #12
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
Comments
Hi @AlexMorti Thank you for the detailed bug report. I would like to understand how to reproduce the error In dbt-oracle, temporary tables are named in the following format:
So, unless you have multiple dbt invocations at the same time (precisely the same second), you wouldn't get |
test model if you remove the exception condition dbt-oracle/dbt/include/oracle/macros/adapters.sql Lines 262 to 263 in 461f58c
then there will always be an error: ORA-14452: attempt to create, alter or drop an index on temporary table already in use logs attached dbt.log |
Hi @AlexMorti, you did not finish this sentence regarding the current behavior. I had the same issue that the temporary table was not dropped caused by the following issue #8 as the incremental materialization failed due to the ORA errors mentioned in the ticket. |
Thanks for attaching the logs. I am checking this |
I checked the logs. It is not clear to me why do you want to delete the line. What is the use case ?
If you keep this line, what is the error you get when you run incremental materialization ? |
Hi @AlexMorti Could you run dbt without any code changes for an incremental model and share the log ? I would like to understand the ORA errors you get without any code changes. Thank you |
Hi @AlexMorti I could reproduce the issue and confirm that Thank you. |
- Both Incremental materialization and Snapshots use temporary tables to stage new data. The data from the temp table is either merged or inserted into the target table. These temp tables are automatically truncated after the session exits, however they were never dropped. - This fix first truncates the temporary table and then drops it.
Is there an existing issue for this?
Current Behavior
The global temporary table is not deleted after running the model due to an
[dbt-oracle/blob/main/dbt/include/oracle/macros/adapters.sql](
dbt-oracle/dbt/include/oracle/macros/adapters.sql
Line 259 in 7348c2b
example:
create global temporary table TEST (object_id number, object_name varchar2(30)) on commit PRESERVE rows;
Such tables get bound to the session with the first insert and then this binding is ONLY removed when the session exits or by truncate. If the binding exists DDL cannot be performed on these temporary tables and if you try a DDL on such tables you would receive ORA-14452 attempt to create, alter or drop an index on temporary table already in use.
add before
dbt-oracle/dbt/include/oracle/macros/materializations/incremental/incremental.sql
Line 63 in 7348c2b
{% for rel in to_drop %}
{% do adapter.truncate_relation(rel) %}
{% endfor %}
Expected Behavior
drop table
Steps To Reproduce
Relevant log output using
--debug
flag enabledNo response
Environment
What Oracle database version are you using dbt with?
12.1.0
Additional Context
No response
The text was updated successfully, but these errors were encountered: