Skip to content

Commit

Permalink
add a dbt_pii project to start on the macro
Browse files Browse the repository at this point in the history
  • Loading branch information
akshaykarle committed Sep 13, 2024
1 parent 9223729 commit 1142895
Show file tree
Hide file tree
Showing 11 changed files with 1,254 additions and 0 deletions.
1 change: 1 addition & 0 deletions dbt_pii/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dbs/*.db
14 changes: 14 additions & 0 deletions dbt_pii/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# dbt pii

A dbt macro which detects pii.

## Getting Started

To get started, run the following:

```
poetry install
poetry run dbt seed --profiles-dir .
poetry run dbt run --profiles-dir .
sqlite3 dbs/main.db 'select * from main.pii_info;'
```
Empty file added dbt_pii/dbs/.gitkeep
Empty file.
33 changes: 33 additions & 0 deletions dbt_pii/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: 'dbt_pii'
version: '1.0.0'
config-version: 2

# This setting configures which "profile" dbt uses for this project.
profile: 'dbt_sqlite'

# These configurations specify where dbt should look for different types of files.
# The `source-paths` config, for example, states that models in this project can be
# found in the "models/" directory. You probably won't need to change these!
model-paths: ["models"]
analysis-paths: ["analysis"]
test-paths: ["tests"]
seed-paths: ["seeds"]
macro-paths: ["macros"]
snapshot-paths: ["snapshots"]
docs-paths: ["docs"]

target-path: "target" # directory which will store compiled SQL files
clean-targets: # directories to be removed by `dbt clean`
- "target"
- "dbt_modules"


# Configuring models
# Full documentation: https://docs.getdbt.com/docs/configuring-models

# In this example config, we tell dbt to build all models in the example/ directory
# as tables. These settings can be overridden in the individual model files
# using the `{{ config(...) }}` macro.
models:
pii:
+materialized: table
11 changes: 11 additions & 0 deletions dbt_pii/models/models.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2

models:
- name: pii_info
description: Fact table for orders including customer and cohort dimensions.
columns:
- name: id
- name: name
- name: city
- name: comments
- name: pii
7 changes: 7 additions & 0 deletions dbt_pii/models/pii_info.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
select
id,
name,
city,
comments,
"pii" as pii
from {{ ref('info') }}
14 changes: 14 additions & 0 deletions dbt_pii/models/sources.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2

sources:
- name: info
schema: info
loader: SQLite CLI
tables:
- name: info
description: Fact table for orders including customer and cohort dimensions.
columns:
- name: id
- name: name
- name: city
- name: comments
1,137 changes: 1,137 additions & 0 deletions dbt_pii/poetry.lock

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions dbt_pii/profiles.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# For more information on how to configure this file, please see:
# https://docs.getdbt.com/docs/profile
config:
send_anonymous_usage_stats: false
use_colors: true

dbt_sqlite:
target: dev
outputs:
dev:
type: sqlite
threads: 1
database: database
schema: main
schemas_and_paths:
main: "{{ env_var('PWD') }}/dbs/main.db"
schema_directory: "{{ env_var('PWD') }}/dbs"
16 changes: 16 additions & 0 deletions dbt_pii/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[tool.poetry]
name = "dbt-pii"
version = "0.1.0"
description = ""
authors = ["Your Name <[email protected]>"]
readme = "README.md"

[tool.poetry.dependencies]
python = ">=3.10,<3.12"
dbt = "^1.0.0.38.13"
dbt-sqlite = "^1.5.0"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
4 changes: 4 additions & 0 deletions dbt_pii/seeds/info.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
id,name,city,comments
1,Sowmya,New York,called him yesterday to confirm he requested to call back in 2 days
2,Jill,Los Angeles,accepted the offer license number AC432223
3,Jack,Chicago,need to call him at phone number 212-555-5555

0 comments on commit 1142895

Please sign in to comment.