Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/match type report adjustments #23

Merged
merged 7 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
24 changes: 24 additions & 0 deletions .buildkite/hooks/pre-command
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

set -e

# Export secrets for Docker containers.
# Restrict exposing secrets only to the steps that need them
export GCLOUD_SERVICE_KEY=$(gcloud secrets versions access latest --secret="GCLOUD_SERVICE_KEY" --project="dbt-package-testing-363917")
export CI_POSTGRES_DBT_HOST=$(gcloud secrets versions access latest --secret="CI_POSTGRES_DBT_HOST" --project="dbt-package-testing-363917")
export CI_POSTGRES_DBT_USER=$(gcloud secrets versions access latest --secret="CI_POSTGRES_DBT_USER" --project="dbt-package-testing-363917")
export CI_POSTGRES_DBT_PASS=$(gcloud secrets versions access latest --secret="CI_POSTGRES_DBT_PASS" --project="dbt-package-testing-363917")
export CI_POSTGRES_DBT_DBNAME=$(gcloud secrets versions access latest --secret="CI_POSTGRES_DBT_DBNAME" --project="dbt-package-testing-363917")
export CI_REDSHIFT_DBT_DBNAME=$(gcloud secrets versions access latest --secret="CI_REDSHIFT_DBT_DBNAME" --project="dbt-package-testing-363917")
export CI_REDSHIFT_DBT_HOST=$(gcloud secrets versions access latest --secret="CI_REDSHIFT_DBT_HOST" --project="dbt-package-testing-363917")
export CI_REDSHIFT_DBT_PASS=$(gcloud secrets versions access latest --secret="CI_REDSHIFT_DBT_PASS" --project="dbt-package-testing-363917")
export CI_REDSHIFT_DBT_USER=$(gcloud secrets versions access latest --secret="CI_REDSHIFT_DBT_USER" --project="dbt-package-testing-363917")
export CI_SNOWFLAKE_DBT_ACCOUNT=$(gcloud secrets versions access latest --secret="CI_SNOWFLAKE_DBT_ACCOUNT" --project="dbt-package-testing-363917")
export CI_SNOWFLAKE_DBT_DATABASE=$(gcloud secrets versions access latest --secret="CI_SNOWFLAKE_DBT_DATABASE" --project="dbt-package-testing-363917")
export CI_SNOWFLAKE_DBT_PASS=$(gcloud secrets versions access latest --secret="CI_SNOWFLAKE_DBT_PASS" --project="dbt-package-testing-363917")
export CI_SNOWFLAKE_DBT_ROLE=$(gcloud secrets versions access latest --secret="CI_SNOWFLAKE_DBT_ROLE" --project="dbt-package-testing-363917")
export CI_SNOWFLAKE_DBT_USER=$(gcloud secrets versions access latest --secret="CI_SNOWFLAKE_DBT_USER" --project="dbt-package-testing-363917")
export CI_SNOWFLAKE_DBT_WAREHOUSE=$(gcloud secrets versions access latest --secret="CI_SNOWFLAKE_DBT_WAREHOUSE" --project="dbt-package-testing-363917")
export CI_DATABRICKS_DBT_HOST=$(gcloud secrets versions access latest --secret="CI_DATABRICKS_DBT_HOST" --project="dbt-package-testing-363917")
export CI_DATABRICKS_DBT_HTTP_PATH=$(gcloud secrets versions access latest --secret="CI_DATABRICKS_DBT_HTTP_PATH" --project="dbt-package-testing-363917")
export CI_DATABRICKS_DBT_TOKEN=$(gcloud secrets versions access latest --secret="CI_DATABRICKS_DBT_TOKEN" --project="dbt-package-testing-363917")
73 changes: 73 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
steps:
- label: ":postgres: Run Tests - Postgres"
key: "run-dbt-postgres"
plugins:
- docker#v3.13.0:
image: "python:3.8"
shell: [ "/bin/bash", "-e", "-c" ]
environment:
- "BASH_ENV=/tmp/.bashrc"
- "CI_POSTGRES_DBT_DBNAME"
- "CI_POSTGRES_DBT_HOST"
- "CI_POSTGRES_DBT_PASS"
- "CI_POSTGRES_DBT_USER"
commands: |
bash .buildkite/scripts/run_models.sh postgres

- label: ":snowflake-db: Run Tests - Snowflake"
key: "run_dbt_snowflake"
plugins:
- docker#v3.13.0:
image: "python:3.8"
shell: [ "/bin/bash", "-e", "-c" ]
environment:
- "BASH_ENV=/tmp/.bashrc"
- "CI_SNOWFLAKE_DBT_ACCOUNT"
- "CI_SNOWFLAKE_DBT_DATABASE"
- "CI_SNOWFLAKE_DBT_PASS"
- "CI_SNOWFLAKE_DBT_ROLE"
- "CI_SNOWFLAKE_DBT_USER"
- "CI_SNOWFLAKE_DBT_WAREHOUSE"
commands: |
bash .buildkite/scripts/run_models.sh snowflake

