-
Notifications
You must be signed in to change notification settings - Fork 20
Update adapters.sql #15
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
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
Oracle requires that contributors to all of its open-source projects sign the Oracle Contributor Agreement (OCA).
In order to sign the OCA, you need to create an Oracle account and sign the OCA in the Oracle's Contributor Agreement Application by following the steps on the homepage. When singing the OCA, please provide your GitHub username. By doing so, this PR will be automatically updated once the signed OCA was approved by Oracle. |
I've filled out OCA document so I guess I'll check / come back in a day or two to complete any additional steps |
@@ -26,9 +26,6 @@ | |||
{% endmacro %} | |||
|
|||
{% macro oracle__create_schema(database_name, schema_name) -%} | |||
{% if relation.database -%} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I already am working on issue which fixes this part.
I am currently working on this issue - #14 which raises these questions. Thank you for highlighting the problem with |
1. Following macros changed or fixed in adapter.sql to use custom schema name - oracle__create_schema, oracle__create_view_as, oracle__alter_relation_comment, oracle__alter_column_type, oracle__drop_relation, oracle__truncate_relation, oracle__rename_relation, oracle__make_temp_relation 2. Changed view materialization strategy which unncessarily created an intermediate <model>__dbt_tmp view first and renamed it to the target view. Now we directly CREATE or REPLACE view <target_view_name> 3. Added generate_schema_name.sql as per dbt documentation in test project to determine the name of the schema that a model should be built in. 4. Changed a couple of models in the test project to use custom schema 5. Fixes Bug #14 6. Fixes Bug #2 7. Addresses issues raised in PR #15
Thank you for raising a PR. Currently, the macro
To support custom schemas, we have handled this in view and incremental materialization to incorporate You can review all the changes here release/v1.0.3...fix/manage_objects_in_different_schema Is there a way you could modify the PR's base branch to merge with |
nice catch! I will address 'alter ...' statement to switch between table/view based on selected materialization strategy. |
This is already handled as seen here. If you could just change the base branch for this PR, I will merge the changes and resolves conflicts accordingly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to pull request against 1.0.3 vs main per committer request
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 #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 .<original_name> rename to <table_new_name>
tested with
Python 3.9.1
dbt-core 1.0.7
dbt-oracle 1.0.2