Skip to content

Commit

Permalink
feat: add dbt project from other repository
Browse files Browse the repository at this point in the history
  • Loading branch information
jaanli committed Apr 1, 2024
1 parent db4f409 commit 8a58ad2
Show file tree
Hide file tree
Showing 1,024 changed files with 2,061,061 additions and 1 deletion.
176 changes: 175 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,178 @@ dist/
docs/.observablehq/cache/
node_modules/
yarn-error.log
.vscode/
.vscode/

# Duckdb
*.duckdb
*.duckdb.tmp/
*.duckdb.wal

.gitkeep

# MacOS
.DS_Store

# Venv
.venv/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
4 changes: 4 additions & 0 deletions data_processing/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

target/
dbt_packages/
logs/
47 changes: 47 additions & 0 deletions data_processing/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Name your project! Project names should contain only lowercase characters
# and underscores. A good package name should reflect your organization's
# name or the intended use of these models
name: "american_community_survey"
version: "1.0.0"
config-version: 2

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

# Variables that can be changed from the command line using the `--vars` flag:
# example: dbt run --vars 'my_variable: my_value'
vars:
# The URL of the American Community Survey PUMS data
public_use_microdata_sample_url: "https://www2.census.gov/programs-surveys/acs/data/pums/2022/1-Year/"
public_use_microdata_sample_data_dictionary_url: "https://www2.census.gov/programs-surveys/acs/tech_docs/pums/data_dict/PUMS_Data_Dictionary_2022.csv"
microdata_area_shapefile_url: "https://www2.census.gov/geo/tiger/TIGER2010/PUMA5/2010/" # https://www2.census.gov/geo/tiger/TIGER2010/PUMA5/2010/ # https://www2.census.gov/geo/tiger/TIGER2020/PUMA20/
output_path: "~/data/american_community_survey"

# These configurations specify where dbt should look for different types of files.
# The `model-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: ["analyses"]
test-paths: ["tests"]
seed-paths: ["seeds"]
macro-paths: ["macros"]
snapshot-paths: ["snapshots"]

clean-targets: # directories to be removed by `dbt clean`
- "target"
- "dbt_packages"

# 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 views. These settings can be overridden in the individual model
# files using the `{{ config(...) }}` macro.
models:
american_community_survey:
# Config indicated by + and applies to all files under models/example/
# example:
+materialized: view
public_use_microdata_sample:
generated:
+tags: "generated"
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% macro generate_industry_mapping_2003_onwards_sql(input_field) %}
{% set industry_mappings = get_industry_mappings_2003_onwards() %}

CASE {{ input_field }}
{% for code, description in industry_mappings.items() %}
WHEN '{{ code }}' THEN '{{ description }}'
{% endfor %}
END::ENUM ({% for description in industry_mappings.values() | unique %}'{{ description }}'{{ "," if not loop.last }}{% endfor %})
{% endmacro %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% macro generate_industry_mapping_before_2003_sql(input_field) %}
{% set industry_mappings = get_industry_mappings_before_2003() %}

CASE {{ input_field }}
{% for code, description in industry_mappings.items() %}
WHEN '{{ code }}' THEN '{{ description }}'
{% endfor %}
END::ENUM ({% for description in industry_mappings.values() | unique %}'{{ description }}'{{ "," if not loop.last }}{% endfor %})
{% endmacro %}
Loading

0 comments on commit 8a58ad2

Please sign in to comment.