- label: ":gcloud: Run Tests - BigQuery"
key: "run_dbt_bigquery"
plugins:
- docker#v3.13.0:
image: "python:3.8"
shell: [ "/bin/bash", "-e", "-c" ]
environment:
- "BASH_ENV=/tmp/.bashrc"
- "GCLOUD_SERVICE_KEY"
commands: |
bash .buildkite/scripts/run_models.sh bigquery

- label: ":amazon-redshift: Run Tests - Redshift"
key: "run_dbt_redshift"
plugins:
- docker#v3.13.0:
image: "python:3.8"
shell: [ "/bin/bash", "-e", "-c" ]
environment:
- "BASH_ENV=/tmp/.bashrc"
- "CI_REDSHIFT_DBT_DBNAME"
- "CI_REDSHIFT_DBT_HOST"
- "CI_REDSHIFT_DBT_PASS"
- "CI_REDSHIFT_DBT_USER"
commands: |
bash .buildkite/scripts/run_models.sh redshift

- label: ":bricks: Run Tests - Databricks"
key: "run_dbt_databricks"
plugins:
- docker#v3.13.0:
image: "python:3.8"
shell: [ "/bin/bash", "-e", "-c" ]
environment:
- "BASH_ENV=/tmp/.bashrc"
- "CI_DATABRICKS_DBT_HOST"
- "CI_DATABRICKS_DBT_HTTP_PATH"
- "CI_DATABRICKS_DBT_TOKEN"
commands: |
bash .buildkite/scripts/run_models.sh databricks
21 changes: 21 additions & 0 deletions .buildkite/scripts/run_models.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

set -euo pipefail

apt-get update
apt-get install libsasl2-dev

python3 -m venv venv
. venv/bin/activate
pip install --upgrade pip setuptools
pip install -r integration_tests/requirements.txt
mkdir -p ~/.dbt
cp integration_tests/ci/sample.profiles.yml ~/.dbt/profiles.yml

db=$1
echo `pwd`
cd integration_tests
dbt deps
dbt seed --target "$db" --full-refresh
dbt run --target "$db" --full-refresh
dbt test --target "$db"
87 changes: 0 additions & 87 deletions .circleci/config.yml

This file was deleted.

5 changes: 2 additions & 3 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
Pull Request
**Are you a current Fivetran customer?**
<!--- Please tell us your name, title and company -->

Expand Down Expand Up @@ -29,9 +28,9 @@ Pull Request

**How did you test the PR changes?**
<!--- Proof of testing is required in order for the PR to be approved. -->
<!--- To check a box, remove the space and insert an x in the box (eg. [x] CircleCi). -->
<!--- To check a box, remove the space and insert an x in the box (eg. [x] BuildKite). -->
<!--- To select a checkbox you simply need to add an "x" with no spaces between the brackets (eg. [x] Yes). -->
- [ ] CircleCi <!--- CircleCi testing is only applicable to Fivetran employees. -->
- [ ] BuildKite <!--- BuildKite testing is only applicable to Fivetran employees. -->
- [ ] Local (please provide additional testing details below)

**Select which warehouse(s) were used to test the PR**
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# dbt_microsoft_ads v0.5.2

