Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
d7d8d2e
Add dbt profiles setting and piperider config setting
wcchang1115 Dec 5, 2022
3cc91ca
Merge pull request #1 from InfuseAI/feature/piperider-ci-setup
wcchang1115 Dec 9, 2022
6a1d673
Add production and pr workflows for ci
wcchang1115 Dec 9, 2022
a2d4a39
Merge pull request #2 from InfuseAI/feature/basic-ci-setup
wcchang1115 Dec 9, 2022
d17535f
Update dbt profile type
wcchang1115 Dec 9, 2022
ba1f793
Merge pull request #3 from InfuseAI/feature/piperider-ci-setup
wcchang1115 Dec 9, 2022
22789fb
Add production and pr workflows for slim ci
wcchang1115 Dec 10, 2022
c8b2590
Merge pull request #4 from InfuseAI/feature/advanced-ci-setup
wcchang1115 Dec 10, 2022
41f8ddf
Update slim ci production job
wcchang1115 Dec 10, 2022
2f619a3
Merge pull request #5 from InfuseAI/feature/advanced-ci-setup
wcchang1115 Dec 10, 2022
dec661e
Post comparison summary to the PR comment
wcchang1115 Dec 20, 2022
58acdc3
Merge pull request #6 from InfuseAI/feature/post-comparison-summary-o…
wcchang1115 Dec 20, 2022
925ef92
Update the slim CI workflow with piperider cloud command
wcchang1115 Dec 23, 2022
470428c
Update piperider installation
wcchang1115 Dec 23, 2022
4e33d4a
Merge pull request #8 from InfuseAI/chore/update-cloud-compare-reort-…
wcchang1115 Dec 29, 2022
af65fe8
Add business metrics
wcchang1115 Jan 5, 2023
da24bbb
Update CI workflow with piperider cli v0.20.0 command
wcchang1115 Mar 8, 2023
fd688b2
Merge pull request #11 from InfuseAI/chore/update-piperider-cloud-cli…
wcchang1115 Mar 8, 2023
64757d7
Update login option and run option for slim CI
wcchang1115 Mar 31, 2023
199c959
Merge pull request #12 from InfuseAI/chore/update-piperider-login-option
wcchang1115 Mar 31, 2023
d0394aa
Merge pull request #10 from InfuseAI/feature/add-metrics
popcornylu Mar 31, 2023
6632c58
Change the piperider config
popcornylu Mar 31, 2023
ccd6e67
Update workflows dbt profile target name
wcchang1115 Apr 5, 2023
49a920a
Merge pull request #13 from InfuseAI/chore/update-workflow-dbt-profil…
wcchang1115 Apr 5, 2023
456c704
Use duckdb by default
popcornylu Apr 17, 2023
24e0023
Merge pull request #14 from InfuseAI/feature/use-duckdb
popcornylu Apr 17, 2023
fc58803
Add workflow for pr review
popcornylu Apr 17, 2023
37e7e36
Merge pull request #15 from InfuseAI/feature/pr-workflow-by-compare-a…
popcornylu Apr 17, 2023
48cc1d2
upload compare to cloud
popcornylu Apr 20, 2023
0c13f2f
Merge pull request #18 from InfuseAI/feature/sc-31094/upload-compare-…
popcornylu Apr 20, 2023
602c913
Add dbt version restriction
wcchang1115 Aug 3, 2023
1c97ecb
Merge pull request #27 from InfuseAI/chore/update-dbt-version-restric…
wcchang1115 Aug 3, 2023
5e5d0f8
Rewrite dbt metrics to semantic layer form
wcchang1115 Aug 23, 2023
e74e9f9
Remove piperider tag
popcornylu Sep 5, 2023
efdff1e
Bump dbt to 1.6+
popcornylu Sep 5, 2023
f17a6ee
Merge pull request #28 from InfuseAI/feature/dbt-16
popcornylu Sep 5, 2023
40d0988
Fix piperider conifg
popcornylu Sep 5, 2023
7ceefc5
Source migration
popcornylu Jun 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/pr-compare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: PR Compare
on:
pull_request:
types: [opened, synchronize, reopened]
branches: ['main']
paths:
- models/**
- seeds/**
- tests/**

jobs:
piperider-compare:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v3

- name: PipeRider Compare
uses: InfuseAI/piperider-compare-action@v1
with:
cloud_api_token: ${{ secrets.PIPERIDER_CLOUD_TOKEN_ID }}
cloud_project: ${{ secrets.PIPERIDER_API_PROJECT }}
upload: true
share: true
81 changes: 81 additions & 0 deletions .github/workflows/pr-comparison-job-slim-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: PR Transformation and Comparison (Slim CI)

on:
pull_request:
types: [opened, synchronize, reopened]
# Trigger when PR is created and/or head of branch is updated.
branches: [ "main" ]
# Only PR target is `main`
paths:
- models/**
- seeds/**
- tests/**

env:
SNOWFLAKE_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }}
SNOWFLAKE_USER: ${{ secrets.SNOWFLAKE_USER }}
SNOWFLAKE_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }}
SNOWFLAKE_ROLE: ${{ secrets.SNOWFLAKE_ROLE }}
SNOWFLAKE_DATABASE: ${{ secrets.SNOWFLAKE_DATABASE }}
SNOWFLAKE_WAREHOUSE: ${{ secrets.SNOWFLAKE_WAREHOUSE }}
SNOWFLAKE_SCHEMA: ${{ secrets.SNOWFLAKE_SCHEMA }}
DBT_CLOUD_API_TOKEN: ${{ secrets.DBT_CLOUD_API_TOKEN }}
DBT_CLOUD_ACCOUNT_ID: ${{ secrets.DBT_CLOUD_ACCOUNT_ID }}
DBT_CLOUD_JOB_ID: 173664
PIPERIDER_CLOUD_TOKEN_ID: ${{ secrets.PIPERIDER_CLOUD_TOKEN_ID }}
PIPERIDER_CLOUD_PROJECT_ID: ${{ secrets.PIPERIDER_CLOUD_PROJECT_ID }}
PIPERIDER_API_PROJECT: ${{ secrets.PIPERIDER_API_PROJECT }}

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Setup Piperider
run: |
pip install dbt-cloud-cli
pip install dbt-snowflake
pip install 'piperider-nightly[snowflake]'

- name: Trigger DBT Cloud Job (PR Job)
run: |
dbt-cloud job run \
--cause "GitHub PR Job" \
--git-branch ${{ github.head_ref }} \
--schema-override ${SNOWFLAKE_SCHEMA} \
--wait \
--file response.json
echo "run_id=$(cat response.json | jq -r '.data.id')" >> $GITHUB_ENV

- name: Piperider Cloud Login
run: piperider cloud login --token $PIPERIDER_CLOUD_TOKEN_ID --no-interaction

- name: Profile on PR environment
run: |
mkdir -p state/pr
dbt-cloud run get-artifact --run-id ${{ env.run_id }} --path manifest.json -f state/pr/manifest.json
dbt-cloud run get-artifact --run-id ${{ env.run_id }} --path run_results.json -f state/pr/run_results.json
piperider run --datasource jaffle_shop_pr --dbt-state state/pr --dbt-run-results -o /tmp/pipe-target
piperider cloud upload-report --run .piperider/outputs/latest/run.json

- name: Generate Comparison Summary
run: |
piperider cloud compare-reports \
--base datasource:jaffle_shop \
--target datasource:jaffle_shop_pr \
--summary-file summary.md \
--tables-from target-only

- name: Create PR Comment
uses: peter-evans/create-or-update-comment@v2.1.0
with:
issue-number: ${{ github.event.number }}
body-file: summary.md

74 changes: 74 additions & 0 deletions .github/workflows/pr-comparison-job.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: PR Transformation and Comparison
on:
pull_request:
types: [opened, synchronize, reopened]
branches: ['main']
paths:
- models/**
- seeds/**
- tests/**

env:
SNOWFLAKE_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }}
SNOWFLAKE_USER: ${{ secrets.SNOWFLAKE_USER }}
SNOWFLAKE_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }}
SNOWFLAKE_ROLE: ${{ secrets.SNOWFLAKE_ROLE }}
SNOWFLAKE_DATABASE: ${{ secrets.SNOWFLAKE_DATABASE }}
SNOWFLAKE_WAREHOUSE: ${{ secrets.SNOWFLAKE_WAREHOUSE }}
SNOWFLAKE_SCHEMA: ${{ secrets.SNOWFLAKE_SCHEMA }}

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Setup DBT + Piperider
run: |
pip install dbt-snowflake
pip install piperider['snowflake']

- name: Run DBT on PR environment
run: dbt build --target jaffle_shop_pr

- name: Profile on PR environment
run: piperider run --datasource jaffle_shop_pr --dbt-state target -o /tmp/pr-report/

- name: Profile on PROD environment
run: piperider run --datasource jaffle_shop -o /tmp/prod-report/

- name: Compare and Prepare
run: |
piperider compare-reports \
--debug \
--base /tmp/prod-report/run.json \
--target /tmp/pr-report/run.json \
--output comparison-report/ \
--tables-from target-only
zip -r comparison-report.zip comparison-report/

- uses: actions/upload-artifact@v3
with:
name: comparison-report-artifact
path: comparison-report.zip

- name: Prepare Comparison Summary
run: |
echo "# :bar_chart: Piperider Comparison Summary" > summary.md
cat comparison-report/summary.md >> summary.md
echo -e "\n" >> summary.md
echo "## :paperclip: Generated Comparison Report ZIP" >> summary.md
echo "Find it in the [Github Action Runs Page](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" >> summary.md

- name: Create PR Comment
uses: peter-evans/create-or-update-comment@v2.1.0
with:
issue-number: ${{ github.event.number }}
body-file: summary.md

69 changes: 69 additions & 0 deletions .github/workflows/production-daily-job-slim-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Daily Production Transformation (Slim CI)
on:
schedule:
- cron: '0 18 * * *' # run at 2 AM (UTC + 8) every day
workflow_dispatch:
pull_request:
types:
- closed
branches: ['main']
paths:
- models/**
- seeds/**
- tests/**

env:
SNOWFLAKE_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }}
SNOWFLAKE_USER: ${{ secrets.SNOWFLAKE_USER }}
SNOWFLAKE_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }}
SNOWFLAKE_ROLE: ${{ secrets.SNOWFLAKE_ROLE }}
SNOWFLAKE_DATABASE: ${{ secrets.SNOWFLAKE_DATABASE }}
SNOWFLAKE_WAREHOUSE: ${{ secrets.SNOWFLAKE_WAREHOUSE }}
DBT_CLOUD_API_TOKEN: ${{ secrets.DBT_CLOUD_API_TOKEN }}
DBT_CLOUD_ACCOUNT_ID: ${{ secrets.DBT_CLOUD_ACCOUNT_ID }}
DBT_CLOUD_JOB_ID: 173663
PIPERIDER_CLOUD_TOKEN_ID: ${{ secrets.PIPERIDER_CLOUD_TOKEN_ID }}
PIPERIDER_API_PROJECT: ${{ secrets. PIPERIDER_API_PROJECT }}

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Setup DBT + Piperider
run: |
pip install dbt-cloud-cli
pip install dbt-snowflake
pip install piperider['snowflake']

- name: Run DBT on PROD environment
run: |
dbt-cloud job run --wait --file response.json
echo "run_id=$(cat response.json | jq -r '.data.id')" >> $GITHUB_ENV

- name: Piperider Cloud Login
run: piperider cloud login --token $PIPERIDER_CLOUD_TOKEN_ID --no-interaction

- name: Profile on PROD environment
run: |
mkdir -p state/prod
dbt-cloud run get-artifact --run-id ${{ env.run_id }} --path manifest.json -f state/prod/manifest.json
dbt-cloud run get-artifact --run-id ${{ env.run_id }} --path run_results.json -f state/prod/run_results.json
piperider run --datasource jaffle_shop --dbt-state state/prod -o report/
piperider cloud upload-report --run .piperider/outputs/latest/run.json

- name: Create run artifact
run: zip -r run-report.zip report/

- name: Upload profiling result
uses: actions/upload-artifact@v3
with:
name: run-report-artifact
path: run-report.zip
54 changes: 54 additions & 0 deletions .github/workflows/production-daily-job.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Daily Production Transformation
on:
schedule:
- cron: '0 18 * * *' # run at 2 AM (UTC + 8) every day
workflow_dispatch:
pull_request:
types:
- closed
branches: ['main']
paths:
- models/**
- seeds/**
- tests/**

env:
SNOWFLAKE_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }}
SNOWFLAKE_USER: ${{ secrets.SNOWFLAKE_USER }}
SNOWFLAKE_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }}
SNOWFLAKE_ROLE: ${{ secrets.SNOWFLAKE_ROLE }}
SNOWFLAKE_DATABASE: ${{ secrets.SNOWFLAKE_DATABASE }}
SNOWFLAKE_WAREHOUSE: ${{ secrets.SNOWFLAKE_WAREHOUSE }}

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Setup DBT + Piperider
run: |
pip install dbt-snowflake
pip install piperider['snowflake']

- name: Run DBT on PROD environment
run: dbt build --target jaffle_shop

- name: Profile on PROD environment
run: piperider run --datasource jaffle_shop --dbt-state target -o report/

- name: Create run artifact
run: zip -r run-report.zip report/

- name: Upload profiling result
uses: actions/upload-artifact@v3
with:
name: run-report-artifact
path: run-report.zip

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
target/
dbt_modules/
logs/
venv/
**/.DS_Store
*.duckdb

