Skip to content

Commit 2b97652

Browse files
committed
v1.3.0 updates
- README updates. Simplified readmes - Added EOF New line - Renamed incremental/helpers.sql -> incremental/strategies.sql
1 parent d3df3de commit 2b97652

File tree

6 files changed

+41
-258
lines changed

6 files changed

+41
-258
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
[![PyPI version](https://badge.fury.io/py/dbt-oracle.svg)](https://pypi.python.org/pypi/dbt-oracle)
44
[![dbt-tests-adapter](https://github.com/oracle/dbt-oracle/actions/workflows/oracle-xe-adapter-tests.yml/badge.svg)](https://github.com/oracle/dbt-oracle/actions/workflows/oracle-xe-adapter-tests.yml)
55

6-
dbt "adapters" are responsible for adapting dbt's functionality to a given database. `dbt-oracle` implements dbt functionalities for the Oracle database.
6+
`dbt-oracle` implements [dbt (data build tool)](https://docs.getdbt.com/docs/introduction) functionalities for the Oracle database.
77

88
> Prior to version 1.0.0, dbt-oracle was created and maintained by [Indicium](https://indicium.tech/) on [their GitHub repo](https://github.com/techindicium/dbt-oracle). Contributors in this repo are credited for laying the groundwork and maintaining the adapter till version 0.4.3.
99
From version 1.0.0, dbt-oracle is maintained and distributed by Oracle.
1010

1111

12-
For dbt documentation, refer https://docs.getdbt.com/docs/introduction
13-
1412
## Installation
1513

1614
For installation, read how you can set up [Oracle profile][1] for dbt

dbt/include/oracle/macros/materializations/incremental/helpers.sql renamed to dbt/include/oracle/macros/materializations/incremental/strategies.sql

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,6 @@
3434
)
3535
{%- endmacro %}
3636

37-
{% macro oracle_check_and_quote_column_names_for_incremental_merge(dest_column_names) %}
38-
{%- set quoted_update_columns = [] -%}
39-
{%- set update_columns = config.get("merge_update_columns", default=dest_column_names) -%}
40-
{% for col in update_columns %}
41-
{% do quoted_update_columns.append(adapter.check_and_quote_identifier(col, model.columns)) %}
42-
{% endfor %}
43-
{{ return(quoted_update_columns)}}
44-
{% endmacro %}
45-
4637
{% macro oracle_check_and_quote_unique_key_for_incremental_merge(unique_key) %}
4738
{%- set quote = "\"" -%}
4839
{%- set unique_key_list = [] -%}
@@ -54,20 +45,20 @@
5445
{% else %}
5546
{% do unique_key_list.append(key.upper()) %}
5647
{% endif %}
57-
{% endfor %}
48+
{% endfor %}
49+
{% else %}
50+
{% if adapter.should_identifier_be_quoted(unique_key, model.columns) == true %}
51+
{% do unique_key_list.append(quote ~ unique_key ~ quote) %}
5852
{% else %}
59-
{% if adapter.should_identifier_be_quoted(unique_key, model.columns) == true %}
60-
{% do unique_key_list.append(quote ~ unique_key ~ quote) %}
61-
{% else %}
62-
{% do unique_key_list.append(unique_key.upper()) %}
63-
{% endif %}
53+
{% do unique_key_list.append(unique_key.upper()) %}
6454
{% endif %}
65-
{% for key in unique_key_list %}
66-
{% set this_key_match %}
67-
temp.{{ key }} = target.{{ key }}
68-
{% endset %}
69-
{% do unique_key_merge_predicates.append(this_key_match) %}
70-
{% endfor %}
55+
{% endif %}
56+
{% for key in unique_key_list %}
57+
{% set this_key_match %}
58+
temp.{{ key }} = target.{{ key }}
59+
{% endset %}
60+
{% do unique_key_merge_predicates.append(this_key_match) %}
61+
{% endfor %}
7162
{%- set unique_key_result = {'unique_key_list': unique_key_list, 'unique_key_merge_predicates': unique_key_merge_predicates} -%}
7263
{{ return(unique_key_result)}}
7364
{% endmacro %}
@@ -155,4 +146,3 @@
155146
{% macro oracle__get_incremental_default_sql(arg_dict) %}
156147
{% do return(get_incremental_merge_sql(arg_dict)) %}
157148
{% endmacro %}
158-

dbt/include/oracle/macros/utils/data_types.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@
2828

2929
{% macro oracle__type_boolean() -%}
3030
NUMBER(1)
31-
{%- endmacro %}
31+
{%- endmacro %}

dbt/include/oracle/macros/utils/timestamps.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
{% macro oracle__snapshot_string_as_time(timestamp) -%}
2323
{%- set result = "TO_TIMESTAMP('"~ timestamp ~ "','yyyy/mm/dd hh24:mi:ss.FF')" -%}
2424
{{ return(result) }}
25-
{%- endmacro %}
25+
{%- endmacro %}

dbt_adbs_test_project/README.md

Lines changed: 26 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -9,70 +9,44 @@ To test the integration with ADBS, you can use OCI's [Always Free Autonomous Dat
99

1010
The database also provides a read-only Sales History data set. Any user can start querying the tables in this Sales History `sh` schema. Models in this test project refer the `sh` schema. You do not need to load any other dataset.
1111

12-
## Setup the oracle profile
12+
## Setup
1313

14-
To setup [profiles.yml](profiles.yml) read [setup & installation instructions][1] on dbt docs website
14+
[Install][1] dbt-oracle and setup [profiles.yml](profiles.yml) for ADBS
1515

16-
Install dbt-oracle in your project's virtual environment.
16+
### Verify the installation
1717

18-
19-
## dbt project
20-
21-
Next, run the `dbt compile` command in this project directory to compile the models and resolve dependencies.
2218
```bash
23-
dbt compile --profiles-dir ./
19+
dbt --version
2420
```
21+
2522
```text
26-
20:14:29 Running with dbt=1.0.1
27-
20:14:29 Found 10 models, 5 tests, 1 snapshot, 1 analysis, 382 macros, 2 operations, 1 seed file, 8 sources, 2 exposures, 0 metrics
28-
20:14:29
29-
20:14:32 Concurrency: 4 threads (target='dev')
30-
20:14:32
31-
20:14:33 Done.
23+
Core:
24+
- installed: 1.3.0
25+
- latest: 1.3.0 - Up to date!
3226
```
33-
All dbt models in this test project refer the sales history (`sh`) sample schema.
34-
Following directory structure shows the 10 models, seed, test, analysis and snaphots.
3527

28+
### Check database connectivity
3629

37-
```text
38-
.
39-
├── README.md
40-
├── analysis
41-
│   └── eu_customers.sql
42-
├── data
43-
│   └── seed.csv
44-
├── dbt_packages
45-
│   └── dbt_utils
46-
├── dbt_project.yml
47-
├── macros
48-
│   ├── demo_multiple_statements.sql
49-
│   ├── execute_statements.sql
50-
│   └── readme.md
51-
├── models
52-
│   ├── direct_sales_channel_promo_cost.sql
53-
│   ├── eu
54-
│   ├── countries.sql
55-
│   └── eu_direct_sales_channels_promo_costs.sql
56-
│   ├── income_levels.sql
57-
│   ├── internet_sales_channel_customers.sql
58-
│   ├── people.sql
59-
│   ├── promotion_costs.sql
60-
│   ├── sales_internet_channel.sql
61-
│   ├── schema.yml
62-
│   ├── us_product_sales_channel_ranking.sql
63-
│   └── us_seed_customers.sql
64-
├── packages.yml
65-
├── profiles.yml
66-
├── seeds
67-
│   └── seed.csv
68-
├── snapshots
69-
│   ├── README.md
70-
│   └── promotion_costs.sql
71-
└── test
72-
└── test_count_employees.sql
30+
```bash
31+
dbt debug --profiles-dir ./
32+
```
7333

34+
```text
35+
dbt version: 1.3.0
36+
python version: 3.8.13
37+
..
38+
..
39+
Connection:
40+
user:
41+
database:
42+
schema:
43+
...
44+
Connection test: [OK connection ok]
45+
46+
All checks passed!
7447
7548
```
49+
After this, you can test various dbt features included in this project
7650

7751
## Features tested in this project
7852

tests/README.md

Lines changed: 0 additions & 179 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
- [Environment Variables](#environment-variables)
66
- [Adapter Plugin Tests](#adapter-plugin-tests)
77
- [Testing for different Python versions](#different-python-versions)
8-
- [Jaffle Shop Test Project](#jaffle-shop-test-project)
98

109

1110
## Environment variables <a name='environment-variables'></a>
@@ -109,181 +108,3 @@ For each environment, you can also see the test runtime as summary
109108
py39 - 24 passed in 755.18s (0:12:35)
110109
py310 - 24 passed in 764.96s (0:12:44)
111110
```
112-
113-
## Jaffle Shop Test Project <a name='jaffle-shop-test-project'></a>
114-
115-
[Jaffle Shop test project](https://github.com/dbt-labs/jaffle_shop) is a self-contained dbt project which can be used for testing the adapter.
116-
117-
### Profile
118-
119-
Setup a `jaffle_shop` profile to connect to the Oracle Database
120-
121-
```yaml
122-
# ~/.dbt/profiles.yml
123-
jaffle_shop:
124-
target: dev
125-
outputs:
126-
dev:
127-
type: oracle
128-
user: "{{ env_var('DBT_ORACLE_USER') }}"
129-
pass: "{{ env_var('DBT_ORACLE_PASSWORD') }}"
130-
protocol: "tcps"
131-
host: "{{ env_var('DBT_ORACLE_HOST') }}"
132-
port: 1522
133-
service: "{{ env_var('DBT_ORACLE_SERVICE') }}"
134-
database: "{{ env_var('DBT_ORACLE_DATABASE') }}"
135-
schema: "{{ env_var('DBT_ORACLE_SCHEMA') }}"
136-
threads: 4
137-
138-
```
139-
140-
### dbt debug
141-
142-
To test connection, run the `dbt debug` command from the `jaffle_shop` project directory
143-
144-
```text
145-
Connection:
146-
user: <...>
147-
database: <...>
148-
schema: <...>
149-
protocol: tcps
150-
host: <...>
151-
port: 1522
152-
service: <...>
153-
connection_string: None
154-
Connection test: [OK connection ok]
155-
156-
All checks passed!
157-
```
158-
159-
160-
### Seed `quote_columns` config
161-
162-
By default, seed configuration `quote_columns` is expected to be False as explained here https://docs.getdbt.com/reference/resource-configs/quote_columns
163-
164-
However, seed column names are quoted when `dbt seed` command is run.
165-
166-
This raises `ORA-00904: "AMOUNT": invalid identifier` errors in the subsequent `dbt run` command.
167-
168-
```text
169-
19:12:11.145108 [error] [MainThread]: Database Error in model stg_payments (models/staging/stg_payments.sql)
170-
19:12:11.145796 [error] [MainThread]: ORA-00904: "AMOUNT": invalid identifier
171-
19:12:11.146445 [error] [MainThread]: compiled SQL at target/run/jaffle_shop/models/staging/stg_payments.sql
172-
19:12:11.147094 [info ] [MainThread]:
173-
19:12:11.147972 [error] [MainThread]: Database Error in model stg_orders (models/staging/stg_orders.sql)
174-
19:12:11.148769 [error] [MainThread]: ORA-00904: "STATUS": invalid identifier
175-
19:12:11.149495 [error] [MainThread]: compiled SQL at target/run/jaffle_shop/models/staging/stg_orders.sql
176-
19:12:11.150168 [info ] [MainThread]:
177-
19:12:11.150703 [error] [MainThread]: Database Error in model stg_customers (models/staging/stg_customers.sql)
178-
19:12:11.151226 [error] [MainThread]: ORA-00904: "LAST_NAME": invalid identifier
179-
19:12:11.151734 [error] [MainThread]: compiled SQL at target/run/jaffle_shop/models/staging/stg_customers.sql
180-
181-
```
182-
183-
Disable `quote_columns` in `dbt_project.yml`.
184-
185-
```yaml
186-
name: 'jaffle_shop'
187-
version: '0.1'
188-
profile: 'jaffle_shop'
189-
config-version: 2
190-
191-
source-paths: ["models"]
192-
analysis-paths: ["analysis"]
193-
test-paths: ["tests"]
194-
data-paths: ["data"]
195-
macro-paths: ["macros"]
196-
197-
target-path: "target"
198-
clean-targets:
199-
- "target"
200-
- "dbt_modules"
201-
- "logs"
202-
203-
models:
204-
jaffle_shop:
205-
materialized: table
206-
staging:
207-
materialized: view
208-
209-
# Disable seed config quote_columns
210-
seeds:
211-
jaffle_shop:
212-
quote_columns: false
213-
```
214-
215-
### dbt seed
216-
217-
```text
218-
219-
21:20:43 Running with dbt=1.0.1
220-
21:20:44 Found 5 models, 20 tests, 0 snapshots, 0 analyses, 193 macros, 0 operations, 3 seed files, 0 sources, 0 exposures, 0 metrics
221-
21:20:44
222-
21:20:51 Concurrency: 4 threads (target='dev')
223-
21:20:51
224-
21:20:51 1 of 3 START seed file dbt_test.raw_customers................................... [RUN]
225-
21:20:51 2 of 3 START seed file dbt_test.raw_orders...................................... [RUN]
226-
21:20:51 3 of 3 START seed file dbt_test.raw_payments.................................... [RUN]
227-
21:20:54 2 of 3 OK loaded seed file dbt_test.raw_orders.................................. [INSERT 99 in 3.56s]
228-
21:20:54 1 of 3 OK loaded seed file dbt_test.raw_customers............................... [INSERT 100 in 3.56s]
229-
21:20:55 3 of 3 OK loaded seed file dbt_test.raw_payments................................ [INSERT 113 in 4.20s]
230-
21:20:57
231-
21:20:57 Finished running 3 seeds in 13.23s.
232-
21:20:57
233-
21:20:57 Completed successfully
234-
21:20:57
235-
21:20:57 Done. PASS=3 WARN=0 ERROR=0 SKIP=0 TOTAL=3
236-
237-
```
238-
239-
240-
### dbt run
241-
242-
```text
243-
21:21:28 Running with dbt=1.0.1
244-
21:21:28 Found 5 models, 20 tests, 0 snapshots, 0 analyses, 193 macros, 0 operations, 3 seed files, 0 sources, 0 exposures, 0 metrics
245-
21:21:28
246-
21:21:35 Concurrency: 4 threads (target='dev')
247-
21:21:35
248-
21:21:35 1 of 5 START view model dbt_test.stg_customers.................................. [RUN]
249-
21:21:35 2 of 5 START view model dbt_test.stg_orders..................................... [RUN]
250-
21:21:35 3 of 5 START view model dbt_test.stg_payments................................... [RUN]
251-
21:21:38 2 of 5 OK created view model dbt_test.stg_orders................................ [OK in 3.07s]
252-
21:21:38 3 of 5 OK created view model dbt_test.stg_payments.............................. [OK in 3.07s]
253-
21:21:38 1 of 5 OK created view model dbt_test.stg_customers............................. [OK in 3.07s]
254-
21:21:38 4 of 5 START table model dbt_test.orders........................................ [RUN]
255-
21:21:38 5 of 5 START table model dbt_test.customers..................................... [RUN]
256-
21:21:41 4 of 5 OK created table model dbt_test.orders................................... [OK in 3.63s]
257-
21:21:41 5 of 5 OK created table model dbt_test.customers................................ [OK in 3.61s]
258-
21:21:43
259-
21:21:43 Finished running 3 view models, 2 table models in 15.27s.
260-
21:21:43
261-
21:21:43 Completed successfully
262-
21:21:43
263-
21:21:43 Done. PASS=5 WARN=0 ERROR=0 SKIP=0 TOTAL=5
264-
265-
```
266-
267-
### dbt test
268-
269-
```text
270-
21:23:10 Running with dbt=1.0.1
271-
21:23:10 Found 5 models, 20 tests, 0 snapshots, 0 analyses, 193 macros, 0 operations, 3 seed files, 0 sources, 0 exposures, 0 metrics
272-
21:23:10
273-
21:23:16 Concurrency: 4 threads (target='dev')
274-
21:23:16
275-
....
276-
....
277-
....
278-
....
279-
21:23:34 17 of 20 PASS unique_orders_order_id............................................ [PASS in 2.78s]
280-
21:23:35 20 of 20 PASS unique_stg_payments_payment_id.................................... [PASS in 2.08s]
281-
21:23:35 19 of 20 PASS unique_stg_orders_order_id........................................ [PASS in 2.40s]
282-
21:23:37
283-
21:23:37 Finished running 20 tests in 27.14s.
284-
21:23:37
285-
21:23:37 Completed successfully
286-
21:23:37
287-
21:23:37 Done. PASS=20 WARN=0 ERROR=0 SKIP=0 TOTAL=20
288-
289-
```

0 commit comments

Comments
 (0)