-
Notifications
You must be signed in to change notification settings - Fork 24
Description
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
When database parameter doesn't match the service parameter:
First run: Successfully creates table in correct schema
Second run: Fails with ORA-00955: name is already used by an existing object
The adapter incorrectly tries to CREATE TABLE instead of running incremental logic because relation detection fails.
Expected Behavior
- Create the table on first run
- Run incremental logic (MERGE/DELETE+INSERT) on subsequent runs
- Work regardless of the
databaseparameter value
Steps To Reproduce
- Configure profiles.yml with mismatched database/service:
my_profile:
target: dev
outputs:
dev:
type: oracle
user: dbt
pass: password
service: MYSERVICE
database: MYDATABASE# <-- doesn't match service!
schema: dbt
host: localhost
port: 1521
- Configure custom schema in dbt_project.yml:
models:
my_project:
intermediate:
+schema: intermediate
- Create an incremental model:
-- models/intermediate/test_incremental.sql
{{
config(
materialized='incremental',
unique_key='id',
incremental_strategy='merge'
)
}}
select
1 as id,
'test' as value
from dual
{% if is_incremental() %}
where 1 = 0 -- No new data on incremental runs for testing
{% endif %}
- Run twice and observe the error:
$ dbt run --select test_incremental
First run succeeds - creates intermediate.test_incremental
$ dbt run --select test_incremental
Second run fails with:
ORA-00955: name is already used by an existing object
Relevant log output using --debug flag enabled
Environment
- OS:Ubuntu 24.04
- Python: Python 3.12.3
- dbt-core: v1.9
- dbt-oracle: 1.9.4What Oracle database version are you using dbt with?
19c
Additional Context
In our case, local development worked because the database name matched the service name, but in the test environment we encountered this problem.
A workaround was to remove the database parameter entirely from profiles.yml.
After removing it, incremental models work correctly on all subsequent runs.
Suggested fix
Looking at the code in dbt/adapters/oracle/impl.py, the get_relation() method could be modified to ignore the database parameter:
Current code:
def get_relation(self, database: str, schema: str, identifier: str) -> Optional[BaseRelation]:
if database == 'None':
database = self.config.credentials.database
return super().get_relation(database, schema, identifier)
Change to:
def get_relation(self, database: str, schema: str, identifier: str) -> Optional[BaseRelation]:
# In Oracle database parameter doesn't apply
# Use None for consistent cache lookups
return super().get_relation(None, schema, identifier)
Alternatively, the adapter could validate that database matches the actual Oracle database name or document that it should be omitted for Oracle.