Skip to content

Commit

Permalink
Add remaining adapters and profile tests (#12)
Browse files Browse the repository at this point in the history
* Finish profile tests, all pass

* Update README to show all adapters covered
  • Loading branch information
gwenwindflower authored Mar 8, 2024
1 parent 87c2363 commit 5185db5
Show file tree
Hide file tree
Showing 10 changed files with 192 additions and 50 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ The following features are implemented or planned:

- [x] dbt [Best Practices project structure](https://docs.getdbt.com/best-practices/how-we-structure/1-guide-overview)
- [x] Basic initial dbt Project configuration
- [ ] Coverage of all non-password-based authentication methods for the below warehouses[^1]
- [ ] Warehouse-aware dbt profile configuration for the following options, check out the [dbt docs on warehouse-specific profile configs](https://docs.getdbt.com/docs/core/connect-data-platform/about-core-connections) for more details:
- [x] Coverage of all non-password-based authentication methods for the below warehouses[^1]
- [x] Warehouse-aware dbt profile configuration for the following options, check out the [dbt docs on warehouse-specific profile configs](https://docs.getdbt.com/docs/core/connect-data-platform/about-core-connections) for more details:
- [x] Snowflake - using `authenticator: externalbrowser` with SSO
- [x] BigQuery - using `method: oauth` via `gcloud` CLI
- [ ] Databricks - using `token: <empty>`, you will need to create a personal access token in Databricks, and fill it into that field in to your `~/.dbt/profiles.yml` manually once the project is created[^1]
- [ ] Redshift - using `method: IAM` via `awscli`
- [ ] Postgres - still haven't decided the best way to handle Postgres
- [x] Databricks - using `token: <empty>`, you will need to create a personal access token in Databricks, and fill it into that field in to your `~/.dbt/profiles.yml` manually once the project is created[^1]
- [x] Redshift - using `method: IAM` via `awscli`
- [x] Postgres - still haven't decided the best way to handle Postgres
- [x] DuckDB - local warehouse, no authentication required
- [x] Linting and formatting of SQL with SQLFluff
- [x] Configurable linting rules in the setup process
Expand Down
69 changes: 58 additions & 11 deletions copier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ project_name:

project_slug:
type: str
default: "{{ project_name | lower | replace(' ', '_') | replace('-', '_') | replace('.', '') }}"
default: "{{ project_name | lower | replace(' ', '_') | replace('-', '_') | replace('.', '') | replace(\"'\", '')}}"
help: The slugified name of your project.

# Warehouse profile connection configs
# Warehouse profile connection shared configs
# All configs that are shared by more than one warehouse
profile_name:
type: str
default: "{{ project_slug }}"
Expand All @@ -29,25 +30,28 @@ data_warehouse:
- postgres
- duckdb

username:
type: str
help: The username you log in to your database with.
when: "{{ data_warehouse in ['snowflake'] }}"

database:
type: str
help: |
The name or id of the database (or project in BigQuery) *within* your data platform that you want to build into.
when: "{{ data_warehouse in [ 'snowflake', 'bigquery', 'duckdb' ] }}"

schema:
type: str
help: |
The name of the schema (or dataset in BigQuery) in the database you want to build into.
thread_count:
host:
type: str
help: |
The URL string of the database host — don't include 'https://'.
when: "{{ data_warehouse in [ 'databricks', 'redshift', 'postgres' ] }}"

port:
type: int
default: 8
help: How many threads you want to dbt to run in parallel?
help: |
The port number on your database host to connect to.
when: "{{ data_warehouse in [ 'redshift', 'postgres' ] }}"

# Snowflake-specific configs
account_id:
Expand All @@ -69,14 +73,51 @@ warehouse:
help: The name of your default development compute warehouse.
when: "{{ data_warehouse == 'snowflake' }}"

username:
type: str
help: The username you log in to your database with. This may be an email address or a plain string.
when: "{{ data_warehouse in [ 'snowflake', 'redshift', 'postgres' ] }}"

# BigQuery specific configs
# There are none for now! `oauth` with `gcloud` is great.
# None for now!

# Databricks specific configs
using_unity_catalog:
type: bool
default: False
help: Are you using Datbricks Unity Catalog?
when: "{{ data_warehouse == 'databricks' }}"

catalog:
type: str
help: Optional catalog name if you're using Unity Catalog.
when: "{{ using_unity_catalog }}"

http_path:
type: str
help: The http path to your SQL Warehouse or all-purpose cluster.
when: "{{ data_warehouse == 'databricks' }}"

# Redshift specific configs
cluster_id:
type: str
help: The id of your warehouse cluster.
when: "{{ data_warehouse == 'redshift' }}"

iam_profile:
type: str
default: default
help: The name of the profile to use for connection.
when: "{{ data_warehouse == 'redshift' }}"

region:
type: str
default: "us-east-1"
help: The region to connect your IAM profile through.
when: "{{ data_warehouse == 'redshift' }}"

# Postgres specific configs
# None for now!

# DuckDB specific configs
duckdb_file_path:
Expand All @@ -87,6 +128,12 @@ duckdb_file_path:
Strongly suggest the default, which will be automatically gitignored.
when: "{{ data_warehouse == 'duckdb' }}"

# dbt development configs
thread_count:
type: int
default: 8
help: How many threads you want to dbt to run in parallel?

# Formatting configs
tab_space_size:
type: int
Expand Down
35 changes: 29 additions & 6 deletions profiles.yml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
dev:
type: {{ data_warehouse | lower }}
account: {{ account_env_var | lower }}
user: {{ username | lower }}
authenticator: externalbrowser
database: {{ database | lower}}
user: {{ username | lower }}
warehouse: {{ warehouse | lower }}
database: {{ database | lower}}
schema: {{ schema | lower }}
threads: {{ thread_count}}
{%- endif -%}
Expand All @@ -18,17 +18,27 @@
outputs:
dev:
type: {{ data_warehouse }}
method: oauth
project: {{ database | lower }}
dataset: {{ schema | lower }}
method: oauth
threads: {{ thread_count }}
{%- endif -%}
{% if data_warehouse == "redshift" %}
{{ profile_name }}:
target: dev
outputs:
dev:
# coming soon
type: {{ data_warehouse | lower }}
method: iam
iam_profile: {{ iam_profile | lower }}
region: {{ region | lower }}
cluster_id: {{ cluster_id | lower }}
host: {{ host | lower }}
port: {{ port | lower }}
user: {{ username | lower }}
database: {{ database | lower }}
schema: {{ schema | lower }}
threads: {{ thread_count }}
{%- endif -%}
{% if data_warehouse == "duckdb" %}
{{ profile_name }}:
Expand All @@ -46,12 +56,25 @@
target: dev
outputs:
dev:
# coming soon
type: {{ data_warehouse | lower }}
host: {{ host | lower }}
port: {{ port | lower }}
user: {{ username | lower }}
password: "" # Add a password here if needed
database: {{ database | lower }}
schema: {{ schema | lower }}
threads: {{ thread_count }}
{%- endif -%}
{% if data_warehouse == "databricks" %}
{{ profile_name }}:
target: dev
outputs:
dev:
# coming soon
type: {{ data_warehouse | lower }}
{% if using_unity_catalog -%}catalog: {{ catalog | lower }}{%- endif %}
host: {{ host | lower }}
http_path: {{ http_path | lower }}
token: # Your Personal Access Token here
schema: {{ schema | lower }}
threads: {{ thread_count }}
{%- endif -%}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

legoalas_corp:
target: dev
outputs:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
faramir_landscaping:
target: dev
outputs:
dev:
type: databricks
catalog: tower_of_ecthelion
host: faramir-landscaping
http_path: ithilien.databricks.com
token: # Your Personal Access Token here
schema: bridal_gifts
threads: 8
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@

lothlorien_enterprises:
galadriels_mirrors_and_more:
target: dev
outputs:
dev:
type: duckdb
path: ./lothlorien.db
database: mallorn
schema: flets
database: lothlorien
schema: mallorn_trees
threads: 8
12 changes: 12 additions & 0 deletions template-integration-tests/test-expectations/postgres_profile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
shieldmaiden_security:
target: dev
outputs:
dev:
type: postgres
host: localhost
port: 5432
user: eowyn
password: "" # Add a password here if needed
database: rohan
schema: nazgul_threat_assessments
threads: 8
15 changes: 15 additions & 0 deletions template-integration-tests/test-expectations/redshift_profile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
gimli_mining:
target: dev
outputs:
dev:
type: redshift
method: iam
iam_profile: default
region: us-east-1
cluster_id: legolas-bff-4eva
host: gimli-mining.us-east-1.redshift.amazonaws.com
port: 5439
user: gimli_son_of_gloin
database: ores
schema: mithril
threads: 8
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@

aragorn_inc:
target: dev
outputs:
dev:
type: snowflake
account:
user: strider
account:
authenticator: externalbrowser
database: gondor
user: strider
warehouse: narsil
database: dunedain
schema: rangers
threads: 8
Loading

0 comments on commit 5185db5

Please sign in to comment.