Skip to content

Commit

Permalink
Merge pull request #23 from fivetran/MagicBot/dbt-utils-cross-db-migr…
Browse files Browse the repository at this point in the history
…ation

Updates for dbt-utils to dbt-core cross-db macro migration
  • Loading branch information
fivetran-joemarkiewicz authored Dec 21, 2022
2 parents cd6876e + 858d798 commit eea68e4
Show file tree
Hide file tree
Showing 19 changed files with 238 additions and 145 deletions.
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: ":databricks: 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
23 changes: 23 additions & 0 deletions .buildkite/scripts/run_models.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/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"
dbt run --vars '{ad_reporting__url_report__using_null_filter: false}' --target "$db" --full-refresh
dbt test --vars '{ad_reporting__url_report__using_null_filter: false}' --target "$db"
77 changes: 0 additions & 77 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
44 changes: 44 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,47 @@
# dbt_facebook_ads v0.6.0

## 🚨 Breaking Changes 🚨:
[PR #23](https://github.com/fivetran/dbt_facebook_ads/pull/23) includes the following breaking changes:
- Dispatch update for dbt-utils to dbt-core cross-db macros migration. Specifically `{{ dbt_utils.<macro> }}` have been updated to `{{ dbt.<macro> }}` for the below macros:
- `any_value`
- `bool_or`
- `cast_bool_to_text`
- `concat`
- `date_trunc`
- `dateadd`
- `datediff`
- `escape_single_quotes`
- `except`
- `hash`
- `intersect`
- `last_day`
- `length`
- `listagg`
- `position`
- `replace`
- `right`
- `safe_cast`
- `split_part`
- `string_literal`
- `type_bigint`
- `type_float`
- `type_int`
- `type_numeric`
- `type_string`
- `type_timestamp`
- `array_append`
- `array_concat`
- `array_construct`
- For `current_timestamp` and `current_timestamp_in_utc` macros, the dispatch AND the macro names have been updated to the below, respectively:
- `dbt.current_timestamp_backcompat`
- `dbt.current_timestamp_in_utc_backcompat`
- `packages.yml` has been updated to reflect new default `fivetran/fivetran_utils` version, previously `[">=0.3.0", "<0.4.0"]` now `[">=0.4.0", "<0.5.0"]`.

## 🎉 Features 🎉
- For use in the [dbt_ad_reporting package](https://github.com/fivetran/dbt_ad_reporting), users can now allow records having nulls in url fields to be included in the `ad_reporting__url_report` model. See the [dbt_ad_reporting README](https://github.com/fivetran/dbt_ad_reporting) for more details([#25](https://github.com/fivetran/dbt_facebook_ads/pull/25)).
## 🚘 Under the Hood 🚘
- Disabled the `not_null` test for `facebook_ads__url_report` when null urls are allowed ([#25](https://github.com/fivetran/dbt_facebook_ads/pull/25)).

# dbt_facebook_ads v0.5.0
## 🚨 Breaking Changes 🚨
The following changes come with PR [https://github.com/fivetran/dbt_facebook_ads/pull/21]:
Expand Down
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
href="https://github.com/fivetran/dbt_facebook_ads/blob/main/LICENSE">
<img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" /></a>
<a alt="dbt-core">
<img src="https://img.shields.io/badge/dbt_Core™_version->=1.0.0_,<2.0.0-orange.svg" /></a>
<img src="https://img.shields.io/badge/dbt_Core™_version->=1.3.0_,<2.0.0-orange.svg" /></a>
<a alt="Maintained?">
<img src="https://img.shields.io/badge/Maintained%3F-yes-green.svg" /></a>
<a alt="PRs">
Expand Down Expand Up @@ -59,7 +59,7 @@ Include the following facebook_ads package version in your `packages.yml` file:
```yaml
packages:
- package: fivetran/facebook_ads
version: [">=0.5.0", "<0.6.0"]
version: [">=0.6.0", "<0.7.0"]
```
## Step 3: Define database and schema variables
Expand Down Expand Up @@ -123,13 +123,16 @@ This dbt package is dependent on the following dbt packages. Please be aware tha
```yml
packages:
- package: fivetran/facebook_ads_source
version: [">=0.5.0", "<0.6.0"]
version: [">=0.6.0", "<0.7.0"]
- package: fivetran/fivetran_utils
version: [">=0.3.0", "<0.4.0"]
version: [">=0.4.0", "<0.5.0"]
- package: dbt-labs/dbt_utils
version: [">=0.8.0", "<0.9.0"]
version: [">=1.0.0", "<2.0.0"]
- package: dbt-labs/spark_utils
version: [">=0.3.0", "<0.4.0"]
```
# 🙌 How is this package maintained and can I contribute?
## Package Maintenance
Expand Down
5 changes: 2 additions & 3 deletions dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
name: 'facebook_ads'
version: '0.5.0'
version: '0.6.0'
config-version: 2
require-dbt-version: [">=1.0.0", "<2.0.0"]

require-dbt-version: [">=1.3.0", "<2.0.0"]
models:
facebook_ads:
+schema: facebook_ads
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 Facebook Ads 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: facebook_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: facebook_ads_integration_tests
threads: 8
spark:
type: spark
method: http
schema: facebook_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: facebook_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: facebook_ads_integration_tests
threads: 2
token: "{{ env_var('CI_DATABRICKS_DBT_TOKEN') }}"
type: databricks
Loading

0 comments on commit eea68e4

Please sign in to comment.