Skip to content

Commit 4e5e528

Browse files
authored
Merge pull request #23 from oracle/release/v1.0.3
Release/v1.0.3
2 parents 461f58c + 4a3da7a commit 4e5e528

File tree

20 files changed

+165
-270
lines changed

20 files changed

+165
-270
lines changed

README.md

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

6-
dbt "adapters" are responsible for adapting dbt's functionality to a given database. `dbt-oracle` implements dbt functionalities for the Oracle database. To learn more about building adapters, check
7-
https://docs.getdbt.com/docs/contributing/building-a-new-adapter
6+
dbt "adapters" are responsible for adapting dbt's functionality to a given database. `dbt-oracle` implements dbt functionalities for the Oracle database.
87

98
> 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.
109
From version 1.0.0, dbt-oracle is maintained and distributed by Oracle.
1110

12-
## What is dbt? <a name='what-is-dbt'></a>
13-
14-
dbt does the T in ELT (Extract, Load, Transform). To work with dbt you need a copy of your data already loaded in your warehouse.
15-
16-
### dbt features <a name='core-concepts'></a>
17-
- With dbt, you can express all transforms with SQL select
18-
- Different materialization strategies.
19-
- view
20-
- table
21-
- incremental; selective rebuild for new rows
22-
- ephemeral; Model 1 interpolated into Model 2 as a Common Table Expression (CTE)
23-
- No need to write boilerplate code
24-
- All code to create table or views is generated using macros.
25-
- Idempotence; rerun models
26-
- If your source data were to stop updating, successive runs of your transformations would still result in the same tables and views in your warehouse.
27-
- If your production deployment of your transformations were interrupted, the next run of the transformations would result in the same tables and views as if the deployment had not been interrupted.
28-
- If you manually triggered transformations between scheduled runs, the scheduled run would result in the same tables and views as if the manual runs had not been triggered.
29-
- All transformation code is accessible and can be version controlled.
30-
- Dependency resolution
31-
- Use of ref() function ``select * from {{ ref('MODEL_NAME')}}``
32-
- dbt automatically resolves dependencies in between models and builds a Directed Acyclic Graph (DAG).
33-
Each path in the DAG can be independently executed using multiple threads.
34-
- Interpolates the name of database schema
35-
- Includes a built-in testing framework to ensure model accuracy
36-
- not null
37-
- unique
38-
- contains accepted values
39-
- relationships
40-
- custom tests
41-
- Generate documentation for your project and render it as a website.
42-
- Use macros to write reusable SQL
43-
44-
### An example <a name='an-example'></a>
45-
46-
dbt model
47-
```sql
48-
--models/sales_internet_channel.sql
49-
{{ config(materialized='table') }}
50-
WITH sales_internet AS (
51-
SELECT * FROM {{ source('sh_database', 'sales') }}
52-
WHERE channel_id = 4 )
53-
SELECT * FROM sales_internet
54-
```
55-
dbt compiles the above SQL template to run the below DDL statement.
56-
```sql
57-
CREATE TABLE dbt_test.sales_internet_channel AS
58-
WITH sales_internet AS (
59-
SELECT * from sh.sales
60-
WHERE channel_id = 4 )
61-
SELECT * FROM sales_internet
62-
```
6311

6412
For dbt documentation, refer https://docs.getdbt.com/docs/introduction
6513

66-
## Installation <a name='install'></a>
67-
68-
dbt-oracle can be installed via the Python Package Index (PyPI) using pip
69-
70-
`pip install -U dbt-oracle`
71-
72-
### Support <a name='support'></a>
73-
74-
dbt-oracle will provide support for the following
75-
76-
- Python versions 3.6, 3.7, 3.8 and 3.9
77-
- Autonomous Database versions 19c and 21c
78-
- OS
79-
- Linux
80-
- MacOS
81-
- Windows
82-
83-
### Core dependencies <a name='core-dependencies'></a>
84-
dbt-oracle requires the following 3 python packages.
85-
86-
`dbt-core`
87-
88-
- Open source framework for data transformation
89-
- Jinja Templating and core SQL compilation logic
90-
- Latest version of dbt-core is preferred; From version 1.0.0, dbt-core supports Python 3.7 or higher
91-
- For Python 3.6, pip will fallback to version 0.21.1 of dbt-core
92-
93-
`cx-Oracle`
94-
- Python driver for Oracle database
95-
- Oracle client libraries should be installed on the system. For details check, https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html
96-
97-
`dataclasses; python_version < '3.7'`
98-
- dataclasses package was introduced in the standard Python library from Python 3.7. This is conditional dependency and required only for Python 3.6
99-
100-
## Getting Started <a name='getting-started'></a>
101-
102-
Create a dbt project for oracle database using the `dbt init` command. The init command is interactive and will help you get started with a new project.
103-
104-
`dbt init` will:
105-
106-
* ask you the name of the project
107-
* ask you the database adapter you are using i.e. oracle
108-
* prompt to specify necessary connection details
109-
110-
This example shows initialization of test project `dbt_oracle_test_project`
111-
112-
```text
113-
>> dbt init
114-
115-
Running with dbt=1.0.4
116-
Enter a name for your project (letters, digits, underscore): dbt_oracle_test_project
117-
Which database would you like to use?
118-
[1] oracle
119-
Enter a number: 1
120-
protocol (tcp or tcps) [tcps]:
121-
host (adb.<oci-region>.oraclecloud.com) [{{ env_var('DBT_ORACLE_HOST') }}]:
122-
port [1522]:
123-
user [{{ env_var('DBT_ORACLE_USER') }}]:
124-
password [{{ env_var('DBT_ORACLE_PASSWORD') }}]:
125-
service (service name in tnsnames.ora) [{{ env_var('DBT_ORACLE_SERVICE') }}]:
126-
dbname (database name in which dbt objects should be created) [{{ env_var('DBT_ORACLE_DATABASE') }}]:
127-
schema (database schema in which dbt objects should be created) [{{ env_var('DBT_ORACLE_SCHEMA') }}]:
128-
threads (1 or more) [1]: 4
129-
Profile dbt_oracle_test_project written to ~/.dbt/profiles.yml using target's profile_template.yml and your supplied values. Run 'dbt debug' to validate the connection.
130-
Your new dbt project "dbt_oracle_test_project" was created!
131-
132-
```
133-
134-
Then dbt init command will:
135-
136-
1. Create the following folder with project name and sample files to get you started
137-
```text
138-
├── README.md
139-
├── analyses
140-
├── dbt_project.yml
141-
├── macros
142-
├── models
143-
│   └── example
144-
├── seeds
145-
├── snapshots
146-
└── tests
147-
```
148-
2. Create a connection profile on your local machine. The default location is `~/.dbt/profiles.yml`
14+
## Installation
14915