## 🪳 Bugfix 🪳
[PR #23](https://github.com/fivetran/dbt_microsoft_ads/pull/23) includes the following bug fixes:
- In each end model, `*_id` fields are explicitly selected from the left side of the join, reports, rather than from entity (i.e. keywords) history tables. This is necessary as Microsoft **hard-deletes** records from history tables, and therefore, daily report fields may have `*_id` values that do not exist in history tables. ([#63](https://github.com/fivetran/dbt_ad_reporting/issues/63)).
- Includes the `match_type` field in the uniqueness test on the `microsoft_ads__search_report` model ([#64](https://github.com/fivetran/dbt_ad_reporting/issues/64)).

## Contributors:
- @clay-walker - Thank you for opening and providing information on issues [#63](https://github.com/fivetran/dbt_ad_reporting/issues/63) and [#64](https://github.com/fivetran/dbt_ad_reporting/issues/64)! 🎉
# dbt_microsoft_ads v0.5.1

## 🪳Bugfix🪳
Expand Down
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'microsoft_ads'
version: '0.5.1'
version: '0.5.2'
config-version: 2
require-dbt-version: [">=1.0.0", "<2.0.0"]

Expand Down
2 changes: 1 addition & 1 deletion docs/catalog.json

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions docs/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/manifest.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/run_results.json

Large diffs are not rendered by default.

34 changes: 14 additions & 20 deletions integration_tests/ci/sample.profiles.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

# HEY! This file is used in the Microsoft integrations tests with CircleCI.
# HEY! This file is used in the dbt package integrations tests with Buildkite.
# You should __NEVER__ check credentials into version control. Thanks for reading :)

config:
send_anonymous_usage_stats: False
use_colors: True

integration_tests:
target: snowflake
target: redshift
outputs:
redshift:
type: redshift
Expand All @@ -20,11 +20,11 @@ integration_tests:
threads: 8
bigquery:
type: bigquery
method: service-account
keyfile: "{{ env_var('GCLOUD_SERVICE_KEY_PATH') }}"
method: service-account-json
project: 'dbt-package-testing'
schema: microsoft_ads_integration_tests
threads: 8
keyfile_json: "{{ env_var('GCLOUD_SERVICE_KEY') | as_native }}"
snowflake:
type: snowflake
account: "{{ env_var('CI_SNOWFLAKE_DBT_ACCOUNT') }}"
Expand All @@ -35,26 +35,20 @@ integration_tests:
warehouse: "{{ env_var('CI_SNOWFLAKE_DBT_WAREHOUSE') }}"
schema: microsoft_ads_integration_tests
threads: 8
spark:
type: spark
method: http
schema: microsoft_ads_integration_tests
host: "{{ env_var('CI_SPARK_DBT_HOST') }}"
organization: "{{ env_var('CI_SPARK_DBT_ORGANIZATION') }}"
token: "{{ env_var('CI_SPARK_DBT_TOKEN') }}"
cluster: "{{ env_var('CI_SPARK_DBT_CLUSTER') }}"
port: 443
connect_timeout: 60
connect_retries: 5
threads: 4
postgres:
type: postgres
host: "{{ env_var('CI_POSTGRES_DBT_HOST') }}"
user: "{{ env_var('CI_POSTGRES_DBT_USER') }}"
password: "{{ env_var('CI_POSTGRES_DBT_PASS') }}"
pass: "{{ env_var('CI_POSTGRES_DBT_PASS') }}"
dbname: "{{ env_var('CI_POSTGRES_DBT_DBNAME') }}"
port: 5432
dbname: "{{ env_var('CI_POSTGRES_DBT_DATABASE') }}"
schema: microsoft_ads_integration_tests
threads: 8
keepalives_idle: 0
sslmode: prefer
databricks:
catalog: null
host: "{{ env_var('CI_DATABRICKS_DBT_HOST') }}"
http_path: "{{ env_var('CI_DATABRICKS_DBT_HTTP_PATH') }}"
schema: microsoft_ads_integration_tests
threads: 2
token: "{{ env_var('CI_DATABRICKS_DBT_TOKEN') }}"
type: databricks
2 changes: 1 addition & 1 deletion integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'microsoft_ads_integration_tests'
version: '0.5.1'
version: '0.5.2'
profile: 'integration_tests'
config-version: 2

Expand Down
13 changes: 7 additions & 6 deletions integration_tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
dbt-snowflake~=1.0.0
dbt-bigquery~=1.0.0
dbt-redshift~=1.0.0
dbt-postgres~=1.0.0
dbt-spark~=1.0.0
dbt-spark[PyHive]~=1.0.0
dbt-snowflake>=1.0.0,<1.3.0
dbt-bigquery>=1.0.0,<1.3.0
dbt-redshift>=1.0.0,<1.3.0
dbt-postgres>=1.0.0,<1.3.0
dbt-spark>=1.0.0,<1.3.0
dbt-spark[PyHive]>=1.0.0,<1.3.0
dbt-databricks>=1.0.0,<1.3.0
1 change: 1 addition & 0 deletions models/microsoft_ads.yml
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ models:
- device_os
- device_type
- network
- match_type
columns:
- name: date_day
description: '{{ doc("date_day") }}'
Expand Down
2 changes: 1 addition & 1 deletion models/microsoft_ads__account_report.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ accounts as (
select
date_day,
accounts.account_name,
accounts.account_id,
report.account_id,
accounts.time_zone as account_timezone,
report.device_os,
report.device_type,
Expand Down
6 changes: 3 additions & 3 deletions models/microsoft_ads__ad_group_report.sql
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ joined as (
select
date_day,
accounts.account_name,
accounts.account_id,
report.account_id,
campaigns.campaign_name,
campaigns.campaign_id,
report.campaign_id,
ad_groups.ad_group_name,
ad_groups.ad_group_id,
report.ad_group_id,
report.device_os,
report.device_type,
report.network,
Expand Down
8 changes: 4 additions & 4 deletions models/microsoft_ads__ad_report.sql
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ joined as (
select
report.date_day,
accounts.account_name,
accounts.account_id,
report.account_id,
campaigns.campaign_name,
campaigns.campaign_id,
report.campaign_id,
ad_groups.ad_group_name,
ad_groups.ad_group_id,
report.ad_group_id,
ads.ad_name,
ads.ad_id,
report.ad_id,
ads.type as ad_type,
report.device_os,
report.device_type,
Expand Down
Loading