8 changes: 8 additions & 0 deletions .piperider/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
**.log
__pycache__/
logs/
outputs/
reports/
comparisons/
credentials.yml
.unsend_events.json
15 changes: 15 additions & 0 deletions .piperider/compare/default.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
base:
branch: main
dbt:
commands:
- dbt deps
- dbt build
piperider:
command: piperider run
target:
dbt:
commands:
- dbt deps
- dbt build
piperider:
command: piperider run
6 changes: 6 additions & 0 deletions .piperider/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dataSources: []
dbt:
projectDir: .

telemetry:
id: 2e470b721f5a4114aa7cf9b73eca760d
3 changes: 2 additions & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ require-dbt-version: [">=1.0.0", "<2.0.0"]
models:
jaffle_shop:
materialized: table
staging:
+tags: piperider
staging:
materialized: view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ customer_payments as (

select
orders.customer_id,
sum(amount) as total_amount
sum(amount)::bigint as total_amount

from payments

Expand Down
4 changes: 2 additions & 2 deletions models/orders.sql → models/int_order_payments_pivoted.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ order_payments as (
order_id,

{% for payment_method in payment_methods -%}
sum(case when payment_method = '{{ payment_method }}' then amount else 0 end) as {{ payment_method }}_amount,
sum(case when payment_method = '{{ payment_method }}' then amount else 0 end)::bigint as {{ payment_method }}_amount,
{% endfor -%}

sum(amount) as total_amount
sum(amount)::bigint as total_amount

from payments

Expand Down
File renamed without changes.
Loading