Skip to content

Commit f3ef84b

Browse files
authored
Update adapters.sql
changes are to address issues when using custom schemas 1 - create schema call verifies database. As of 1.0.7 Oracle adapter allows for database parm not to be set since Oracle doesn't allow statement prefix to include database name. Trickle down effect of that change is 'create schema check' not working hence why lines are removed. There is even dummy-noop already in that method since you can't create schemas dbt-way in oracle (schemas are users). 2 - once oracle#1 is addressed and custom schema is used, rename command will not find temp model table since schema is not passed as part of rename statement. Furthermore, rename statement will not work because Oracle doesn't support renaming tables that way. Alter Table to the rescue. changed from rename <table_original_name> to <table_new_name> to alter table <schema>.<original_name> rename to <table_new_name> tested with Python 3.9.1 dbt-core 1.0.7 dbt-oracle 1.0.2
1 parent 461f58c commit f3ef84b

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

dbt/include/oracle/macros/adapters.sql

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
{% endmacro %}
2727

2828
{% macro oracle__create_schema(database_name, schema_name) -%}
29-
{% if relation.database -%}
30-
{{ adapter.verify_database(relation.database) }}
31-
{%- endif -%}
3229
{%- call statement('drop_schema') -%}
3330
-- Noop for not breaking tests, oracle
3431
-- schemas are actualy users, we can't
@@ -275,7 +272,7 @@
275272

276273
{% macro oracle__rename_relation(from_relation, to_relation) -%}
277274
{% call statement('rename_relation') -%}
278-
rename {{ from_relation.include(False, False, True).quote(schema=False, identifier=False) }} to {{ to_relation.include(False, False, True).quote(schema=False, identifier=False) }}
275+
alter table {{ from_relation.include(False, True, True).quote(schema=False, identifier=False) }} rename to {{ to_relation.include(False, False, True).quote(schema=False, identifier=False) }}
279276
{%- endcall %}
280277
{% endmacro %}
281278

@@ -361,4 +358,4 @@
361358
{% set results = run_query("select SYS_CONTEXT('userenv', 'DB_NAME') FROM DUAL") %}
362359
{% set db_name = results.columns[0].values()[0] %}
363360
{{ return(db_name) }}
364-
{% endmacro %}
361+
{% endmacro %}

0 commit comments

Comments
 (0)