Skip to content

Commit 1c28e50

Browse files
trietschBob van den Hoogen
andauthored
feat(pace-171): add dbt snowflake example (#207)
* feat(pace-171): add dbt snowflake example * chore(pace-171): update dbt snowflake readme * fix: remove incorrect pagination on bigquery list groups --------- Co-authored-by: Bob van den Hoogen <[email protected]>
1 parent 8d85045 commit 1c28e50

File tree

12 files changed

+165
-4
lines changed

12 files changed

+165
-4
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Make sure to fill out the variables below in order to use the Snowflake example dbt project
2+
export SNOWFLAKE_USER=""
3+
export SNOWFLAKE_PASSWORD=""
4+
export SNOWFLAKE_ACCOUNT_NAME=""
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
target/
3+
dbt_packages/
4+
logs/
5+
.envrc
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
id: 3afbb3a6-c6f7-45c7-932a-c1cbf871a710
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# dbt x Snowflake
2+
3+
This example dbt project uses the Online Retail II dataset, which can be
4+
found [here](https://archive.ics.uci.edu/dataset/502/online+retail+ii).
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: 'dbt_snowflake_project'
2+
version: '1.0.0'
3+
config-version: 2
4+
5+
profile: 'dbt_snowflake_project'
6+
7+
model-paths: [ "models" ]
8+
analysis-paths: [ "analyses" ]
9+
test-paths: [ "tests" ]
10+
seed-paths: [ "seeds" ]
11+
macro-paths: [ "macros" ]
12+
snapshot-paths: [ "snapshots" ]
13+
14+
clean-targets: # directories to be removed by `dbt clean`
15+
- "target"
16+
- "dbt_packages"
17+
18+
models:
19+
+meta:
20+
pace_user_groups_table: stream-machine-development.user_groups.user_groups

dbt/src/main/dbt_snowflake_project/macros/.gitkeep

Whitespace-only changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{% macro generate_schema_name(custom_schema_name, node) -%}
2+
3+
{%- set default_schema = target.schema -%}
4+
{%- if custom_schema_name is none -%}
5+
6+
{{ default_schema }}
7+
8+
{%- else -%}
9+
10+
{{ custom_schema_name | trim }}
11+
12+
{%- endif -%}
13+
14+
{%- endmacro %}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{{
2+
config(
3+
materialized='table'
4+
)
5+
}}
6+
7+
select
8+
CUSTOMERID,
9+
DESCRIPTION,
10+
INVOICE,
11+
INVOICEDATE,
12+
PRICE,
13+
QUANTITY,
14+
STOCKCODE,
15+
COUNTRY
16+
from pace.online_retail.retail
17+
where year(invoicedate) = 2010
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{#
2+
This file was auto-generated by PACE. Do not edit this file directly.
3+
#}
4+
{{
5+
config(
6+
materialized='view',
7+
database='pace',
8+
schema='online_retail'
9+
)
10+
}}
11+
12+
select
13+
COUNTRY,
14+
case
15+
when (IS_ROLE_IN_SESSION('ACCOUNTADMIN')) then CUSTOMERID
16+
else null
17+
end CUSTOMERID,
18+
DESCRIPTION,
19+
INVOICE,
20+
INVOICEDATE,
21+
PRICE,
22+
QUANTITY,
23+
STOCKCODE
24+
from {{ ref('retail_2010') }}
25+
where case
26+
when (
27+
(IS_ROLE_IN_SESSION('ACCOUNTADMIN'))
28+
or (IS_ROLE_IN_SESSION('FRAUD_AND_RISK'))
29+
) then true
30+
else COUNTRY like 'Germany'
31+
end
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
version: 2
2+
3+
models:
4+
- name: retail_2010
5+
columns:
6+
- name: COUNTRY
7+
type: Varchar
8+
- name: CUSTOMERID
9+
type: Integer
10+
meta:
11+
pace:
12+
transforms:
13+
- principals: [ { group: ACCOUNTADMIN } ]
14+
identity: { }
15+
- principals: [ ]
16+
nullify: {}
17+
- name: DESCRIPTION
18+
type: Varchar
19+
- name: INVOICE
20+
type: Varchar
21+
- name: INVOICEDATE
22+
type: Timestamp
23+
- name: PRICE
24+
type: Number
25+
- name: QUANTITY
26+
type: Number
27+
- name: STOCKCODE
28+
type: Varchar
29+
meta:
30+
pace:
31+
rule_sets:
32+
- target:
33+
ref:
34+
integration_fqn: 'pace.online_retail.retail_2010_secured'
35+
filters:
36+
- generic_filter:
37+
conditions:
38+
- principals: [ { group: ACCOUNTADMIN }, { group: FRAUD_AND_RISK } ]
39+
condition: "true"
40+
- principals: [ ]
41+
condition: "COUNTRY like 'Germany'"

0 commit comments

Comments
 (0)