Package: oracle4dbt
oracle4dbtOracle adapter for DBT (Data Build Tool):warning: PLEASE READ THIS :warning:This adapter is not suitable for production usage. It's just a way to test DBT and its opinionated workflow if you currently use an Oracle database.The intended usage is to point at aTESTdatabase and try out the different features.InstallationThe adapter uses the cx_Oracle package, so you need to have an Oracle client installed on your system.
You can either use the client that comes in with your DB or download the instant client from Oracle.https://www.oracle.com/database/technologies/instant-client.htmlSupported versionsDBT:tested with 0.19.0should probably work with >= 0.19.0Oracle:tested with DB version 18cshould probably work with >= 12.2 (identifiers length >= 128 chars)Profile configurationAdd the following into yourprofiles.ymldefault:outputs:dev:type:oraclethreads:4host:localhostport:1521service:XEPDB1username:SYSpassword:rootas_sysdba:truenls_date_format:'YYYY-MM-DDHH24:MI:SS'schema:dbt_testTo generate a sample profile.yml you can usedbt init [project_name] --adapter oracleNotes:host,portandserviceare used while connecting to the databasehost:port/service_nameas_sysdbais optional, defaults to falsenls_date_formatis optional, defaults to none.if you provide a value, it will be set on every session opened by DBT.Also:nls_timestamp_format will be set as{nls_date_format}XFFnls_timestamp_tz_format will be set as{nls_date_format}XFF TZRFeaturesApart from what is listed in the Caveats sections, every DBT functionality is expected to be working as intended.This includes:materializationssnapshotstestscustom schemashooksseedsIf something is  off please open an issueCaveatsDBT is thought from the ground up to be run against a set of databases (postgres, redshift, snowflake, ...); therefore in some cases Oracle behave differently.The main caveats are listed below.
Please note that if you write SQL that works on Oracle it should be good to go in DBT too.CTE / with clauses / ephemeral modelsOracle doesn't support nested with clauses.Put simply, you can't do:WITH cte_a AS (
    WITH cte_b AS (
        ...
    )
    SELECT * FROM cte_b
)
SELECT * FROM cte_aThis has some implications, the most important one is that you can'trefan ephemeral model from another ephemeral modelThe error message is usually pretty clear: just refactor your codeCTE namesIn some cases, if you name the CTE as the base table an error is raisedWITH table_a AS (
    SELECT * FROM schema_a.table_a
)NLSIn some cases DBT performs conversions between date/timestamps and pythonstr.
For this reason explicitly setting a NLS_DATE_FORMAT in the profile may avoid problems.If you keep getting errors likeORA-01843: not a valid monthplease consider setting the profile parameter.
It will be set on every session opened by DBTTestsTesting is done using Tox.There are four kind of tests available:unit testsintegration testsdbt adapter testssample projectsUnit testsForked from DBT main repo and adapted to Oracle (mainly SQL changes)Launch withtox -e unitIntegration testsForked from DBT main repo, adapted to Oracle (mainly SQL changes).Postgres tests are used, as these are the one more closely related to Oracle. Tests of specific Postgres commands are disabled (eg. vacuum commands)Launch withtox -e integrationDbt adapter testsForked fromhttps://github.com/fishtown-analytics/dbt-adapter-testsand adapted to Oracle.Launch withtox -e dbt-adapterSample projectsJaffle Shop and Attribute Playbook projects are available to launch. Some models have been changed to make them compatible with Oracle syntax.Launch with:jaffle_shop:tox -e jaffle-shopattribution_playbook:tox -e attribution-playbookContributingEvery contribution is welcome and encouraged.Please note that this is a side project and replies may need some time