150-
Next step, [configure connection][1] related parameters and test if dbt connection works using dbt debug command
151-
152-
```text
153-
>> dbt debug
154-
155-
os info: macOS-11.6-x86_64-i386-64bit
156-
Using profiles.yml file at ~/.dbt/profiles.yml
157-
Using dbt_project.yml file at /dbt_oracle_test_project/dbt_project.yml
158-
Configuration:
159-
profiles.yml file [OK found and valid]
160-
dbt_project.yml file [OK found and valid]
161-
Required dependencies:
162-
- git [OK found]
163-
Connection:
164-
user: ***
165-
database: ga01d76d2ecd5e0_db202112221108
166-
schema: ***
167-
protocol: tcps
168-
host: adb.us-ashburn-1.oraclecloud.com
169-
port: 1522
170-
service: <service_name>_high.adb.oraclecloud.com
171-
connection_string: None
172-
shardingkey: []
173-
supershardingkey: []
174-
cclass: None
175-
purity: None
176-
Connection test: [OK connection ok]
177-
178-
All checks passed!
179-
```
16+
For installation, read how you can set up [Oracle profile][1] for dbt
18017

181-
## Documentation [TODO] <a name='documentation-todo'></a>
182-
Link to the homepage - https://oracle.github.io/dbt-oracle
18+
## Sample project
18319

184-
Link to documentation - https://dbt-oracle.readthedocs.io
20+
To get started, a sample dbt project can be found in the directory [/dbt_adbs_test_project][5]
18521

18622
## Contributing <a name='contributing'></a>
18723
This project welcomes contributions from the community. Before submitting a pull request, please review our [contribution guide][2].
@@ -192,7 +28,8 @@ Please consult the [security guide][3] for our responsible security vulnerabilit
19228
## License <a name='license'></a>
19329
dbt-oracle is licensed under Apache 2.0 License which you can find [here][4]
19430

195-
[1]: https://github.com/oracle/dbt-oracle/blob/main/dbt_adbs_test_project/profiles.yml
31+
[1]: https://docs.getdbt.com/reference/warehouse-profiles/oracle-profile
19632
[2]: https://github.com/oracle/dbt-oracle/blob/main/CONTRIBUTING.md
19733
[3]: https://github.com/oracle/dbt-oracle/blob/main/SECURITY.md
19834
[4]: https://github.com/oracle/dbt-oracle/blob/main/LICENSE.txt
35+
[5]: https://github.com/oracle/dbt-oracle/tree/main/dbt_adbs_test_project

dbt/adapters/oracle/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
"""
17-
version = "1.0.6"
17+
version = "1.0.7"

dbt/adapters/oracle/impl.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
from dbt.adapters.oracle.relation import OracleRelation
2929
from dbt.contracts.graph.manifest import Manifest
3030

31+
from dbt.exceptions import raise_compiler_error
32+
from dbt.utils import filter_null_values
3133

3234

3335
import agate
@@ -117,6 +119,21 @@ def verify_database(self, database):
117119
# return an empty string on success so macros can call this
118120
return ''
119121

122+
def _make_match_kwargs(self, database, schema, identifier):
123+
quoting = self.config.quoting
124+
if identifier is not None and quoting["identifier"] is False:
125+
identifier = identifier.upper()
126+
127+
if schema is not None and quoting["schema"] is False:
128+
schema = schema.upper()
129+
130+
if database is not None and quoting["database"] is False:
131+
database = database.upper()
132+
133+
return filter_null_values(
134+
{"identifier": identifier, "schema": schema, "database": database}
135+
)
136+
120137
def get_rows_different_sql(
121138
self,
122139
relation_a: OracleRelation,
@@ -212,3 +229,23 @@ def list_relations_without_caching(
212229
type=_type
213230
))
214231
return relations
232+
233+
@available
234+
def quote_seed_column(
235+
self, column: str, quote_config: Optional[bool]
236+
) -> str:
237+
quote_columns: bool = False
238+
if isinstance(quote_config, bool):
239+
quote_columns = quote_config
240+
elif quote_config is None:
241+
pass
242+
else:
243+
raise_compiler_error(
244+
f'The seed configuration value of "quote_columns" has an '
245+
f'invalid type {type(quote_config)}'
246+
)
247+
248+
if quote_columns:
249+
return self.quote(column)
250+
else:
251+
return column

0 commit comments

Comments
 (0)