diff --git a/.circleci/config.yml b/.circleci/config.yml
index 3328605..1ae439f 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -16,12 +16,24 @@ jobs:
- run:
name: "Setup dbt"
command: |
+ sudo apt 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
+ # - run:
+ # name: "Run Tests - Spark"
+ # command: |
+ # . venv/bin/activate
+ # echo `pwd`
+ # cd integration_tests
+ # dbt deps
+ # dbt seed --target spark --full-refresh
+ # dbt run --target spark --full-refresh
+ # dbt test --target spark
+ # no_output_timeout: 10m
- run:
name: "Run Tests - Redshift"
command: |
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
new file mode 100644
index 0000000..c36e4fe
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,62 @@
+---
+name: Bug report
+about: Create a report to help us improve
+title: BUG - [your bug title here]
+labels: bug
+assignees: ''
+
+---
+
+**Are you a current Fivetran customer?**
+
+
+
+**Describe the bug**
+
+
+**Steps to reproduce**
+1. Go to '...'
+2. Click on '....'
+3. Scroll down to '....'
+4. See error
+
+**Expected behavior**
+
+
+**Project variables configuration**
+
+```yml
+copy dbt_project.yml here
+```
+
+**Package Version**
+
+```yml
+copy packages.yml here
+```
+
+**Warehouse**
+
+
+- [ ] BigQuery
+- [ ] Redshift
+- [ ] Snowflake
+- [ ] Postgres
+- [ ] Databricks
+- [ ] Other (provide details below)
+
+**Additional context**
+
+
+**Screenshots**
+
+
+**Please indicate the level of urgency**
+
+
+**Are you interested in contributing to this package?**
+
+- [ ] Yes, I can do this and open a PR for your review.
+- [ ] Possibly, but I'm not quite sure how to do this. I'd be happy to do a live coding session with someone to get this fixed.
+- [ ] No, I'd prefer if someone else fixed this. I don't have the time and/or don't know what the root cause of the problem is.
+
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
new file mode 100644
index 0000000..ad1df3f
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -0,0 +1,32 @@
+---
+name: Feature request
+about: Suggest an idea for this project
+title: FEATURE - [your feature request title here]
+labels: enhancement
+assignees: ''
+
+---
+
+**Are you a Fivetran customer?**
+
+
+**Is your feature request related to a problem? Please describe.**
+
+
+**Describe the solution you'd like**
+
+
+**Describe alternatives you've considered**
+
+
+**Additional context**
+
+
+**Please indicate the level of urgency and business impact of this request**
+
+
+**Are you interested in contributing to this package?**
+
+- [ ] Yes, I can do this and open a PR for your review.
+- [ ] Possibly, but I'm not quite sure how to do this. I'd be happy to do a live coding session with someone to get this work implemented.
+- [ ] No, I'd prefer if someone else did this. I don't have the time and/or don't know how to incorporate the changes necessary.
diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md
new file mode 100644
index 0000000..2bd3b25
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/question.md
@@ -0,0 +1,20 @@
+---
+name: Question
+about: Confused about how to use the package? Ask us a question
+title: QUESTION - [your question title here]
+labels: question
+assignees: ''
+
+---
+
+**Are you a Fivetran customer?**
+
+
+**Your Question**
+
+
+**Additional context**
+
+
+**Please indicate the level of urgency and business impact of this request**
+
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
new file mode 100644
index 0000000..1d9bae8
--- /dev/null
+++ b/.github/pull_request_template.md
@@ -0,0 +1,40 @@
+**Are you a current Fivetran customer?**
+
+
+**What change(s) does this PR introduce?**
+
+
+**Does this PR introduce a breaking change?**
+
+
+- [ ] Yes (please provide breaking change details below.)
+- [ ] No (please provide explanation how the change is non breaking below.)
+
+**Is this PR in response to a previously created Issue**
+
+
+- [ ] Yes, Issue [link issue number here]
+- [ ] No
+
+**How did you test the PR changes?**
+
+
+- [ ] CircleCi
+- [ ] Other (please provide additional testing details below)
+
+**Select which warehouse(s) were used to test the PR**
+
+- [ ] BigQuery
+- [ ] Redshift
+- [ ] Snowflake
+- [ ] Postgres
+- [ ] Databricks
+- [ ] Other (provide details below)
+
+**Provide an emoji that best describes your current mood**
+
+:dancer:
+
+**Feedback**
+
+We are so excited you decided to contribute to the Fivetran community dbt package! We continue to work to improve the packages and would greatly appreciate your [feedback](https://www.surveymonkey.com/r/DQ7K7WW) on our existing dbt packages or what you'd like to see next.
diff --git a/dbt_project.yml b/dbt_project.yml
index c612268..4076bcf 100644
--- a/dbt_project.yml
+++ b/dbt_project.yml
@@ -12,15 +12,47 @@ vars:
integration: "{{ ref( 'stg_klaviyo__integration') }}"
person: "{{ ref( 'stg_klaviyo__person') }}"
metric: "{{ ref( 'stg_klaviyo__metric') }}"
-
+
+ klaviyo__email_attribution_lookback: 120 # in hours - 5 days -> https://help.klaviyo.com/hc/en-us/articles/115005248128#conversion-tracking1
+ klaviyo__sms_attribution_lookback: 24 # in hours -> https://help.klaviyo.com/hc/en-us/articles/115005248128#sms-conversion-tracking7
+
+ klaviyo__eligible_attribution_events: # default in klaviyo -> https://help.klaviyo.com/hc/en-us/articles/115005248128
+ - 'opened email'
+ - 'clicked email'
+ - 'clicked sms'
+
+ klaviyo__count_metrics:
+ - 'Active on Site' # default API metrics
+ - 'Viewed Product'
+ - 'Ordered Product' # some default Shopify metrics
+ - 'Placed Order' # there are X 'ordered product' events for every `placed order` purchase event of X products
+ - 'Refunded Order' # note: klaviyo only tracks FULL refunds (not partial)
+ - 'Received Email' # default email and sms conversion metrics in Klaviyo
+ - 'Clicked Email'
+ - 'Opened Email'
+ - 'Marked Email as Spam'
+ - 'Unsubscribed'
+ - 'Received SMS'
+ - 'Clicked SMS'
+ - 'Sent SMS'
+ - 'Unsubscribed from SMS'
+
+ klaviyo__sum_revenue_metrics:
+ - 'Refunded Order'
+ - 'Placed Order'
+ - 'Ordered Product'
+ - 'checkout started'
+ - 'cancelled order'
+
klaviyo_source:
klaviyo__event_pass_through_columns: []
klaviyo__person_pass_through_columns: []
+
-# models:
-# klaviyo_source:
-# tmp:
-# +materialized: view
-# +materialized: table
-
-profile: klaviyo
\ No newline at end of file
+models:
+ klaviyo:
+ intermediate:
+ +schema: int_klaviyo
+ +materialized: view # note: int_klaviyo__event_attribution is configured as incremental
+ +materialized: table # note: klaviyo__events is configured as incremental
+ +schema: klaviyo
diff --git a/docs/catalog.json b/docs/catalog.json
new file mode 100644
index 0000000..33f8b62
--- /dev/null
+++ b/docs/catalog.json
@@ -0,0 +1 @@
+{"metadata": {"dbt_schema_version": "https://schemas.getdbt.com/dbt/catalog/v1.json", "dbt_version": "0.19.1", "generated_at": "2021-05-14T22:08:52.360981Z", "invocation_id": "f7550b65-aa65-41a7-947e-4f59ca100216", "env": {}}, "nodes": {"model.klaviyo_source.stg_klaviyo__event_tmp": {"metadata": {"type": "VIEW", "schema": "DBT_FIVETRAN_STG_KLAVIYO", "name": "STG_KLAVIYO__EVENT_TMP", "database": "FIVETRAN_STAGING", "comment": null, "owner": "FIVETRAN_ANALYST"}, "columns": {"ID": {"type": "TEXT", "index": 1, "name": "ID", "comment": null}, "PERSON_ID": {"type": "TEXT", "index": 2, "name": "PERSON_ID", "comment": null}, "CAMPAIGN_ID": {"type": "TEXT", "index": 3, "name": "CAMPAIGN_ID", "comment": null}, "FLOW_ID": {"type": "TEXT", "index": 4, "name": "FLOW_ID", "comment": null}, "FLOW_MESSAGE_ID": {"type": "TEXT", "index": 5, "name": "FLOW_MESSAGE_ID", "comment": null}, "UUID": {"type": "TEXT", "index": 6, "name": "UUID", "comment": null}, "DATETIME": {"type": "TIMESTAMP_TZ", "index": 7, "name": "DATETIME", "comment": null}, "TIMESTAMP": {"type": "TIMESTAMP_TZ", "index": 8, "name": "TIMESTAMP", "comment": null}, "_FIVETRAN_DELETED": {"type": "BOOLEAN", "index": 9, "name": "_FIVETRAN_DELETED", "comment": null}, "METRIC_ID": {"type": "TEXT", "index": 10, "name": "METRIC_ID", "comment": null}, "TYPE": {"type": "TEXT", "index": 11, "name": "TYPE", "comment": null}, "_VARIATION": {"type": "TEXT", "index": 12, "name": "_VARIATION", "comment": null}, "PROPERTY_VALUE": {"type": "FLOAT", "index": 13, "name": "PROPERTY_VALUE", "comment": null}, "PROPERTY_SOURCE_NAME": {"type": "TEXT", "index": 14, "name": "PROPERTY_SOURCE_NAME", "comment": null}, "PROPERTY_EXTRA": {"type": "VARIANT", "index": 15, "name": "PROPERTY_EXTRA", "comment": null}, "PROPERTY_SHIPPING_RATE": {"type": "TEXT", "index": 16, "name": "PROPERTY_SHIPPING_RATE", "comment": null}, "PROPERTY_ITEMS": {"type": "VARIANT", "index": 17, "name": "PROPERTY_ITEMS", "comment": null}, "PROPERTY_TAGS": {"type": "VARIANT", "index": 18, "name": "PROPERTY_TAGS", "comment": null}, "PROPERTY_ITEM_COUNT": {"type": "NUMBER", "index": 19, "name": "PROPERTY_ITEM_COUNT", "comment": null}, "PROPERTY_COLLECTIONS": {"type": "VARIANT", "index": 20, "name": "PROPERTY_COLLECTIONS", "comment": null}, "_FIVETRAN_SYNCED": {"type": "TIMESTAMP_TZ", "index": 21, "name": "_FIVETRAN_SYNCED", "comment": null}, "PROPERTY_CURRENCY_CODE": {"type": "TEXT", "index": 22, "name": "PROPERTY_CURRENCY_CODE", "comment": null}, "PROPERTY_PRODUCT_ID": {"type": "NUMBER", "index": 23, "name": "PROPERTY_PRODUCT_ID", "comment": null}, "PROPERTY_QUANTITY": {"type": "NUMBER", "index": 24, "name": "PROPERTY_QUANTITY", "comment": null}, "PROPERTY_NAME": {"type": "TEXT", "index": 25, "name": "PROPERTY_NAME", "comment": null}, "PROPERTY_VARIANT_OPTION_TITLE": {"type": "TEXT", "index": 26, "name": "PROPERTY_VARIANT_OPTION_TITLE", "comment": null}, "PROPERTY_SKU": {"type": "TEXT", "index": 27, "name": "PROPERTY_SKU", "comment": null}, "PROPERTY_VARIANT_NAME": {"type": "TEXT", "index": 28, "name": "PROPERTY_VARIANT_NAME", "comment": null}, "PROPERTY_VENDOR": {"type": "TEXT", "index": 29, "name": "PROPERTY_VENDOR", "comment": null}, "PROPERTY_EVENT_ID": {"type": "TEXT", "index": 30, "name": "PROPERTY_EVENT_ID", "comment": null}, "PROPERTY_TOTAL_DISCOUNTS": {"type": "FLOAT", "index": 31, "name": "PROPERTY_TOTAL_DISCOUNTS", "comment": null}, "PROPERTY_ATTRIBUTION": {"type": "VARIANT", "index": 32, "name": "PROPERTY_ATTRIBUTION", "comment": null}, "PROPERTY_DISCOUNT_CODES": {"type": "VARIANT", "index": 33, "name": "PROPERTY_DISCOUNT_CODES", "comment": null}, "PROPERTY_FULFILLMENT_HOURS": {"type": "NUMBER", "index": 34, "name": "PROPERTY_FULFILLMENT_HOURS", "comment": null}, "PROPERTY_FULFILLMENT_STATUS": {"type": "TEXT", "index": 35, "name": "PROPERTY_FULFILLMENT_STATUS", "comment": null}, "PROPERTY_SUBJECT": {"type": "TEXT", "index": 36, "name": "PROPERTY_SUBJECT", "comment": null}, "PROPERTY_TITLE": {"type": "TEXT", "index": 37, "name": "PROPERTY_TITLE", "comment": null}, "PROPERTY_MESSAGE_INTERACTION": {"type": "TEXT", "index": 38, "name": "PROPERTY_MESSAGE_INTERACTION", "comment": null}, "PROPERTY_URL": {"type": "TEXT", "index": 39, "name": "PROPERTY_URL", "comment": null}, "PROPERTY_SHIPMENT_TYPE": {"type": "TEXT", "index": 40, "name": "PROPERTY_SHIPMENT_TYPE", "comment": null}, "PROPERTY_COURIER_NAME": {"type": "TEXT", "index": 41, "name": "PROPERTY_COURIER_NAME", "comment": null}, "PROPERTY_CURRENT_STATUS": {"type": "TEXT", "index": 42, "name": "PROPERTY_CURRENT_STATUS", "comment": null}, "PROPERTY_TRACKING_SHIP_DATE": {"type": "NUMBER", "index": 43, "name": "PROPERTY_TRACKING_SHIP_DATE", "comment": null}, "PROPERTY_TRACKING_POSTAL_CODE": {"type": "TEXT", "index": 44, "name": "PROPERTY_TRACKING_POSTAL_CODE", "comment": null}, "PROPERTY_SHIPMENT_PACKAGE_COUNT": {"type": "NUMBER", "index": 45, "name": "PROPERTY_SHIPMENT_PACKAGE_COUNT", "comment": null}, "PROPERTY_CAMPAIGN_NAME": {"type": "TEXT", "index": 46, "name": "PROPERTY_CAMPAIGN_NAME", "comment": null}, "PROPERTY_COHORT_MESSAGE_SEND_COHORT": {"type": "TEXT", "index": 47, "name": "PROPERTY_COHORT_MESSAGE_SEND_COHORT", "comment": null}, "PROPERTY_EMAIL_DOMAIN": {"type": "TEXT", "index": 48, "name": "PROPERTY_EMAIL_DOMAIN", "comment": null}, "PROPERTY_BOUNCE_TYPE": {"type": "TEXT", "index": 49, "name": "PROPERTY_BOUNCE_TYPE", "comment": null}, "PROPERTY_CLIENT_TYPE": {"type": "TEXT", "index": 50, "name": "PROPERTY_CLIENT_TYPE", "comment": null}, "PROPERTY_CLIENT_OS": {"type": "TEXT", "index": 51, "name": "PROPERTY_CLIENT_OS", "comment": null}, "PROPERTY_CLIENT_NAME": {"type": "TEXT", "index": 52, "name": "PROPERTY_CLIENT_NAME", "comment": null}, "PROPERTY_CLIENT_OS_FAMILY": {"type": "TEXT", "index": 53, "name": "PROPERTY_CLIENT_OS_FAMILY", "comment": null}, "PROPERTY_CLIENT_CANONICAL": {"type": "TEXT", "index": 54, "name": "PROPERTY_CLIENT_CANONICAL", "comment": null}, "PROPERTY_PAGE": {"type": "TEXT", "index": 55, "name": "PROPERTY_PAGE", "comment": null}, "PROPERTY_IS_SESSION_ACTIVITY": {"type": "BOOLEAN", "index": 56, "name": "PROPERTY_IS_SESSION_ACTIVITY", "comment": null}, "PROPERTY_OS": {"type": "TEXT", "index": 57, "name": "PROPERTY_OS", "comment": null}, "PROPERTY_SESSION_END": {"type": "NUMBER", "index": 58, "name": "PROPERTY_SESSION_END", "comment": null}, "PROPERTY_BROWSER": {"type": "TEXT", "index": 59, "name": "PROPERTY_BROWSER", "comment": null}, "PROPERTY_LIST": {"type": "TEXT", "index": 60, "name": "PROPERTY_LIST", "comment": null}, "PROPERTY_COMPARE_AT_PRICE": {"type": "TEXT", "index": 61, "name": "PROPERTY_COMPARE_AT_PRICE", "comment": null}, "PROPERTY_PRICE": {"type": "TEXT", "index": 62, "name": "PROPERTY_PRICE", "comment": null}, "PROPERTY_IMAGE_URL": {"type": "TEXT", "index": 63, "name": "PROPERTY_IMAGE_URL", "comment": null}, "PROPERTY_BRAND": {"type": "TEXT", "index": 64, "name": "PROPERTY_BRAND", "comment": null}, "PROPERTY_CATEGORIES": {"type": "VARIANT", "index": 65, "name": "PROPERTY_CATEGORIES", "comment": null}, "PROPERTY_VARIANT_OPTION_SIZE": {"type": "TEXT", "index": 66, "name": "PROPERTY_VARIANT_OPTION_SIZE", "comment": null}, "PROPERTY_ATTRIBUTE_WORKOUT": {"type": "TEXT", "index": 67, "name": "PROPERTY_ATTRIBUTE_WORKOUT", "comment": null}, "PROPERTY_ATTRIBUTE_AGE": {"type": "TEXT", "index": 68, "name": "PROPERTY_ATTRIBUTE_AGE", "comment": null}, "PROPERTY_ATTRIBUTE_FITNESS_GOAL": {"type": "TEXT", "index": 69, "name": "PROPERTY_ATTRIBUTE_FITNESS_GOAL", "comment": null}, "PROPERTY_ATTRIBUTE_BREAKFAST": {"type": "TEXT", "index": 70, "name": "PROPERTY_ATTRIBUTE_BREAKFAST", "comment": null}, "PROPERTY_VARIANT_OPTION_TYPE": {"type": "TEXT", "index": 71, "name": "PROPERTY_VARIANT_OPTION_TYPE", "comment": null}, "PROPERTY_COHORT_VARIATION_SEND_COHORT": {"type": "TEXT", "index": 72, "name": "PROPERTY_COHORT_VARIATION_SEND_COHORT", "comment": null}, "PROPERTY_METHOD": {"type": "TEXT", "index": 73, "name": "PROPERTY_METHOD", "comment": null}, "PROPERTY_TO_NUMBER": {"type": "TEXT", "index": 74, "name": "PROPERTY_TO_NUMBER", "comment": null}, "PROPERTY_MESSAGE_TYPE": {"type": "TEXT", "index": 75, "name": "PROPERTY_MESSAGE_TYPE", "comment": null}, "PROPERTY_FROM_NUMBER": {"type": "TEXT", "index": 76, "name": "PROPERTY_FROM_NUMBER", "comment": null}, "PROPERTY_MESSAGE_FORMAT": {"type": "TEXT", "index": 77, "name": "PROPERTY_MESSAGE_FORMAT", "comment": null}, "PROPERTY_MESSAGE_NAME": {"type": "TEXT", "index": 78, "name": "PROPERTY_MESSAGE_NAME", "comment": null}, "PROPERTY_CARRIER_DELIVERY_STATUS": {"type": "TEXT", "index": 79, "name": "PROPERTY_CARRIER_DELIVERY_STATUS", "comment": null}, "PROPERTY_FAILURE_TYPE": {"type": "TEXT", "index": 80, "name": "PROPERTY_FAILURE_TYPE", "comment": null}, "PROPERTY_FAILURE_SOURCE": {"type": "TEXT", "index": 81, "name": "PROPERTY_FAILURE_SOURCE", "comment": null}, "PROPERTY_MESSAGE_BODY": {"type": "TEXT", "index": 82, "name": "PROPERTY_MESSAGE_BODY", "comment": null}, "PROPERTY_EMAIL": {"type": "TEXT", "index": 83, "name": "PROPERTY_EMAIL", "comment": null}, "PROPERTY_ATTRIBUTE_KIT": {"type": "TEXT", "index": 84, "name": "PROPERTY_ATTRIBUTE_KIT", "comment": null}, "PROPERTY_VENDOR_ERROR_CODE": {"type": "TEXT", "index": 85, "name": "PROPERTY_VENDOR_ERROR_CODE", "comment": null}, "PROPERTY_ORDR_DETAILS": {"type": "VARIANT", "index": 86, "name": "PROPERTY_ORDR_DETAILS", "comment": null}, "PROPERTY_DATE_TO_SEND_GIFT": {"type": "TEXT", "index": 87, "name": "PROPERTY_DATE_TO_SEND_GIFT", "comment": null}, "PROPERTY_RECIPIENT_NAME": {"type": "TEXT", "index": 88, "name": "PROPERTY_RECIPIENT_NAME", "comment": null}, "PROPERTY_ATTRIBUTE_FACEBOOK_ORDER_RETAILER_ID": {"type": "NUMBER", "index": 89, "name": "PROPERTY_ATTRIBUTE_FACEBOOK_ORDER_RETAILER_ID", "comment": null}, "PROPERTY_SENDER_S_NAME": {"type": "TEXT", "index": 90, "name": "PROPERTY_SENDER_S_NAME", "comment": null}, "PROPERTY_ATTRIBUTE_KITID": {"type": "NUMBER", "index": 91, "name": "PROPERTY_ATTRIBUTE_KITID", "comment": null}, "PROPERTY_CONVERSATION_ID": {"type": "TEXT", "index": 92, "name": "PROPERTY_CONVERSATION_ID", "comment": null}, "PROPERTY_CONVERSATION_LINK": {"type": "TEXT", "index": 93, "name": "PROPERTY_CONVERSATION_LINK", "comment": null}, "PROPERTY_CONVERSATION_CHANNEL": {"type": "TEXT", "index": 94, "name": "PROPERTY_CONVERSATION_CHANNEL", "comment": null}, "PROPERTY_RATING": {"type": "NUMBER", "index": 95, "name": "PROPERTY_RATING", "comment": null}, "PROPERTY_SCORE": {"type": "NUMBER", "index": 96, "name": "PROPERTY_SCORE", "comment": null}, "PROPERTY_FROM_PHONE_REGION": {"type": "TEXT", "index": 97, "name": "PROPERTY_FROM_PHONE_REGION", "comment": null}, "PROPERTY_SHIPMENT_CARRIER": {"type": "TEXT", "index": 98, "name": "PROPERTY_SHIPMENT_CARRIER", "comment": null}, "PROPERTY_SHIPMENT_STATUS": {"type": "TEXT", "index": 99, "name": "PROPERTY_SHIPMENT_STATUS", "comment": null}, "PROPERTY_TO_PHONE_REGION": {"type": "TEXT", "index": 100, "name": "PROPERTY_TO_PHONE_REGION", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.klaviyo_source.stg_klaviyo__event_tmp"}, "model.klaviyo_source.stg_klaviyo__metric": {"metadata": {"type": "BASE TABLE", "schema": "DBT_FIVETRAN_STG_KLAVIYO", "name": "STG_KLAVIYO__METRIC", "database": "FIVETRAN_STAGING", "comment": null, "owner": "FIVETRAN_ANALYST"}, "columns": {"CREATED_AT": {"type": "TIMESTAMP_TZ", "index": 1, "name": "CREATED_AT", "comment": null}, "METRIC_ID": {"type": "TEXT", "index": 2, "name": "METRIC_ID", "comment": null}, "INTEGRATION_ID": {"type": "TEXT", "index": 3, "name": "INTEGRATION_ID", "comment": null}, "METRIC_NAME": {"type": "TEXT", "index": 4, "name": "METRIC_NAME", "comment": null}, "UPDATED_AT": {"type": "TIMESTAMP_TZ", "index": 5, "name": "UPDATED_AT", "comment": null}}, "stats": {"bytes": {"id": "bytes", "label": "Approximate Size", "value": 3584.0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2021-05-13 00:17UTC", "include": true, "description": "The timestamp for last update/change"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 41.0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.klaviyo_source.stg_klaviyo__metric"}, "model.klaviyo.int_klaviyo__campaign_flow_metrics": {"metadata": {"type": "VIEW", "schema": "DBT_FIVETRAN_INT_KLAVIYO", "name": "INT_KLAVIYO__CAMPAIGN_FLOW_METRICS", "database": "FIVETRAN_STAGING", "comment": null, "owner": "FIVETRAN_ANALYST"}, "columns": {"LAST_TOUCH_CAMPAIGN_ID": {"type": "TEXT", "index": 1, "name": "LAST_TOUCH_CAMPAIGN_ID", "comment": null}, "LAST_TOUCH_FLOW_ID": {"type": "TEXT", "index": 2, "name": "LAST_TOUCH_FLOW_ID", "comment": null}, "VARIATION_ID": {"type": "TEXT", "index": 3, "name": "VARIATION_ID", "comment": null}, "TOTAL_COUNT_UNIQUE_PEOPLE": {"type": "NUMBER", "index": 4, "name": "TOTAL_COUNT_UNIQUE_PEOPLE", "comment": null}, "FIRST_EVENT_AT": {"type": "TIMESTAMP_NTZ", "index": 5, "name": "FIRST_EVENT_AT", "comment": null}, "LAST_EVENT_AT": {"type": "TIMESTAMP_NTZ", "index": 6, "name": "LAST_EVENT_AT", "comment": null}, "SUM_REVENUE_REFUNDED_ORDER": {"type": "FLOAT", "index": 7, "name": "SUM_REVENUE_REFUNDED_ORDER", "comment": null}, "SUM_REVENUE_PLACED_ORDER": {"type": "FLOAT", "index": 8, "name": "SUM_REVENUE_PLACED_ORDER", "comment": null}, "SUM_REVENUE_ORDERED_PRODUCT": {"type": "FLOAT", "index": 9, "name": "SUM_REVENUE_ORDERED_PRODUCT", "comment": null}, "SUM_REVENUE_CHECKOUT_STARTED": {"type": "FLOAT", "index": 10, "name": "SUM_REVENUE_CHECKOUT_STARTED", "comment": null}, "SUM_REVENUE_CANCELLED_ORDER": {"type": "FLOAT", "index": 11, "name": "SUM_REVENUE_CANCELLED_ORDER", "comment": null}, "COUNT_ACTIVE_ON_SITE": {"type": "NUMBER", "index": 12, "name": "COUNT_ACTIVE_ON_SITE", "comment": null}, "UNIQUE_COUNT_ACTIVE_ON_SITE": {"type": "NUMBER", "index": 13, "name": "UNIQUE_COUNT_ACTIVE_ON_SITE", "comment": null}, "COUNT_VIEWED_PRODUCT": {"type": "NUMBER", "index": 14, "name": "COUNT_VIEWED_PRODUCT", "comment": null}, "UNIQUE_COUNT_VIEWED_PRODUCT": {"type": "NUMBER", "index": 15, "name": "UNIQUE_COUNT_VIEWED_PRODUCT", "comment": null}, "COUNT_ORDERED_PRODUCT": {"type": "NUMBER", "index": 16, "name": "COUNT_ORDERED_PRODUCT", "comment": null}, "UNIQUE_COUNT_ORDERED_PRODUCT": {"type": "NUMBER", "index": 17, "name": "UNIQUE_COUNT_ORDERED_PRODUCT", "comment": null}, "COUNT_PLACED_ORDER": {"type": "NUMBER", "index": 18, "name": "COUNT_PLACED_ORDER", "comment": null}, "UNIQUE_COUNT_PLACED_ORDER": {"type": "NUMBER", "index": 19, "name": "UNIQUE_COUNT_PLACED_ORDER", "comment": null}, "COUNT_REFUNDED_ORDER": {"type": "NUMBER", "index": 20, "name": "COUNT_REFUNDED_ORDER", "comment": null}, "UNIQUE_COUNT_REFUNDED_ORDER": {"type": "NUMBER", "index": 21, "name": "UNIQUE_COUNT_REFUNDED_ORDER", "comment": null}, "COUNT_RECEIVED_EMAIL": {"type": "NUMBER", "index": 22, "name": "COUNT_RECEIVED_EMAIL", "comment": null}, "UNIQUE_COUNT_RECEIVED_EMAIL": {"type": "NUMBER", "index": 23, "name": "UNIQUE_COUNT_RECEIVED_EMAIL", "comment": null}, "COUNT_CLICKED_EMAIL": {"type": "NUMBER", "index": 24, "name": "COUNT_CLICKED_EMAIL", "comment": null}, "UNIQUE_COUNT_CLICKED_EMAIL": {"type": "NUMBER", "index": 25, "name": "UNIQUE_COUNT_CLICKED_EMAIL", "comment": null}, "COUNT_OPENED_EMAIL": {"type": "NUMBER", "index": 26, "name": "COUNT_OPENED_EMAIL", "comment": null}, "UNIQUE_COUNT_OPENED_EMAIL": {"type": "NUMBER", "index": 27, "name": "UNIQUE_COUNT_OPENED_EMAIL", "comment": null}, "COUNT_MARKED_EMAIL_AS_SPAM": {"type": "NUMBER", "index": 28, "name": "COUNT_MARKED_EMAIL_AS_SPAM", "comment": null}, "UNIQUE_COUNT_MARKED_EMAIL_AS_SPAM": {"type": "NUMBER", "index": 29, "name": "UNIQUE_COUNT_MARKED_EMAIL_AS_SPAM", "comment": null}, "COUNT_UNSUBSCRIBED": {"type": "NUMBER", "index": 30, "name": "COUNT_UNSUBSCRIBED", "comment": null}, "UNIQUE_COUNT_UNSUBSCRIBED": {"type": "NUMBER", "index": 31, "name": "UNIQUE_COUNT_UNSUBSCRIBED", "comment": null}, "COUNT_RECEIVED_SMS": {"type": "NUMBER", "index": 32, "name": "COUNT_RECEIVED_SMS", "comment": null}, "UNIQUE_COUNT_RECEIVED_SMS": {"type": "NUMBER", "index": 33, "name": "UNIQUE_COUNT_RECEIVED_SMS", "comment": null}, "COUNT_CLICKED_SMS": {"type": "NUMBER", "index": 34, "name": "COUNT_CLICKED_SMS", "comment": null}, "UNIQUE_COUNT_CLICKED_SMS": {"type": "NUMBER", "index": 35, "name": "UNIQUE_COUNT_CLICKED_SMS", "comment": null}, "COUNT_SENT_SMS": {"type": "NUMBER", "index": 36, "name": "COUNT_SENT_SMS", "comment": null}, "UNIQUE_COUNT_SENT_SMS": {"type": "NUMBER", "index": 37, "name": "UNIQUE_COUNT_SENT_SMS", "comment": null}, "COUNT_UNSUBSCRIBED_FROM_SMS": {"type": "NUMBER", "index": 38, "name": "COUNT_UNSUBSCRIBED_FROM_SMS", "comment": null}, "UNIQUE_COUNT_UNSUBSCRIBED_FROM_SMS": {"type": "NUMBER", "index": 39, "name": "UNIQUE_COUNT_UNSUBSCRIBED_FROM_SMS", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.klaviyo.int_klaviyo__campaign_flow_metrics"}, "model.klaviyo.int_klaviyo__event_attribution": {"metadata": {"type": "BASE TABLE", "schema": "DBT_FIVETRAN_INT_KLAVIYO", "name": "INT_KLAVIYO__EVENT_ATTRIBUTION", "database": "FIVETRAN_STAGING", "comment": null, "owner": "FIVETRAN_ANALYST"}, "columns": {"VARIATION_ID": {"type": "TEXT", "index": 1, "name": "VARIATION_ID", "comment": null}, "CAMPAIGN_ID": {"type": "TEXT", "index": 2, "name": "CAMPAIGN_ID", "comment": null}, "OCCURRED_AT": {"type": "TIMESTAMP_NTZ", "index": 3, "name": "OCCURRED_AT", "comment": null}, "FLOW_ID": {"type": "TEXT", "index": 4, "name": "FLOW_ID", "comment": null}, "FLOW_MESSAGE_ID": {"type": "TEXT", "index": 5, "name": "FLOW_MESSAGE_ID", "comment": null}, "EVENT_ID": {"type": "TEXT", "index": 6, "name": "EVENT_ID", "comment": null}, "METRIC_ID": {"type": "TEXT", "index": 7, "name": "METRIC_ID", "comment": null}, "PERSON_ID": {"type": "TEXT", "index": 8, "name": "PERSON_ID", "comment": null}, "TYPE": {"type": "TEXT", "index": 9, "name": "TYPE", "comment": null}, "UUID": {"type": "TEXT", "index": 10, "name": "UUID", "comment": null}, "NUMERIC_VALUE": {"type": "FLOAT", "index": 11, "name": "NUMERIC_VALUE", "comment": null}, "_FIVETRAN_SYNCED": {"type": "TIMESTAMP_TZ", "index": 12, "name": "_FIVETRAN_SYNCED", "comment": null}, "OCCURRED_ON": {"type": "DATE", "index": 13, "name": "OCCURRED_ON", "comment": null}, "TOUCH_ID": {"type": "TEXT", "index": 14, "name": "TOUCH_ID", "comment": null}, "TOUCH_TYPE": {"type": "TEXT", "index": 15, "name": "TOUCH_TYPE", "comment": null}, "TOUCH_SESSION": {"type": "NUMBER", "index": 16, "name": "TOUCH_SESSION", "comment": null}, "SESSION_START_AT": {"type": "TIMESTAMP_NTZ", "index": 17, "name": "SESSION_START_AT", "comment": null}, "SESSION_EVENT_TYPE": {"type": "TEXT", "index": 18, "name": "SESSION_EVENT_TYPE", "comment": null}, "LAST_TOUCH_ID": {"type": "TEXT", "index": 19, "name": "LAST_TOUCH_ID", "comment": null}, "LAST_TOUCH_TYPE": {"type": "TEXT", "index": 20, "name": "LAST_TOUCH_TYPE", "comment": null}}, "stats": {"bytes": {"id": "bytes", "label": "Approximate Size", "value": 737427456.0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2021-05-13 00:18UTC", "include": true, "description": "The timestamp for last update/change"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 15181494.0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.klaviyo.int_klaviyo__event_attribution"}, "model.klaviyo.int_klaviyo__person_metrics": {"metadata": {"type": "VIEW", "schema": "DBT_FIVETRAN_INT_KLAVIYO", "name": "INT_KLAVIYO__PERSON_METRICS", "database": "FIVETRAN_STAGING", "comment": null, "owner": "FIVETRAN_ANALYST"}, "columns": {"PERSON_ID": {"type": "TEXT", "index": 1, "name": "PERSON_ID", "comment": null}, "COUNT_TOTAL_CAMPAIGNS": {"type": "NUMBER", "index": 2, "name": "COUNT_TOTAL_CAMPAIGNS", "comment": null}, "COUNT_TOTAL_FLOWS": {"type": "NUMBER", "index": 3, "name": "COUNT_TOTAL_FLOWS", "comment": null}, "FIRST_EVENT_AT": {"type": "TIMESTAMP_NTZ", "index": 4, "name": "FIRST_EVENT_AT", "comment": null}, "LAST_EVENT_AT": {"type": "TIMESTAMP_NTZ", "index": 5, "name": "LAST_EVENT_AT", "comment": null}, "FIRST_CAMPAIGN_TOUCH_AT": {"type": "TIMESTAMP_NTZ", "index": 6, "name": "FIRST_CAMPAIGN_TOUCH_AT", "comment": null}, "LAST_CAMPAIGN_TOUCH_AT": {"type": "TIMESTAMP_NTZ", "index": 7, "name": "LAST_CAMPAIGN_TOUCH_AT", "comment": null}, "FIRST_FLOW_TOUCH_AT": {"type": "TIMESTAMP_NTZ", "index": 8, "name": "FIRST_FLOW_TOUCH_AT", "comment": null}, "LAST_FLOW_TOUCH_AT": {"type": "TIMESTAMP_NTZ", "index": 9, "name": "LAST_FLOW_TOUCH_AT", "comment": null}, "TOTAL_SUM_REVENUE_REFUNDED_ORDER": {"type": "FLOAT", "index": 10, "name": "TOTAL_SUM_REVENUE_REFUNDED_ORDER", "comment": null}, "ORGANIC_SUM_REVENUE_REFUNDED_ORDER": {"type": "FLOAT", "index": 11, "name": "ORGANIC_SUM_REVENUE_REFUNDED_ORDER", "comment": null}, "TOTAL_SUM_REVENUE_PLACED_ORDER": {"type": "FLOAT", "index": 12, "name": "TOTAL_SUM_REVENUE_PLACED_ORDER", "comment": null}, "ORGANIC_SUM_REVENUE_PLACED_ORDER": {"type": "FLOAT", "index": 13, "name": "ORGANIC_SUM_REVENUE_PLACED_ORDER", "comment": null}, "TOTAL_SUM_REVENUE_ORDERED_PRODUCT": {"type": "FLOAT", "index": 14, "name": "TOTAL_SUM_REVENUE_ORDERED_PRODUCT", "comment": null}, "ORGANIC_SUM_REVENUE_ORDERED_PRODUCT": {"type": "FLOAT", "index": 15, "name": "ORGANIC_SUM_REVENUE_ORDERED_PRODUCT", "comment": null}, "TOTAL_SUM_REVENUE_CHECKOUT_STARTED": {"type": "FLOAT", "index": 16, "name": "TOTAL_SUM_REVENUE_CHECKOUT_STARTED", "comment": null}, "ORGANIC_SUM_REVENUE_CHECKOUT_STARTED": {"type": "FLOAT", "index": 17, "name": "ORGANIC_SUM_REVENUE_CHECKOUT_STARTED", "comment": null}, "TOTAL_SUM_REVENUE_CANCELLED_ORDER": {"type": "FLOAT", "index": 18, "name": "TOTAL_SUM_REVENUE_CANCELLED_ORDER", "comment": null}, "ORGANIC_SUM_REVENUE_CANCELLED_ORDER": {"type": "FLOAT", "index": 19, "name": "ORGANIC_SUM_REVENUE_CANCELLED_ORDER", "comment": null}, "TOTAL_COUNT_ACTIVE_ON_SITE": {"type": "NUMBER", "index": 20, "name": "TOTAL_COUNT_ACTIVE_ON_SITE", "comment": null}, "TOTAL_COUNT_VIEWED_PRODUCT": {"type": "NUMBER", "index": 21, "name": "TOTAL_COUNT_VIEWED_PRODUCT", "comment": null}, "TOTAL_COUNT_ORDERED_PRODUCT": {"type": "NUMBER", "index": 22, "name": "TOTAL_COUNT_ORDERED_PRODUCT", "comment": null}, "TOTAL_COUNT_PLACED_ORDER": {"type": "NUMBER", "index": 23, "name": "TOTAL_COUNT_PLACED_ORDER", "comment": null}, "TOTAL_COUNT_REFUNDED_ORDER": {"type": "NUMBER", "index": 24, "name": "TOTAL_COUNT_REFUNDED_ORDER", "comment": null}, "TOTAL_COUNT_RECEIVED_EMAIL": {"type": "NUMBER", "index": 25, "name": "TOTAL_COUNT_RECEIVED_EMAIL", "comment": null}, "TOTAL_COUNT_CLICKED_EMAIL": {"type": "NUMBER", "index": 26, "name": "TOTAL_COUNT_CLICKED_EMAIL", "comment": null}, "TOTAL_COUNT_OPENED_EMAIL": {"type": "NUMBER", "index": 27, "name": "TOTAL_COUNT_OPENED_EMAIL", "comment": null}, "TOTAL_COUNT_MARKED_EMAIL_AS_SPAM": {"type": "NUMBER", "index": 28, "name": "TOTAL_COUNT_MARKED_EMAIL_AS_SPAM", "comment": null}, "TOTAL_COUNT_UNSUBSCRIBED": {"type": "NUMBER", "index": 29, "name": "TOTAL_COUNT_UNSUBSCRIBED", "comment": null}, "TOTAL_COUNT_RECEIVED_SMS": {"type": "NUMBER", "index": 30, "name": "TOTAL_COUNT_RECEIVED_SMS", "comment": null}, "TOTAL_COUNT_CLICKED_SMS": {"type": "NUMBER", "index": 31, "name": "TOTAL_COUNT_CLICKED_SMS", "comment": null}, "TOTAL_COUNT_SENT_SMS": {"type": "NUMBER", "index": 32, "name": "TOTAL_COUNT_SENT_SMS", "comment": null}, "TOTAL_COUNT_UNSUBSCRIBED_FROM_SMS": {"type": "NUMBER", "index": 33, "name": "TOTAL_COUNT_UNSUBSCRIBED_FROM_SMS", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.klaviyo.int_klaviyo__person_metrics"}, "model.klaviyo.klaviyo__campaigns": {"metadata": {"type": "BASE TABLE", "schema": "DBT_FIVETRAN_KLAVIYO", "name": "KLAVIYO__CAMPAIGNS", "database": "FIVETRAN_STAGING", "comment": null, "owner": "FIVETRAN_ANALYST"}, "columns": {"CAMPAIGN_TYPE": {"type": "TEXT", "index": 1, "name": "CAMPAIGN_TYPE", "comment": null}, "CREATED_AT": {"type": "TIMESTAMP_TZ", "index": 2, "name": "CREATED_AT", "comment": null}, "EMAIL_TEMPLATE_ID": {"type": "TEXT", "index": 3, "name": "EMAIL_TEMPLATE_ID", "comment": null}, "FROM_EMAIL": {"type": "TEXT", "index": 4, "name": "FROM_EMAIL", "comment": null}, "FROM_NAME": {"type": "TEXT", "index": 5, "name": "FROM_NAME", "comment": null}, "CAMPAIGN_ID": {"type": "TEXT", "index": 6, "name": "CAMPAIGN_ID", "comment": null}, "IS_SEGMENTED": {"type": "BOOLEAN", "index": 7, "name": "IS_SEGMENTED", "comment": null}, "CAMPAIGN_NAME": {"type": "TEXT", "index": 8, "name": "CAMPAIGN_NAME", "comment": null}, "SCHEDULED_TO_SEND_AT": {"type": "TIMESTAMP_TZ", "index": 9, "name": "SCHEDULED_TO_SEND_AT", "comment": null}, "SENT_AT": {"type": "TIMESTAMP_TZ", "index": 10, "name": "SENT_AT", "comment": null}, "STATUS": {"type": "TEXT", "index": 11, "name": "STATUS", "comment": null}, "STATUS_ID": {"type": "TEXT", "index": 12, "name": "STATUS_ID", "comment": null}, "SUBJECT": {"type": "TEXT", "index": 13, "name": "SUBJECT", "comment": null}, "UPDATED_AT": {"type": "TIMESTAMP_TZ", "index": 14, "name": "UPDATED_AT", "comment": null}, "VARIATION_ID": {"type": "TEXT", "index": 15, "name": "VARIATION_ID", "comment": null}, "TOTAL_COUNT_UNIQUE_PEOPLE": {"type": "NUMBER", "index": 16, "name": "TOTAL_COUNT_UNIQUE_PEOPLE", "comment": null}, "FIRST_EVENT_AT": {"type": "TIMESTAMP_NTZ", "index": 17, "name": "FIRST_EVENT_AT", "comment": null}, "LAST_EVENT_AT": {"type": "TIMESTAMP_NTZ", "index": 18, "name": "LAST_EVENT_AT", "comment": null}, "SUM_REVENUE_REFUNDED_ORDER": {"type": "FLOAT", "index": 19, "name": "SUM_REVENUE_REFUNDED_ORDER", "comment": null}, "SUM_REVENUE_PLACED_ORDER": {"type": "FLOAT", "index": 20, "name": "SUM_REVENUE_PLACED_ORDER", "comment": null}, "SUM_REVENUE_ORDERED_PRODUCT": {"type": "FLOAT", "index": 21, "name": "SUM_REVENUE_ORDERED_PRODUCT", "comment": null}, "SUM_REVENUE_CHECKOUT_STARTED": {"type": "FLOAT", "index": 22, "name": "SUM_REVENUE_CHECKOUT_STARTED", "comment": null}, "SUM_REVENUE_CANCELLED_ORDER": {"type": "FLOAT", "index": 23, "name": "SUM_REVENUE_CANCELLED_ORDER", "comment": null}, "COUNT_ACTIVE_ON_SITE": {"type": "NUMBER", "index": 24, "name": "COUNT_ACTIVE_ON_SITE", "comment": null}, "UNIQUE_COUNT_ACTIVE_ON_SITE": {"type": "NUMBER", "index": 25, "name": "UNIQUE_COUNT_ACTIVE_ON_SITE", "comment": null}, "COUNT_VIEWED_PRODUCT": {"type": "NUMBER", "index": 26, "name": "COUNT_VIEWED_PRODUCT", "comment": null}, "UNIQUE_COUNT_VIEWED_PRODUCT": {"type": "NUMBER", "index": 27, "name": "UNIQUE_COUNT_VIEWED_PRODUCT", "comment": null}, "COUNT_ORDERED_PRODUCT": {"type": "NUMBER", "index": 28, "name": "COUNT_ORDERED_PRODUCT", "comment": null}, "UNIQUE_COUNT_ORDERED_PRODUCT": {"type": "NUMBER", "index": 29, "name": "UNIQUE_COUNT_ORDERED_PRODUCT", "comment": null}, "COUNT_PLACED_ORDER": {"type": "NUMBER", "index": 30, "name": "COUNT_PLACED_ORDER", "comment": null}, "UNIQUE_COUNT_PLACED_ORDER": {"type": "NUMBER", "index": 31, "name": "UNIQUE_COUNT_PLACED_ORDER", "comment": null}, "COUNT_REFUNDED_ORDER": {"type": "NUMBER", "index": 32, "name": "COUNT_REFUNDED_ORDER", "comment": null}, "UNIQUE_COUNT_REFUNDED_ORDER": {"type": "NUMBER", "index": 33, "name": "UNIQUE_COUNT_REFUNDED_ORDER", "comment": null}, "COUNT_RECEIVED_EMAIL": {"type": "NUMBER", "index": 34, "name": "COUNT_RECEIVED_EMAIL", "comment": null}, "UNIQUE_COUNT_RECEIVED_EMAIL": {"type": "NUMBER", "index": 35, "name": "UNIQUE_COUNT_RECEIVED_EMAIL", "comment": null}, "COUNT_CLICKED_EMAIL": {"type": "NUMBER", "index": 36, "name": "COUNT_CLICKED_EMAIL", "comment": null}, "UNIQUE_COUNT_CLICKED_EMAIL": {"type": "NUMBER", "index": 37, "name": "UNIQUE_COUNT_CLICKED_EMAIL", "comment": null}, "COUNT_OPENED_EMAIL": {"type": "NUMBER", "index": 38, "name": "COUNT_OPENED_EMAIL", "comment": null}, "UNIQUE_COUNT_OPENED_EMAIL": {"type": "NUMBER", "index": 39, "name": "UNIQUE_COUNT_OPENED_EMAIL", "comment": null}, "COUNT_MARKED_EMAIL_AS_SPAM": {"type": "NUMBER", "index": 40, "name": "COUNT_MARKED_EMAIL_AS_SPAM", "comment": null}, "UNIQUE_COUNT_MARKED_EMAIL_AS_SPAM": {"type": "NUMBER", "index": 41, "name": "UNIQUE_COUNT_MARKED_EMAIL_AS_SPAM", "comment": null}, "COUNT_UNSUBSCRIBED": {"type": "NUMBER", "index": 42, "name": "COUNT_UNSUBSCRIBED", "comment": null}, "UNIQUE_COUNT_UNSUBSCRIBED": {"type": "NUMBER", "index": 43, "name": "UNIQUE_COUNT_UNSUBSCRIBED", "comment": null}, "COUNT_RECEIVED_SMS": {"type": "NUMBER", "index": 44, "name": "COUNT_RECEIVED_SMS", "comment": null}, "UNIQUE_COUNT_RECEIVED_SMS": {"type": "NUMBER", "index": 45, "name": "UNIQUE_COUNT_RECEIVED_SMS", "comment": null}, "COUNT_CLICKED_SMS": {"type": "NUMBER", "index": 46, "name": "COUNT_CLICKED_SMS", "comment": null}, "UNIQUE_COUNT_CLICKED_SMS": {"type": "NUMBER", "index": 47, "name": "UNIQUE_COUNT_CLICKED_SMS", "comment": null}, "COUNT_SENT_SMS": {"type": "NUMBER", "index": 48, "name": "COUNT_SENT_SMS", "comment": null}, "UNIQUE_COUNT_SENT_SMS": {"type": "NUMBER", "index": 49, "name": "UNIQUE_COUNT_SENT_SMS", "comment": null}, "COUNT_UNSUBSCRIBED_FROM_SMS": {"type": "NUMBER", "index": 50, "name": "COUNT_UNSUBSCRIBED_FROM_SMS", "comment": null}, "UNIQUE_COUNT_UNSUBSCRIBED_FROM_SMS": {"type": "NUMBER", "index": 51, "name": "UNIQUE_COUNT_UNSUBSCRIBED_FROM_SMS", "comment": null}, "CAMPAIGN_VARIATION_KEY": {"type": "TEXT", "index": 52, "name": "CAMPAIGN_VARIATION_KEY", "comment": null}}, "stats": {"bytes": {"id": "bytes", "label": "Approximate Size", "value": 162304.0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2021-05-13 00:19UTC", "include": true, "description": "The timestamp for last update/change"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 102.0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.klaviyo.klaviyo__campaigns"}, "model.klaviyo_source.stg_klaviyo__person_tmp": {"metadata": {"type": "VIEW", "schema": "DBT_FIVETRAN_STG_KLAVIYO", "name": "STG_KLAVIYO__PERSON_TMP", "database": "FIVETRAN_STAGING", "comment": null, "owner": "FIVETRAN_ANALYST"}, "columns": {"ID": {"type": "TEXT", "index": 1, "name": "ID", "comment": null}, "UPDATED": {"type": "TIMESTAMP_TZ", "index": 2, "name": "UPDATED", "comment": null}, "CREATED": {"type": "TIMESTAMP_TZ", "index": 3, "name": "CREATED", "comment": null}, "_FIVETRAN_DELETED": {"type": "BOOLEAN", "index": 4, "name": "_FIVETRAN_DELETED", "comment": null}, "FIRST_NAME": {"type": "TEXT", "index": 5, "name": "FIRST_NAME", "comment": null}, "LAST_NAME": {"type": "TEXT", "index": 6, "name": "LAST_NAME", "comment": null}, "ADDRESS_1": {"type": "TEXT", "index": 7, "name": "ADDRESS_1", "comment": null}, "ADDRESS_2": {"type": "TEXT", "index": 8, "name": "ADDRESS_2", "comment": null}, "TITLE": {"type": "TEXT", "index": 9, "name": "TITLE", "comment": null}, "TIMEZONE": {"type": "TEXT", "index": 10, "name": "TIMEZONE", "comment": null}, "ORGANIZATION": {"type": "TEXT", "index": 11, "name": "ORGANIZATION", "comment": null}, "REGION": {"type": "TEXT", "index": 12, "name": "REGION", "comment": null}, "LONGITUDE": {"type": "FLOAT", "index": 13, "name": "LONGITUDE", "comment": null}, "LATITUDE": {"type": "FLOAT", "index": 14, "name": "LATITUDE", "comment": null}, "PHONE_NUMBER": {"type": "TEXT", "index": 15, "name": "PHONE_NUMBER", "comment": null}, "COUNTRY": {"type": "TEXT", "index": 16, "name": "COUNTRY", "comment": null}, "ZIP": {"type": "TEXT", "index": 17, "name": "ZIP", "comment": null}, "CITY": {"type": "TEXT", "index": 18, "name": "CITY", "comment": null}, "EMAIL": {"type": "TEXT", "index": 19, "name": "EMAIL", "comment": null}, "CUSTOM_OBJECT": {"type": "TEXT", "index": 20, "name": "CUSTOM_OBJECT", "comment": null}, "CUSTOM_EMAIL": {"type": "TEXT", "index": 21, "name": "CUSTOM_EMAIL", "comment": null}, "CUSTOM_ACCEPTS_MARKETING": {"type": "TEXT", "index": 22, "name": "CUSTOM_ACCEPTS_MARKETING", "comment": null}, "CUSTOM_SHOPIFY_TAGS": {"type": "VARIANT", "index": 23, "name": "CUSTOM_SHOPIFY_TAGS", "comment": null}, "_FIVETRAN_SYNCED": {"type": "TIMESTAMP_TZ", "index": 24, "name": "_FIVETRAN_SYNCED", "comment": null}, "CUSTOM_CONSENT_FORM_ID": {"type": "TEXT", "index": 25, "name": "CUSTOM_CONSENT_FORM_ID", "comment": null}, "CUSTOM_SOURCE": {"type": "TEXT", "index": 26, "name": "CUSTOM_SOURCE", "comment": null}, "CUSTOM_CONSENT_METHOD": {"type": "TEXT", "index": 27, "name": "CUSTOM_CONSENT_METHOD", "comment": null}, "CUSTOM_CONSENT": {"type": "VARIANT", "index": 28, "name": "CUSTOM_CONSENT", "comment": null}, "CUSTOM_GIFT_GIVER_NAME": {"type": "TEXT", "index": 29, "name": "CUSTOM_GIFT_GIVER_NAME", "comment": null}, "CUSTOM_STATE": {"type": "TEXT", "index": 30, "name": "CUSTOM_STATE", "comment": null}, "CUSTOM_FLOW": {"type": "TEXT", "index": 31, "name": "CUSTOM_FLOW", "comment": null}, "CUSTOM_GIFT_RECIPIENT_NAME": {"type": "TEXT", "index": 32, "name": "CUSTOM_GIFT_RECIPIENT_NAME", "comment": null}, "CUSTOM_LAST_SIGN_IN": {"type": "TIMESTAMP_TZ", "index": 33, "name": "CUSTOM_LAST_SIGN_IN", "comment": null}, "CUSTOM_CONSENT_FORM_VERSION": {"type": "NUMBER", "index": 34, "name": "CUSTOM_CONSENT_FORM_VERSION", "comment": null}, "CUSTOM_CONSENT_TIMESTAMP": {"type": "TIMESTAMP_TZ", "index": 35, "name": "CUSTOM_CONSENT_TIMESTAMP", "comment": null}, "CUSTOM_MAIL_CHIMP_RATING": {"type": "NUMBER", "index": 36, "name": "CUSTOM_MAIL_CHIMP_RATING", "comment": null}, "CUSTOM_GIFT_RECIPIENT_EMAIL": {"type": "TEXT", "index": 37, "name": "CUSTOM_GIFT_RECIPIENT_EMAIL", "comment": null}, "CUSTOM_GIFT_OPTIONS": {"type": "VARIANT", "index": 38, "name": "CUSTOM_GIFT_OPTIONS", "comment": null}, "CUSTOM_ADDRESS": {"type": "TEXT", "index": 39, "name": "CUSTOM_ADDRESS", "comment": null}, "CUSTOM_SUBSCRIPTION_EXPIRATION": {"type": "TIMESTAMP_TZ", "index": 40, "name": "CUSTOM_SUBSCRIPTION_EXPIRATION", "comment": null}, "CUSTOM_CITY": {"type": "TEXT", "index": 41, "name": "CUSTOM_CITY", "comment": null}, "CUSTOM_ADDRESS_LINE_2": {"type": "TEXT", "index": 42, "name": "CUSTOM_ADDRESS_LINE_2", "comment": null}, "CUSTOM_ZIPCODE": {"type": "TEXT", "index": 43, "name": "CUSTOM_ZIPCODE", "comment": null}, "CUSTOM_EXPECTED_DATE_OF_NEXT_ORDER": {"type": "TEXT", "index": 44, "name": "CUSTOM_EXPECTED_DATE_OF_NEXT_ORDER", "comment": null}, "CUSTOM_SMS_ATTENTIVE_SIGNUP": {"type": "BOOLEAN", "index": 45, "name": "CUSTOM_SMS_ATTENTIVE_SIGNUP", "comment": null}, "CUSTOM_PHONE": {"type": "TEXT", "index": 46, "name": "CUSTOM_PHONE", "comment": null}, "CUSTOM_AFTERPAY_ORDER": {"type": "BOOLEAN", "index": 47, "name": "CUSTOM_AFTERPAY_ORDER", "comment": null}, "CUSTOM_PHONE_NUMBER_REGION": {"type": "TEXT", "index": 48, "name": "CUSTOM_PHONE_NUMBER_REGION", "comment": null}, "CUSTOM_NAME": {"type": "TEXT", "index": 49, "name": "CUSTOM_NAME", "comment": null}, "CUSTOM_REFERRER_NAME": {"type": "TEXT", "index": 50, "name": "CUSTOM_REFERRER_NAME", "comment": null}, "CUSTOM_REFERRER_EMAIL": {"type": "TEXT", "index": 51, "name": "CUSTOM_REFERRER_EMAIL", "comment": null}, "CUSTOM_BIRTHDAY": {"type": "TEXT", "index": 52, "name": "CUSTOM_BIRTHDAY", "comment": null}, "CUSTOM_FIRST_PURCHASE_DATE_": {"type": "DATE", "index": 53, "name": "CUSTOM_FIRST_PURCHASE_DATE_", "comment": null}, "CUSTOM_UNENGAGED": {"type": "BOOLEAN", "index": 54, "name": "CUSTOM_UNENGAGED", "comment": null}, "CUSTOM_LANDING_PAGE_TAG": {"type": "TEXT", "index": 55, "name": "CUSTOM_LANDING_PAGE_TAG", "comment": null}, "CUSTOM_FITNESS_GOAL": {"type": "TEXT", "index": 56, "name": "CUSTOM_FITNESS_GOAL", "comment": null}, "CUSTOM_AGE": {"type": "TEXT", "index": 57, "name": "CUSTOM_AGE", "comment": null}, "CUSTOM_WORKOUT": {"type": "TEXT", "index": 58, "name": "CUSTOM_WORKOUT", "comment": null}, "CUSTOM_QUIZ": {"type": "BOOLEAN", "index": 59, "name": "CUSTOM_QUIZ", "comment": null}, "CUSTOM_BREAKFAST": {"type": "TEXT", "index": 60, "name": "CUSTOM_BREAKFAST", "comment": null}, "CUSTOM_QUIZ_DATA": {"type": "BOOLEAN", "index": 61, "name": "CUSTOM_QUIZ_DATA", "comment": null}, "CUSTOM_RAF_SUBSCRIBE": {"type": "BOOLEAN", "index": 62, "name": "CUSTOM_RAF_SUBSCRIBE", "comment": null}, "CUSTOM_SUPPRESS": {"type": "BOOLEAN", "index": 63, "name": "CUSTOM_SUPPRESS", "comment": null}, "CUSTOM_SMS_CONSENT": {"type": "BOOLEAN", "index": 64, "name": "CUSTOM_SMS_CONSENT", "comment": null}, "CUSTOM_GIFT_OPTION_DREAMBELT": {"type": "VARIANT", "index": 65, "name": "CUSTOM_GIFT_OPTION_DREAMBELT", "comment": null}, "CUSTOM_GIFT_OPTION_STARTER": {"type": "VARIANT", "index": 66, "name": "CUSTOM_GIFT_OPTION_STARTER", "comment": null}, "CUSTOM_GIFT_OPTION_MACHINE": {"type": "VARIANT", "index": 67, "name": "CUSTOM_GIFT_OPTION_MACHINE", "comment": null}, "CUSTOM_LANDINGPAGE_TAG": {"type": "TEXT", "index": 68, "name": "CUSTOM_LANDINGPAGE_TAG", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.klaviyo_source.stg_klaviyo__person_tmp"}, "model.klaviyo.klaviyo__events": {"metadata": {"type": "BASE TABLE", "schema": "DBT_FIVETRAN_KLAVIYO", "name": "KLAVIYO__EVENTS", "database": "FIVETRAN_STAGING", "comment": null, "owner": "FIVETRAN_ANALYST"}, "columns": {"VARIATION_ID": {"type": "TEXT", "index": 1, "name": "VARIATION_ID", "comment": null}, "CAMPAIGN_ID": {"type": "TEXT", "index": 2, "name": "CAMPAIGN_ID", "comment": null}, "OCCURRED_AT": {"type": "TIMESTAMP_NTZ", "index": 3, "name": "OCCURRED_AT", "comment": null}, "FLOW_ID": {"type": "TEXT", "index": 4, "name": "FLOW_ID", "comment": null}, "FLOW_MESSAGE_ID": {"type": "TEXT", "index": 5, "name": "FLOW_MESSAGE_ID", "comment": null}, "EVENT_ID": {"type": "TEXT", "index": 6, "name": "EVENT_ID", "comment": null}, "METRIC_ID": {"type": "TEXT", "index": 7, "name": "METRIC_ID", "comment": null}, "PERSON_ID": {"type": "TEXT", "index": 8, "name": "PERSON_ID", "comment": null}, "UUID": {"type": "TEXT", "index": 9, "name": "UUID", "comment": null}, "NUMERIC_VALUE": {"type": "FLOAT", "index": 10, "name": "NUMERIC_VALUE", "comment": null}, "_FIVETRAN_SYNCED": {"type": "TIMESTAMP_TZ", "index": 11, "name": "_FIVETRAN_SYNCED", "comment": null}, "OCCURRED_ON": {"type": "DATE", "index": 12, "name": "OCCURRED_ON", "comment": null}, "TOUCH_TYPE": {"type": "TEXT", "index": 13, "name": "TOUCH_TYPE", "comment": null}, "LAST_TOUCH_TYPE": {"type": "TEXT", "index": 14, "name": "LAST_TOUCH_TYPE", "comment": null}, "TYPE": {"type": "TEXT", "index": 15, "name": "TYPE", "comment": null}, "LAST_TOUCH_CAMPAIGN_ID": {"type": "TEXT", "index": 16, "name": "LAST_TOUCH_CAMPAIGN_ID", "comment": null}, "LAST_TOUCH_FLOW_ID": {"type": "TEXT", "index": 17, "name": "LAST_TOUCH_FLOW_ID", "comment": null}, "LAST_TOUCH_AT": {"type": "TIMESTAMP_NTZ", "index": 18, "name": "LAST_TOUCH_AT", "comment": null}, "LAST_TOUCH_EVENT_TYPE": {"type": "TEXT", "index": 19, "name": "LAST_TOUCH_EVENT_TYPE", "comment": null}, "CAMPAIGN_NAME": {"type": "TEXT", "index": 20, "name": "CAMPAIGN_NAME", "comment": null}, "CAMPAIGN_TYPE": {"type": "TEXT", "index": 21, "name": "CAMPAIGN_TYPE", "comment": null}, "CAMPAIGN_SUBJECT_LINE": {"type": "TEXT", "index": 22, "name": "CAMPAIGN_SUBJECT_LINE", "comment": null}, "FLOW_NAME": {"type": "TEXT", "index": 23, "name": "FLOW_NAME", "comment": null}, "PERSON_CITY": {"type": "TEXT", "index": 24, "name": "PERSON_CITY", "comment": null}, "PERSON_COUNTRY": {"type": "TEXT", "index": 25, "name": "PERSON_COUNTRY", "comment": null}, "PERSON_REGION": {"type": "TEXT", "index": 26, "name": "PERSON_REGION", "comment": null}, "PERSON_EMAIL": {"type": "TEXT", "index": 27, "name": "PERSON_EMAIL", "comment": null}, "PERSON_TIMEZONE": {"type": "TEXT", "index": 28, "name": "PERSON_TIMEZONE", "comment": null}, "INTEGRATION_NAME": {"type": "TEXT", "index": 29, "name": "INTEGRATION_NAME", "comment": null}, "INTEGRATION_CATEGORY": {"type": "TEXT", "index": 30, "name": "INTEGRATION_CATEGORY", "comment": null}}, "stats": {"bytes": {"id": "bytes", "label": "Approximate Size", "value": 849081856.0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2021-05-13 00:18UTC", "include": true, "description": "The timestamp for last update/change"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 15181494.0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.klaviyo.klaviyo__events"}, "model.klaviyo_source.stg_klaviyo__integration_tmp": {"metadata": {"type": "VIEW", "schema": "DBT_FIVETRAN_STG_KLAVIYO", "name": "STG_KLAVIYO__INTEGRATION_TMP", "database": "FIVETRAN_STAGING", "comment": null, "owner": "FIVETRAN_ANALYST"}, "columns": {"ID": {"type": "TEXT", "index": 1, "name": "ID", "comment": null}, "CATEGORY": {"type": "TEXT", "index": 2, "name": "CATEGORY", "comment": null}, "NAME": {"type": "TEXT", "index": 3, "name": "NAME", "comment": null}, "_FIVETRAN_DELETED": {"type": "BOOLEAN", "index": 4, "name": "_FIVETRAN_DELETED", "comment": null}, "_FIVETRAN_SYNCED": {"type": "TIMESTAMP_TZ", "index": 5, "name": "_FIVETRAN_SYNCED", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.klaviyo_source.stg_klaviyo__integration_tmp"}, "model.klaviyo.klaviyo__flows": {"metadata": {"type": "BASE TABLE", "schema": "DBT_FIVETRAN_KLAVIYO", "name": "KLAVIYO__FLOWS", "database": "FIVETRAN_STAGING", "comment": null, "owner": "FIVETRAN_ANALYST"}, "columns": {"CREATED_AT": {"type": "TIMESTAMP_TZ", "index": 1, "name": "CREATED_AT", "comment": null}, "FLOW_ID": {"type": "TEXT", "index": 2, "name": "FLOW_ID", "comment": null}, "FLOW_NAME": {"type": "TEXT", "index": 3, "name": "FLOW_NAME", "comment": null}, "STATUS": {"type": "TEXT", "index": 4, "name": "STATUS", "comment": null}, "FLOW_TRIGGER": {"type": "VARIANT", "index": 5, "name": "FLOW_TRIGGER", "comment": null}, "UPDATED_AT": {"type": "TIMESTAMP_TZ", "index": 6, "name": "UPDATED_AT", "comment": null}, "PERSON_FILTER": {"type": "VARIANT", "index": 7, "name": "PERSON_FILTER", "comment": null}, "VARIATION_ID": {"type": "TEXT", "index": 8, "name": "VARIATION_ID", "comment": null}, "TOTAL_COUNT_UNIQUE_PEOPLE": {"type": "NUMBER", "index": 9, "name": "TOTAL_COUNT_UNIQUE_PEOPLE", "comment": null}, "FIRST_EVENT_AT": {"type": "TIMESTAMP_NTZ", "index": 10, "name": "FIRST_EVENT_AT", "comment": null}, "LAST_EVENT_AT": {"type": "TIMESTAMP_NTZ", "index": 11, "name": "LAST_EVENT_AT", "comment": null}, "SUM_REVENUE_REFUNDED_ORDER": {"type": "FLOAT", "index": 12, "name": "SUM_REVENUE_REFUNDED_ORDER", "comment": null}, "SUM_REVENUE_PLACED_ORDER": {"type": "FLOAT", "index": 13, "name": "SUM_REVENUE_PLACED_ORDER", "comment": null}, "SUM_REVENUE_ORDERED_PRODUCT": {"type": "FLOAT", "index": 14, "name": "SUM_REVENUE_ORDERED_PRODUCT", "comment": null}, "SUM_REVENUE_CHECKOUT_STARTED": {"type": "FLOAT", "index": 15, "name": "SUM_REVENUE_CHECKOUT_STARTED", "comment": null}, "SUM_REVENUE_CANCELLED_ORDER": {"type": "FLOAT", "index": 16, "name": "SUM_REVENUE_CANCELLED_ORDER", "comment": null}, "COUNT_ACTIVE_ON_SITE": {"type": "NUMBER", "index": 17, "name": "COUNT_ACTIVE_ON_SITE", "comment": null}, "UNIQUE_COUNT_ACTIVE_ON_SITE": {"type": "NUMBER", "index": 18, "name": "UNIQUE_COUNT_ACTIVE_ON_SITE", "comment": null}, "COUNT_VIEWED_PRODUCT": {"type": "NUMBER", "index": 19, "name": "COUNT_VIEWED_PRODUCT", "comment": null}, "UNIQUE_COUNT_VIEWED_PRODUCT": {"type": "NUMBER", "index": 20, "name": "UNIQUE_COUNT_VIEWED_PRODUCT", "comment": null}, "COUNT_ORDERED_PRODUCT": {"type": "NUMBER", "index": 21, "name": "COUNT_ORDERED_PRODUCT", "comment": null}, "UNIQUE_COUNT_ORDERED_PRODUCT": {"type": "NUMBER", "index": 22, "name": "UNIQUE_COUNT_ORDERED_PRODUCT", "comment": null}, "COUNT_PLACED_ORDER": {"type": "NUMBER", "index": 23, "name": "COUNT_PLACED_ORDER", "comment": null}, "UNIQUE_COUNT_PLACED_ORDER": {"type": "NUMBER", "index": 24, "name": "UNIQUE_COUNT_PLACED_ORDER", "comment": null}, "COUNT_REFUNDED_ORDER": {"type": "NUMBER", "index": 25, "name": "COUNT_REFUNDED_ORDER", "comment": null}, "UNIQUE_COUNT_REFUNDED_ORDER": {"type": "NUMBER", "index": 26, "name": "UNIQUE_COUNT_REFUNDED_ORDER", "comment": null}, "COUNT_RECEIVED_EMAIL": {"type": "NUMBER", "index": 27, "name": "COUNT_RECEIVED_EMAIL", "comment": null}, "UNIQUE_COUNT_RECEIVED_EMAIL": {"type": "NUMBER", "index": 28, "name": "UNIQUE_COUNT_RECEIVED_EMAIL", "comment": null}, "COUNT_CLICKED_EMAIL": {"type": "NUMBER", "index": 29, "name": "COUNT_CLICKED_EMAIL", "comment": null}, "UNIQUE_COUNT_CLICKED_EMAIL": {"type": "NUMBER", "index": 30, "name": "UNIQUE_COUNT_CLICKED_EMAIL", "comment": null}, "COUNT_OPENED_EMAIL": {"type": "NUMBER", "index": 31, "name": "COUNT_OPENED_EMAIL", "comment": null}, "UNIQUE_COUNT_OPENED_EMAIL": {"type": "NUMBER", "index": 32, "name": "UNIQUE_COUNT_OPENED_EMAIL", "comment": null}, "COUNT_MARKED_EMAIL_AS_SPAM": {"type": "NUMBER", "index": 33, "name": "COUNT_MARKED_EMAIL_AS_SPAM", "comment": null}, "UNIQUE_COUNT_MARKED_EMAIL_AS_SPAM": {"type": "NUMBER", "index": 34, "name": "UNIQUE_COUNT_MARKED_EMAIL_AS_SPAM", "comment": null}, "COUNT_UNSUBSCRIBED": {"type": "NUMBER", "index": 35, "name": "COUNT_UNSUBSCRIBED", "comment": null}, "UNIQUE_COUNT_UNSUBSCRIBED": {"type": "NUMBER", "index": 36, "name": "UNIQUE_COUNT_UNSUBSCRIBED", "comment": null}, "COUNT_RECEIVED_SMS": {"type": "NUMBER", "index": 37, "name": "COUNT_RECEIVED_SMS", "comment": null}, "UNIQUE_COUNT_RECEIVED_SMS": {"type": "NUMBER", "index": 38, "name": "UNIQUE_COUNT_RECEIVED_SMS", "comment": null}, "COUNT_CLICKED_SMS": {"type": "NUMBER", "index": 39, "name": "COUNT_CLICKED_SMS", "comment": null}, "UNIQUE_COUNT_CLICKED_SMS": {"type": "NUMBER", "index": 40, "name": "UNIQUE_COUNT_CLICKED_SMS", "comment": null}, "COUNT_SENT_SMS": {"type": "NUMBER", "index": 41, "name": "COUNT_SENT_SMS", "comment": null}, "UNIQUE_COUNT_SENT_SMS": {"type": "NUMBER", "index": 42, "name": "UNIQUE_COUNT_SENT_SMS", "comment": null}, "COUNT_UNSUBSCRIBED_FROM_SMS": {"type": "NUMBER", "index": 43, "name": "COUNT_UNSUBSCRIBED_FROM_SMS", "comment": null}, "UNIQUE_COUNT_UNSUBSCRIBED_FROM_SMS": {"type": "NUMBER", "index": 44, "name": "UNIQUE_COUNT_UNSUBSCRIBED_FROM_SMS", "comment": null}, "FLOW_VARIATION_KEY": {"type": "TEXT", "index": 45, "name": "FLOW_VARIATION_KEY", "comment": null}}, "stats": {"bytes": {"id": "bytes", "label": "Approximate Size", "value": 292864.0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2021-05-13 00:19UTC", "include": true, "description": "The timestamp for last update/change"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 87.0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.klaviyo.klaviyo__flows"}, "model.klaviyo.klaviyo__persons": {"metadata": {"type": "BASE TABLE", "schema": "DBT_FIVETRAN_KLAVIYO", "name": "KLAVIYO__PERSONS", "database": "FIVETRAN_STAGING", "comment": null, "owner": "FIVETRAN_ANALYST"}, "columns": {"PERSON_ID": {"type": "TEXT", "index": 1, "name": "PERSON_ID", "comment": null}, "ADDRESS_1": {"type": "TEXT", "index": 2, "name": "ADDRESS_1", "comment": null}, "ADDRESS_2": {"type": "TEXT", "index": 3, "name": "ADDRESS_2", "comment": null}, "CITY": {"type": "TEXT", "index": 4, "name": "CITY", "comment": null}, "COUNTRY": {"type": "TEXT", "index": 5, "name": "COUNTRY", "comment": null}, "ZIP": {"type": "TEXT", "index": 6, "name": "ZIP", "comment": null}, "CREATED_AT": {"type": "TIMESTAMP_TZ", "index": 7, "name": "CREATED_AT", "comment": null}, "EMAIL": {"type": "TEXT", "index": 8, "name": "EMAIL", "comment": null}, "FULL_NAME": {"type": "TEXT", "index": 9, "name": "FULL_NAME", "comment": null}, "LATITUDE": {"type": "FLOAT", "index": 10, "name": "LATITUDE", "comment": null}, "LONGITUDE": {"type": "FLOAT", "index": 11, "name": "LONGITUDE", "comment": null}, "ORGANIZATION": {"type": "TEXT", "index": 12, "name": "ORGANIZATION", "comment": null}, "PHONE_NUMBER": {"type": "TEXT", "index": 13, "name": "PHONE_NUMBER", "comment": null}, "REGION": {"type": "TEXT", "index": 14, "name": "REGION", "comment": null}, "TIMEZONE": {"type": "TEXT", "index": 15, "name": "TIMEZONE", "comment": null}, "TITLE": {"type": "TEXT", "index": 16, "name": "TITLE", "comment": null}, "UPDATED_AT": {"type": "TIMESTAMP_TZ", "index": 17, "name": "UPDATED_AT", "comment": null}, "COUNT_TOTAL_CAMPAIGNS": {"type": "NUMBER", "index": 18, "name": "COUNT_TOTAL_CAMPAIGNS", "comment": null}, "COUNT_TOTAL_FLOWS": {"type": "NUMBER", "index": 19, "name": "COUNT_TOTAL_FLOWS", "comment": null}, "FIRST_EVENT_AT": {"type": "TIMESTAMP_NTZ", "index": 20, "name": "FIRST_EVENT_AT", "comment": null}, "LAST_EVENT_AT": {"type": "TIMESTAMP_NTZ", "index": 21, "name": "LAST_EVENT_AT", "comment": null}, "FIRST_CAMPAIGN_TOUCH_AT": {"type": "TIMESTAMP_NTZ", "index": 22, "name": "FIRST_CAMPAIGN_TOUCH_AT", "comment": null}, "LAST_CAMPAIGN_TOUCH_AT": {"type": "TIMESTAMP_NTZ", "index": 23, "name": "LAST_CAMPAIGN_TOUCH_AT", "comment": null}, "FIRST_FLOW_TOUCH_AT": {"type": "TIMESTAMP_NTZ", "index": 24, "name": "FIRST_FLOW_TOUCH_AT", "comment": null}, "LAST_FLOW_TOUCH_AT": {"type": "TIMESTAMP_NTZ", "index": 25, "name": "LAST_FLOW_TOUCH_AT", "comment": null}, "TOTAL_SUM_REVENUE_REFUNDED_ORDER": {"type": "FLOAT", "index": 26, "name": "TOTAL_SUM_REVENUE_REFUNDED_ORDER", "comment": null}, "ORGANIC_SUM_REVENUE_REFUNDED_ORDER": {"type": "FLOAT", "index": 27, "name": "ORGANIC_SUM_REVENUE_REFUNDED_ORDER", "comment": null}, "TOTAL_SUM_REVENUE_PLACED_ORDER": {"type": "FLOAT", "index": 28, "name": "TOTAL_SUM_REVENUE_PLACED_ORDER", "comment": null}, "ORGANIC_SUM_REVENUE_PLACED_ORDER": {"type": "FLOAT", "index": 29, "name": "ORGANIC_SUM_REVENUE_PLACED_ORDER", "comment": null}, "TOTAL_SUM_REVENUE_ORDERED_PRODUCT": {"type": "FLOAT", "index": 30, "name": "TOTAL_SUM_REVENUE_ORDERED_PRODUCT", "comment": null}, "ORGANIC_SUM_REVENUE_ORDERED_PRODUCT": {"type": "FLOAT", "index": 31, "name": "ORGANIC_SUM_REVENUE_ORDERED_PRODUCT", "comment": null}, "TOTAL_SUM_REVENUE_CHECKOUT_STARTED": {"type": "FLOAT", "index": 32, "name": "TOTAL_SUM_REVENUE_CHECKOUT_STARTED", "comment": null}, "ORGANIC_SUM_REVENUE_CHECKOUT_STARTED": {"type": "FLOAT", "index": 33, "name": "ORGANIC_SUM_REVENUE_CHECKOUT_STARTED", "comment": null}, "TOTAL_SUM_REVENUE_CANCELLED_ORDER": {"type": "FLOAT", "index": 34, "name": "TOTAL_SUM_REVENUE_CANCELLED_ORDER", "comment": null}, "ORGANIC_SUM_REVENUE_CANCELLED_ORDER": {"type": "FLOAT", "index": 35, "name": "ORGANIC_SUM_REVENUE_CANCELLED_ORDER", "comment": null}, "TOTAL_COUNT_ACTIVE_ON_SITE": {"type": "NUMBER", "index": 36, "name": "TOTAL_COUNT_ACTIVE_ON_SITE", "comment": null}, "TOTAL_COUNT_VIEWED_PRODUCT": {"type": "NUMBER", "index": 37, "name": "TOTAL_COUNT_VIEWED_PRODUCT", "comment": null}, "TOTAL_COUNT_ORDERED_PRODUCT": {"type": "NUMBER", "index": 38, "name": "TOTAL_COUNT_ORDERED_PRODUCT", "comment": null}, "TOTAL_COUNT_PLACED_ORDER": {"type": "NUMBER", "index": 39, "name": "TOTAL_COUNT_PLACED_ORDER", "comment": null}, "TOTAL_COUNT_REFUNDED_ORDER": {"type": "NUMBER", "index": 40, "name": "TOTAL_COUNT_REFUNDED_ORDER", "comment": null}, "TOTAL_COUNT_RECEIVED_EMAIL": {"type": "NUMBER", "index": 41, "name": "TOTAL_COUNT_RECEIVED_EMAIL", "comment": null}, "TOTAL_COUNT_CLICKED_EMAIL": {"type": "NUMBER", "index": 42, "name": "TOTAL_COUNT_CLICKED_EMAIL", "comment": null}, "TOTAL_COUNT_OPENED_EMAIL": {"type": "NUMBER", "index": 43, "name": "TOTAL_COUNT_OPENED_EMAIL", "comment": null}, "TOTAL_COUNT_MARKED_EMAIL_AS_SPAM": {"type": "NUMBER", "index": 44, "name": "TOTAL_COUNT_MARKED_EMAIL_AS_SPAM", "comment": null}, "TOTAL_COUNT_UNSUBSCRIBED": {"type": "NUMBER", "index": 45, "name": "TOTAL_COUNT_UNSUBSCRIBED", "comment": null}, "TOTAL_COUNT_RECEIVED_SMS": {"type": "NUMBER", "index": 46, "name": "TOTAL_COUNT_RECEIVED_SMS", "comment": null}, "TOTAL_COUNT_CLICKED_SMS": {"type": "NUMBER", "index": 47, "name": "TOTAL_COUNT_CLICKED_SMS", "comment": null}, "TOTAL_COUNT_SENT_SMS": {"type": "NUMBER", "index": 48, "name": "TOTAL_COUNT_SENT_SMS", "comment": null}, "TOTAL_COUNT_UNSUBSCRIBED_FROM_SMS": {"type": "NUMBER", "index": 49, "name": "TOTAL_COUNT_UNSUBSCRIBED_FROM_SMS", "comment": null}}, "stats": {"bytes": {"id": "bytes", "label": "Approximate Size", "value": 82117632.0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2021-05-13 00:19UTC", "include": true, "description": "The timestamp for last update/change"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 683969.0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.klaviyo.klaviyo__persons"}, "model.klaviyo.klaviyo__person_campaign_flow": {"metadata": {"type": "BASE TABLE", "schema": "DBT_FIVETRAN_KLAVIYO", "name": "KLAVIYO__PERSON_CAMPAIGN_FLOW", "database": "FIVETRAN_STAGING", "comment": null, "owner": "FIVETRAN_ANALYST"}, "columns": {"PERSON_ID": {"type": "TEXT", "index": 1, "name": "PERSON_ID", "comment": null}, "LAST_TOUCH_CAMPAIGN_ID": {"type": "TEXT", "index": 2, "name": "LAST_TOUCH_CAMPAIGN_ID", "comment": null}, "LAST_TOUCH_FLOW_ID": {"type": "TEXT", "index": 3, "name": "LAST_TOUCH_FLOW_ID", "comment": null}, "CAMPAIGN_NAME": {"type": "TEXT", "index": 4, "name": "CAMPAIGN_NAME", "comment": null}, "FLOW_NAME": {"type": "TEXT", "index": 5, "name": "FLOW_NAME", "comment": null}, "VARIATION_ID": {"type": "TEXT", "index": 6, "name": "VARIATION_ID", "comment": null}, "FIRST_EVENT_AT": {"type": "TIMESTAMP_NTZ", "index": 7, "name": "FIRST_EVENT_AT", "comment": null}, "LAST_EVENT_AT": {"type": "TIMESTAMP_NTZ", "index": 8, "name": "LAST_EVENT_AT", "comment": null}, "SUM_REVENUE_REFUNDED_ORDER": {"type": "FLOAT", "index": 9, "name": "SUM_REVENUE_REFUNDED_ORDER", "comment": null}, "SUM_REVENUE_PLACED_ORDER": {"type": "FLOAT", "index": 10, "name": "SUM_REVENUE_PLACED_ORDER", "comment": null}, "SUM_REVENUE_ORDERED_PRODUCT": {"type": "FLOAT", "index": 11, "name": "SUM_REVENUE_ORDERED_PRODUCT", "comment": null}, "SUM_REVENUE_CHECKOUT_STARTED": {"type": "FLOAT", "index": 12, "name": "SUM_REVENUE_CHECKOUT_STARTED", "comment": null}, "SUM_REVENUE_CANCELLED_ORDER": {"type": "FLOAT", "index": 13, "name": "SUM_REVENUE_CANCELLED_ORDER", "comment": null}, "COUNT_ACTIVE_ON_SITE": {"type": "NUMBER", "index": 14, "name": "COUNT_ACTIVE_ON_SITE", "comment": null}, "COUNT_VIEWED_PRODUCT": {"type": "NUMBER", "index": 15, "name": "COUNT_VIEWED_PRODUCT", "comment": null}, "COUNT_ORDERED_PRODUCT": {"type": "NUMBER", "index": 16, "name": "COUNT_ORDERED_PRODUCT", "comment": null}, "COUNT_PLACED_ORDER": {"type": "NUMBER", "index": 17, "name": "COUNT_PLACED_ORDER", "comment": null}, "COUNT_REFUNDED_ORDER": {"type": "NUMBER", "index": 18, "name": "COUNT_REFUNDED_ORDER", "comment": null}, "COUNT_RECEIVED_EMAIL": {"type": "NUMBER", "index": 19, "name": "COUNT_RECEIVED_EMAIL", "comment": null}, "COUNT_CLICKED_EMAIL": {"type": "NUMBER", "index": 20, "name": "COUNT_CLICKED_EMAIL", "comment": null}, "COUNT_OPENED_EMAIL": {"type": "NUMBER", "index": 21, "name": "COUNT_OPENED_EMAIL", "comment": null}, "COUNT_MARKED_EMAIL_AS_SPAM": {"type": "NUMBER", "index": 22, "name": "COUNT_MARKED_EMAIL_AS_SPAM", "comment": null}, "COUNT_UNSUBSCRIBED": {"type": "NUMBER", "index": 23, "name": "COUNT_UNSUBSCRIBED", "comment": null}, "COUNT_RECEIVED_SMS": {"type": "NUMBER", "index": 24, "name": "COUNT_RECEIVED_SMS", "comment": null}, "COUNT_CLICKED_SMS": {"type": "NUMBER", "index": 25, "name": "COUNT_CLICKED_SMS", "comment": null}, "COUNT_SENT_SMS": {"type": "NUMBER", "index": 26, "name": "COUNT_SENT_SMS", "comment": null}, "COUNT_UNSUBSCRIBED_FROM_SMS": {"type": "NUMBER", "index": 27, "name": "COUNT_UNSUBSCRIBED_FROM_SMS", "comment": null}}, "stats": {"bytes": {"id": "bytes", "label": "Approximate Size", "value": 248420352.0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2021-05-13 00:19UTC", "include": true, "description": "The timestamp for last update/change"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 7091092.0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.klaviyo.klaviyo__person_campaign_flow"}, "model.klaviyo_source.stg_klaviyo__metric_tmp": {"metadata": {"type": "VIEW", "schema": "DBT_FIVETRAN_STG_KLAVIYO", "name": "STG_KLAVIYO__METRIC_TMP", "database": "FIVETRAN_STAGING", "comment": null, "owner": "FIVETRAN_ANALYST"}, "columns": {"ID": {"type": "TEXT", "index": 1, "name": "ID", "comment": null}, "NAME": {"type": "TEXT", "index": 2, "name": "NAME", "comment": null}, "INTEGRATION_ID": {"type": "TEXT", "index": 3, "name": "INTEGRATION_ID", "comment": null}, "CREATED": {"type": "TIMESTAMP_TZ", "index": 4, "name": "CREATED", "comment": null}, "UPDATED": {"type": "TIMESTAMP_TZ", "index": 5, "name": "UPDATED", "comment": null}, "_FIVETRAN_DELETED": {"type": "BOOLEAN", "index": 6, "name": "_FIVETRAN_DELETED", "comment": null}, "_FIVETRAN_SYNCED": {"type": "TIMESTAMP_TZ", "index": 7, "name": "_FIVETRAN_SYNCED", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.klaviyo_source.stg_klaviyo__metric_tmp"}, "model.klaviyo_source.stg_klaviyo__campaign": {"metadata": {"type": "BASE TABLE", "schema": "DBT_FIVETRAN_STG_KLAVIYO", "name": "STG_KLAVIYO__CAMPAIGN", "database": "FIVETRAN_STAGING", "comment": null, "owner": "FIVETRAN_ANALYST"}, "columns": {"CAMPAIGN_TYPE": {"type": "TEXT", "index": 1, "name": "CAMPAIGN_TYPE", "comment": null}, "CREATED_AT": {"type": "TIMESTAMP_TZ", "index": 2, "name": "CREATED_AT", "comment": null}, "EMAIL_TEMPLATE_ID": {"type": "TEXT", "index": 3, "name": "EMAIL_TEMPLATE_ID", "comment": null}, "FROM_EMAIL": {"type": "TEXT", "index": 4, "name": "FROM_EMAIL", "comment": null}, "FROM_NAME": {"type": "TEXT", "index": 5, "name": "FROM_NAME", "comment": null}, "CAMPAIGN_ID": {"type": "TEXT", "index": 6, "name": "CAMPAIGN_ID", "comment": null}, "IS_SEGMENTED": {"type": "BOOLEAN", "index": 7, "name": "IS_SEGMENTED", "comment": null}, "CAMPAIGN_NAME": {"type": "TEXT", "index": 8, "name": "CAMPAIGN_NAME", "comment": null}, "SCHEDULED_TO_SEND_AT": {"type": "TIMESTAMP_TZ", "index": 9, "name": "SCHEDULED_TO_SEND_AT", "comment": null}, "SENT_AT": {"type": "TIMESTAMP_TZ", "index": 10, "name": "SENT_AT", "comment": null}, "STATUS": {"type": "TEXT", "index": 11, "name": "STATUS", "comment": null}, "STATUS_ID": {"type": "TEXT", "index": 12, "name": "STATUS_ID", "comment": null}, "SUBJECT": {"type": "TEXT", "index": 13, "name": "SUBJECT", "comment": null}, "UPDATED_AT": {"type": "TIMESTAMP_TZ", "index": 14, "name": "UPDATED_AT", "comment": null}}, "stats": {"bytes": {"id": "bytes", "label": "Approximate Size", "value": 13312.0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2021-05-13 00:17UTC", "include": true, "description": "The timestamp for last update/change"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 98.0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.klaviyo_source.stg_klaviyo__campaign"}, "model.klaviyo_source.stg_klaviyo__person": {"metadata": {"type": "BASE TABLE", "schema": "DBT_FIVETRAN_STG_KLAVIYO", "name": "STG_KLAVIYO__PERSON", "database": "FIVETRAN_STAGING", "comment": null, "owner": "FIVETRAN_ANALYST"}, "columns": {"PERSON_ID": {"type": "TEXT", "index": 1, "name": "PERSON_ID", "comment": null}, "ADDRESS_1": {"type": "TEXT", "index": 2, "name": "ADDRESS_1", "comment": null}, "ADDRESS_2": {"type": "TEXT", "index": 3, "name": "ADDRESS_2", "comment": null}, "CITY": {"type": "TEXT", "index": 4, "name": "CITY", "comment": null}, "COUNTRY": {"type": "TEXT", "index": 5, "name": "COUNTRY", "comment": null}, "ZIP": {"type": "TEXT", "index": 6, "name": "ZIP", "comment": null}, "CREATED_AT": {"type": "TIMESTAMP_TZ", "index": 7, "name": "CREATED_AT", "comment": null}, "EMAIL": {"type": "TEXT", "index": 8, "name": "EMAIL", "comment": null}, "FULL_NAME": {"type": "TEXT", "index": 9, "name": "FULL_NAME", "comment": null}, "LATITUDE": {"type": "FLOAT", "index": 10, "name": "LATITUDE", "comment": null}, "LONGITUDE": {"type": "FLOAT", "index": 11, "name": "LONGITUDE", "comment": null}, "ORGANIZATION": {"type": "TEXT", "index": 12, "name": "ORGANIZATION", "comment": null}, "PHONE_NUMBER": {"type": "TEXT", "index": 13, "name": "PHONE_NUMBER", "comment": null}, "REGION": {"type": "TEXT", "index": 14, "name": "REGION", "comment": null}, "TIMEZONE": {"type": "TEXT", "index": 15, "name": "TIMEZONE", "comment": null}, "TITLE": {"type": "TEXT", "index": 16, "name": "TITLE", "comment": null}, "UPDATED_AT": {"type": "TIMESTAMP_TZ", "index": 17, "name": "UPDATED_AT", "comment": null}}, "stats": {"bytes": {"id": "bytes", "label": "Approximate Size", "value": 46069248.0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2021-05-13 00:17UTC", "include": true, "description": "The timestamp for last update/change"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 683969.0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.klaviyo_source.stg_klaviyo__person"}, "model.klaviyo_source.stg_klaviyo__integration": {"metadata": {"type": "BASE TABLE", "schema": "DBT_FIVETRAN_STG_KLAVIYO", "name": "STG_KLAVIYO__INTEGRATION", "database": "FIVETRAN_STAGING", "comment": null, "owner": "FIVETRAN_ANALYST"}, "columns": {"CATEGORY": {"type": "TEXT", "index": 1, "name": "CATEGORY", "comment": null}, "INTEGRATION_ID": {"type": "TEXT", "index": 2, "name": "INTEGRATION_ID", "comment": null}, "INTEGRATION_NAME": {"type": "TEXT", "index": 3, "name": "INTEGRATION_NAME", "comment": null}}, "stats": {"bytes": {"id": "bytes", "label": "Approximate Size", "value": 1536.0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2021-05-13 00:17UTC", "include": true, "description": "The timestamp for last update/change"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 5.0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.klaviyo_source.stg_klaviyo__integration"}, "model.klaviyo_source.stg_klaviyo__flow_tmp": {"metadata": {"type": "VIEW", "schema": "DBT_FIVETRAN_STG_KLAVIYO", "name": "STG_KLAVIYO__FLOW_TMP", "database": "FIVETRAN_STAGING", "comment": null, "owner": "FIVETRAN_ANALYST"}, "columns": {"ID": {"type": "TEXT", "index": 1, "name": "ID", "comment": null}, "NAME": {"type": "TEXT", "index": 2, "name": "NAME", "comment": null}, "STATUS": {"type": "TEXT", "index": 3, "name": "STATUS", "comment": null}, "CREATED": {"type": "TIMESTAMP_TZ", "index": 4, "name": "CREATED", "comment": null}, "UPDATED": {"type": "TIMESTAMP_TZ", "index": 5, "name": "UPDATED", "comment": null}, "CUSTOMER_FILTER": {"type": "VARIANT", "index": 6, "name": "CUSTOMER_FILTER", "comment": null}, "TRIGGER": {"type": "VARIANT", "index": 7, "name": "TRIGGER", "comment": null}, "_FIVETRAN_DELETED": {"type": "BOOLEAN", "index": 8, "name": "_FIVETRAN_DELETED", "comment": null}, "_FIVETRAN_SYNCED": {"type": "TIMESTAMP_TZ", "index": 9, "name": "_FIVETRAN_SYNCED", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.klaviyo_source.stg_klaviyo__flow_tmp"}, "model.klaviyo_source.stg_klaviyo__campaign_tmp": {"metadata": {"type": "VIEW", "schema": "DBT_FIVETRAN_STG_KLAVIYO", "name": "STG_KLAVIYO__CAMPAIGN_TMP", "database": "FIVETRAN_STAGING", "comment": null, "owner": "FIVETRAN_ANALYST"}, "columns": {"ID": {"type": "TEXT", "index": 1, "name": "ID", "comment": null}, "FROM_NAME": {"type": "TEXT", "index": 2, "name": "FROM_NAME", "comment": null}, "STATUS_ID": {"type": "TEXT", "index": 3, "name": "STATUS_ID", "comment": null}, "IS_SEGMENTED": {"type": "BOOLEAN", "index": 4, "name": "IS_SEGMENTED", "comment": null}, "CAMPAIGN_TYPE": {"type": "TEXT", "index": 5, "name": "CAMPAIGN_TYPE", "comment": null}, "STATUS_LABEL": {"type": "TEXT", "index": 6, "name": "STATUS_LABEL", "comment": null}, "FROM_EMAIL": {"type": "TEXT", "index": 7, "name": "FROM_EMAIL", "comment": null}, "SUBJECT": {"type": "TEXT", "index": 8, "name": "SUBJECT", "comment": null}, "NAME": {"type": "TEXT", "index": 9, "name": "NAME", "comment": null}, "STATUS": {"type": "TEXT", "index": 10, "name": "STATUS", "comment": null}, "CREATED": {"type": "TIMESTAMP_TZ", "index": 11, "name": "CREATED", "comment": null}, "UPDATED": {"type": "TIMESTAMP_TZ", "index": 12, "name": "UPDATED", "comment": null}, "SEND_TIME": {"type": "TIMESTAMP_TZ", "index": 13, "name": "SEND_TIME", "comment": null}, "SENT_AT": {"type": "TIMESTAMP_TZ", "index": 14, "name": "SENT_AT", "comment": null}, "_FIVETRAN_DELETED": {"type": "BOOLEAN", "index": 15, "name": "_FIVETRAN_DELETED", "comment": null}, "EMAIL_TEMPLATE_ID": {"type": "TEXT", "index": 16, "name": "EMAIL_TEMPLATE_ID", "comment": null}, "_FIVETRAN_SYNCED": {"type": "TIMESTAMP_TZ", "index": 17, "name": "_FIVETRAN_SYNCED", "comment": null}}, "stats": {"has_stats": {"id": "has_stats", "label": "Has Stats?", "value": false, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.klaviyo_source.stg_klaviyo__campaign_tmp"}, "model.klaviyo_source.stg_klaviyo__event": {"metadata": {"type": "BASE TABLE", "schema": "DBT_FIVETRAN_STG_KLAVIYO", "name": "STG_KLAVIYO__EVENT", "database": "FIVETRAN_STAGING", "comment": null, "owner": "FIVETRAN_ANALYST"}, "columns": {"VARIATION_ID": {"type": "TEXT", "index": 1, "name": "VARIATION_ID", "comment": null}, "CAMPAIGN_ID": {"type": "TEXT", "index": 2, "name": "CAMPAIGN_ID", "comment": null}, "OCCURRED_AT": {"type": "TIMESTAMP_NTZ", "index": 3, "name": "OCCURRED_AT", "comment": null}, "FLOW_ID": {"type": "TEXT", "index": 4, "name": "FLOW_ID", "comment": null}, "FLOW_MESSAGE_ID": {"type": "TEXT", "index": 5, "name": "FLOW_MESSAGE_ID", "comment": null}, "EVENT_ID": {"type": "TEXT", "index": 6, "name": "EVENT_ID", "comment": null}, "METRIC_ID": {"type": "TEXT", "index": 7, "name": "METRIC_ID", "comment": null}, "PERSON_ID": {"type": "TEXT", "index": 8, "name": "PERSON_ID", "comment": null}, "TYPE": {"type": "TEXT", "index": 9, "name": "TYPE", "comment": null}, "UUID": {"type": "TEXT", "index": 10, "name": "UUID", "comment": null}, "NUMERIC_VALUE": {"type": "FLOAT", "index": 11, "name": "NUMERIC_VALUE", "comment": null}, "_FIVETRAN_SYNCED": {"type": "TIMESTAMP_TZ", "index": 12, "name": "_FIVETRAN_SYNCED", "comment": null}, "OCCURRED_ON": {"type": "DATE", "index": 13, "name": "OCCURRED_ON", "comment": null}}, "stats": {"bytes": {"id": "bytes", "label": "Approximate Size", "value": 700953088.0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2021-05-13 00:17UTC", "include": true, "description": "The timestamp for last update/change"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 15181494.0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.klaviyo_source.stg_klaviyo__event"}, "model.klaviyo_source.stg_klaviyo__flow": {"metadata": {"type": "BASE TABLE", "schema": "DBT_FIVETRAN_STG_KLAVIYO", "name": "STG_KLAVIYO__FLOW", "database": "FIVETRAN_STAGING", "comment": null, "owner": "FIVETRAN_ANALYST"}, "columns": {"CREATED_AT": {"type": "TIMESTAMP_TZ", "index": 1, "name": "CREATED_AT", "comment": null}, "FLOW_ID": {"type": "TEXT", "index": 2, "name": "FLOW_ID", "comment": null}, "FLOW_NAME": {"type": "TEXT", "index": 3, "name": "FLOW_NAME", "comment": null}, "STATUS": {"type": "TEXT", "index": 4, "name": "STATUS", "comment": null}, "FLOW_TRIGGER": {"type": "VARIANT", "index": 5, "name": "FLOW_TRIGGER", "comment": null}, "UPDATED_AT": {"type": "TIMESTAMP_TZ", "index": 6, "name": "UPDATED_AT", "comment": null}, "PERSON_FILTER": {"type": "VARIANT", "index": 7, "name": "PERSON_FILTER", "comment": null}}, "stats": {"bytes": {"id": "bytes", "label": "Approximate Size", "value": 52736.0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2021-05-13 00:17UTC", "include": true, "description": "The timestamp for last update/change"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 57.0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "model.klaviyo_source.stg_klaviyo__flow"}}, "sources": {"source.klaviyo_source.klaviyo.person": {"metadata": {"type": "BASE TABLE", "schema": "KLAVIYO", "name": "PERSON", "database": "FIVETRAN_STAGING", "comment": null, "owner": "FIVETRAN_ROLE"}, "columns": {"ID": {"type": "TEXT", "index": 1, "name": "ID", "comment": null}, "UPDATED": {"type": "TIMESTAMP_TZ", "index": 2, "name": "UPDATED", "comment": null}, "CREATED": {"type": "TIMESTAMP_TZ", "index": 3, "name": "CREATED", "comment": null}, "_FIVETRAN_DELETED": {"type": "BOOLEAN", "index": 4, "name": "_FIVETRAN_DELETED", "comment": null}, "FIRST_NAME": {"type": "TEXT", "index": 5, "name": "FIRST_NAME", "comment": null}, "LAST_NAME": {"type": "TEXT", "index": 6, "name": "LAST_NAME", "comment": null}, "ADDRESS_1": {"type": "TEXT", "index": 7, "name": "ADDRESS_1", "comment": null}, "ADDRESS_2": {"type": "TEXT", "index": 8, "name": "ADDRESS_2", "comment": null}, "TITLE": {"type": "TEXT", "index": 9, "name": "TITLE", "comment": null}, "TIMEZONE": {"type": "TEXT", "index": 10, "name": "TIMEZONE", "comment": null}, "ORGANIZATION": {"type": "TEXT", "index": 11, "name": "ORGANIZATION", "comment": null}, "REGION": {"type": "TEXT", "index": 12, "name": "REGION", "comment": null}, "LONGITUDE": {"type": "FLOAT", "index": 13, "name": "LONGITUDE", "comment": null}, "LATITUDE": {"type": "FLOAT", "index": 14, "name": "LATITUDE", "comment": null}, "PHONE_NUMBER": {"type": "TEXT", "index": 15, "name": "PHONE_NUMBER", "comment": null}, "COUNTRY": {"type": "TEXT", "index": 16, "name": "COUNTRY", "comment": null}, "ZIP": {"type": "TEXT", "index": 17, "name": "ZIP", "comment": null}, "CITY": {"type": "TEXT", "index": 18, "name": "CITY", "comment": null}, "EMAIL": {"type": "TEXT", "index": 19, "name": "EMAIL", "comment": null}, "CUSTOM_OBJECT": {"type": "TEXT", "index": 20, "name": "CUSTOM_OBJECT", "comment": null}, "CUSTOM_EMAIL": {"type": "TEXT", "index": 21, "name": "CUSTOM_EMAIL", "comment": null}, "CUSTOM_ACCEPTS_MARKETING": {"type": "TEXT", "index": 22, "name": "CUSTOM_ACCEPTS_MARKETING", "comment": null}, "CUSTOM_SHOPIFY_TAGS": {"type": "VARIANT", "index": 23, "name": "CUSTOM_SHOPIFY_TAGS", "comment": null}, "_FIVETRAN_SYNCED": {"type": "TIMESTAMP_TZ", "index": 24, "name": "_FIVETRAN_SYNCED", "comment": null}, "CUSTOM_CONSENT_FORM_ID": {"type": "TEXT", "index": 25, "name": "CUSTOM_CONSENT_FORM_ID", "comment": null}, "CUSTOM_SOURCE": {"type": "TEXT", "index": 26, "name": "CUSTOM_SOURCE", "comment": null}, "CUSTOM_CONSENT_METHOD": {"type": "TEXT", "index": 27, "name": "CUSTOM_CONSENT_METHOD", "comment": null}, "CUSTOM_CONSENT": {"type": "VARIANT", "index": 28, "name": "CUSTOM_CONSENT", "comment": null}, "CUSTOM_GIFT_GIVER_NAME": {"type": "TEXT", "index": 29, "name": "CUSTOM_GIFT_GIVER_NAME", "comment": null}, "CUSTOM_STATE": {"type": "TEXT", "index": 30, "name": "CUSTOM_STATE", "comment": null}, "CUSTOM_FLOW": {"type": "TEXT", "index": 31, "name": "CUSTOM_FLOW", "comment": null}, "CUSTOM_GIFT_RECIPIENT_NAME": {"type": "TEXT", "index": 32, "name": "CUSTOM_GIFT_RECIPIENT_NAME", "comment": null}, "CUSTOM_LAST_SIGN_IN": {"type": "TIMESTAMP_TZ", "index": 33, "name": "CUSTOM_LAST_SIGN_IN", "comment": null}, "CUSTOM_CONSENT_FORM_VERSION": {"type": "NUMBER", "index": 34, "name": "CUSTOM_CONSENT_FORM_VERSION", "comment": null}, "CUSTOM_CONSENT_TIMESTAMP": {"type": "TIMESTAMP_TZ", "index": 35, "name": "CUSTOM_CONSENT_TIMESTAMP", "comment": null}, "CUSTOM_MAIL_CHIMP_RATING": {"type": "NUMBER", "index": 36, "name": "CUSTOM_MAIL_CHIMP_RATING", "comment": null}, "CUSTOM_GIFT_RECIPIENT_EMAIL": {"type": "TEXT", "index": 37, "name": "CUSTOM_GIFT_RECIPIENT_EMAIL", "comment": null}, "CUSTOM_GIFT_OPTIONS": {"type": "VARIANT", "index": 38, "name": "CUSTOM_GIFT_OPTIONS", "comment": null}, "CUSTOM_ADDRESS": {"type": "TEXT", "index": 39, "name": "CUSTOM_ADDRESS", "comment": null}, "CUSTOM_SUBSCRIPTION_EXPIRATION": {"type": "TIMESTAMP_TZ", "index": 40, "name": "CUSTOM_SUBSCRIPTION_EXPIRATION", "comment": null}, "CUSTOM_CITY": {"type": "TEXT", "index": 41, "name": "CUSTOM_CITY", "comment": null}, "CUSTOM_ADDRESS_LINE_2": {"type": "TEXT", "index": 42, "name": "CUSTOM_ADDRESS_LINE_2", "comment": null}, "CUSTOM_ZIPCODE": {"type": "TEXT", "index": 43, "name": "CUSTOM_ZIPCODE", "comment": null}, "CUSTOM_EXPECTED_DATE_OF_NEXT_ORDER": {"type": "TEXT", "index": 44, "name": "CUSTOM_EXPECTED_DATE_OF_NEXT_ORDER", "comment": null}, "CUSTOM_SMS_ATTENTIVE_SIGNUP": {"type": "BOOLEAN", "index": 45, "name": "CUSTOM_SMS_ATTENTIVE_SIGNUP", "comment": null}, "CUSTOM_PHONE": {"type": "TEXT", "index": 46, "name": "CUSTOM_PHONE", "comment": null}, "CUSTOM_AFTERPAY_ORDER": {"type": "BOOLEAN", "index": 47, "name": "CUSTOM_AFTERPAY_ORDER", "comment": null}, "CUSTOM_PHONE_NUMBER_REGION": {"type": "TEXT", "index": 48, "name": "CUSTOM_PHONE_NUMBER_REGION", "comment": null}, "CUSTOM_NAME": {"type": "TEXT", "index": 49, "name": "CUSTOM_NAME", "comment": null}, "CUSTOM_REFERRER_NAME": {"type": "TEXT", "index": 50, "name": "CUSTOM_REFERRER_NAME", "comment": null}, "CUSTOM_REFERRER_EMAIL": {"type": "TEXT", "index": 51, "name": "CUSTOM_REFERRER_EMAIL", "comment": null}, "CUSTOM_BIRTHDAY": {"type": "TEXT", "index": 52, "name": "CUSTOM_BIRTHDAY", "comment": null}, "CUSTOM_FIRST_PURCHASE_DATE_": {"type": "DATE", "index": 53, "name": "CUSTOM_FIRST_PURCHASE_DATE_", "comment": null}, "CUSTOM_UNENGAGED": {"type": "BOOLEAN", "index": 54, "name": "CUSTOM_UNENGAGED", "comment": null}, "CUSTOM_LANDING_PAGE_TAG": {"type": "TEXT", "index": 55, "name": "CUSTOM_LANDING_PAGE_TAG", "comment": null}, "CUSTOM_FITNESS_GOAL": {"type": "TEXT", "index": 56, "name": "CUSTOM_FITNESS_GOAL", "comment": null}, "CUSTOM_AGE": {"type": "TEXT", "index": 57, "name": "CUSTOM_AGE", "comment": null}, "CUSTOM_WORKOUT": {"type": "TEXT", "index": 58, "name": "CUSTOM_WORKOUT", "comment": null}, "CUSTOM_QUIZ": {"type": "BOOLEAN", "index": 59, "name": "CUSTOM_QUIZ", "comment": null}, "CUSTOM_BREAKFAST": {"type": "TEXT", "index": 60, "name": "CUSTOM_BREAKFAST", "comment": null}, "CUSTOM_QUIZ_DATA": {"type": "BOOLEAN", "index": 61, "name": "CUSTOM_QUIZ_DATA", "comment": null}, "CUSTOM_RAF_SUBSCRIBE": {"type": "BOOLEAN", "index": 62, "name": "CUSTOM_RAF_SUBSCRIBE", "comment": null}, "CUSTOM_SUPPRESS": {"type": "BOOLEAN", "index": 63, "name": "CUSTOM_SUPPRESS", "comment": null}, "CUSTOM_SMS_CONSENT": {"type": "BOOLEAN", "index": 64, "name": "CUSTOM_SMS_CONSENT", "comment": null}, "CUSTOM_GIFT_OPTION_DREAMBELT": {"type": "VARIANT", "index": 65, "name": "CUSTOM_GIFT_OPTION_DREAMBELT", "comment": null}, "CUSTOM_GIFT_OPTION_STARTER": {"type": "VARIANT", "index": 66, "name": "CUSTOM_GIFT_OPTION_STARTER", "comment": null}, "CUSTOM_GIFT_OPTION_MACHINE": {"type": "VARIANT", "index": 67, "name": "CUSTOM_GIFT_OPTION_MACHINE", "comment": null}, "CUSTOM_LANDINGPAGE_TAG": {"type": "TEXT", "index": 68, "name": "CUSTOM_LANDINGPAGE_TAG", "comment": null}}, "stats": {"bytes": {"id": "bytes", "label": "Approximate Size", "value": 65661952.0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2021-04-14 07:49UTC", "include": true, "description": "The timestamp for last update/change"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 683969.0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "source.klaviyo_source.klaviyo.person"}, "source.klaviyo_source.klaviyo.metric": {"metadata": {"type": "BASE TABLE", "schema": "KLAVIYO", "name": "METRIC", "database": "FIVETRAN_STAGING", "comment": null, "owner": "FIVETRAN_ROLE"}, "columns": {"ID": {"type": "TEXT", "index": 1, "name": "ID", "comment": null}, "NAME": {"type": "TEXT", "index": 2, "name": "NAME", "comment": null}, "INTEGRATION_ID": {"type": "TEXT", "index": 3, "name": "INTEGRATION_ID", "comment": null}, "CREATED": {"type": "TIMESTAMP_TZ", "index": 4, "name": "CREATED", "comment": null}, "UPDATED": {"type": "TIMESTAMP_TZ", "index": 5, "name": "UPDATED", "comment": null}, "_FIVETRAN_DELETED": {"type": "BOOLEAN", "index": 6, "name": "_FIVETRAN_DELETED", "comment": null}, "_FIVETRAN_SYNCED": {"type": "TIMESTAMP_TZ", "index": 7, "name": "_FIVETRAN_SYNCED", "comment": null}}, "stats": {"bytes": {"id": "bytes", "label": "Approximate Size", "value": 4096.0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2021-04-14 07:49UTC", "include": true, "description": "The timestamp for last update/change"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 41.0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "source.klaviyo_source.klaviyo.metric"}, "source.klaviyo_source.klaviyo.integration": {"metadata": {"type": "BASE TABLE", "schema": "KLAVIYO", "name": "INTEGRATION", "database": "FIVETRAN_STAGING", "comment": null, "owner": "FIVETRAN_ROLE"}, "columns": {"ID": {"type": "TEXT", "index": 1, "name": "ID", "comment": null}, "CATEGORY": {"type": "TEXT", "index": 2, "name": "CATEGORY", "comment": null}, "NAME": {"type": "TEXT", "index": 3, "name": "NAME", "comment": null}, "_FIVETRAN_DELETED": {"type": "BOOLEAN", "index": 4, "name": "_FIVETRAN_DELETED", "comment": null}, "_FIVETRAN_SYNCED": {"type": "TIMESTAMP_TZ", "index": 5, "name": "_FIVETRAN_SYNCED", "comment": null}}, "stats": {"bytes": {"id": "bytes", "label": "Approximate Size", "value": 2048.0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2021-04-14 07:49UTC", "include": true, "description": "The timestamp for last update/change"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 5.0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "source.klaviyo_source.klaviyo.integration"}, "source.klaviyo_source.klaviyo.flow": {"metadata": {"type": "BASE TABLE", "schema": "KLAVIYO", "name": "FLOW", "database": "FIVETRAN_STAGING", "comment": null, "owner": "FIVETRAN_ROLE"}, "columns": {"ID": {"type": "TEXT", "index": 1, "name": "ID", "comment": null}, "NAME": {"type": "TEXT", "index": 2, "name": "NAME", "comment": null}, "STATUS": {"type": "TEXT", "index": 3, "name": "STATUS", "comment": null}, "CREATED": {"type": "TIMESTAMP_TZ", "index": 4, "name": "CREATED", "comment": null}, "UPDATED": {"type": "TIMESTAMP_TZ", "index": 5, "name": "UPDATED", "comment": null}, "CUSTOMER_FILTER": {"type": "VARIANT", "index": 6, "name": "CUSTOMER_FILTER", "comment": null}, "TRIGGER": {"type": "VARIANT", "index": 7, "name": "TRIGGER", "comment": null}, "_FIVETRAN_DELETED": {"type": "BOOLEAN", "index": 8, "name": "_FIVETRAN_DELETED", "comment": null}, "_FIVETRAN_SYNCED": {"type": "TIMESTAMP_TZ", "index": 9, "name": "_FIVETRAN_SYNCED", "comment": null}}, "stats": {"bytes": {"id": "bytes", "label": "Approximate Size", "value": 53248.0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2021-04-14 07:49UTC", "include": true, "description": "The timestamp for last update/change"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 57.0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "source.klaviyo_source.klaviyo.flow"}, "source.klaviyo_source.klaviyo.event": {"metadata": {"type": "BASE TABLE", "schema": "KLAVIYO", "name": "EVENT", "database": "FIVETRAN_STAGING", "comment": null, "owner": "FIVETRAN_ROLE"}, "columns": {"ID": {"type": "TEXT", "index": 1, "name": "ID", "comment": null}, "PERSON_ID": {"type": "TEXT", "index": 2, "name": "PERSON_ID", "comment": null}, "CAMPAIGN_ID": {"type": "TEXT", "index": 3, "name": "CAMPAIGN_ID", "comment": null}, "FLOW_ID": {"type": "TEXT", "index": 4, "name": "FLOW_ID", "comment": null}, "FLOW_MESSAGE_ID": {"type": "TEXT", "index": 5, "name": "FLOW_MESSAGE_ID", "comment": null}, "UUID": {"type": "TEXT", "index": 6, "name": "UUID", "comment": null}, "DATETIME": {"type": "TIMESTAMP_TZ", "index": 7, "name": "DATETIME", "comment": null}, "TIMESTAMP": {"type": "TIMESTAMP_TZ", "index": 8, "name": "TIMESTAMP", "comment": null}, "_FIVETRAN_DELETED": {"type": "BOOLEAN", "index": 9, "name": "_FIVETRAN_DELETED", "comment": null}, "METRIC_ID": {"type": "TEXT", "index": 10, "name": "METRIC_ID", "comment": null}, "TYPE": {"type": "TEXT", "index": 11, "name": "TYPE", "comment": null}, "_VARIATION": {"type": "TEXT", "index": 12, "name": "_VARIATION", "comment": null}, "PROPERTY_VALUE": {"type": "FLOAT", "index": 13, "name": "PROPERTY_VALUE", "comment": null}, "PROPERTY_SOURCE_NAME": {"type": "TEXT", "index": 14, "name": "PROPERTY_SOURCE_NAME", "comment": null}, "PROPERTY_EXTRA": {"type": "VARIANT", "index": 15, "name": "PROPERTY_EXTRA", "comment": null}, "PROPERTY_SHIPPING_RATE": {"type": "TEXT", "index": 16, "name": "PROPERTY_SHIPPING_RATE", "comment": null}, "PROPERTY_ITEMS": {"type": "VARIANT", "index": 17, "name": "PROPERTY_ITEMS", "comment": null}, "PROPERTY_TAGS": {"type": "VARIANT", "index": 18, "name": "PROPERTY_TAGS", "comment": null}, "PROPERTY_ITEM_COUNT": {"type": "NUMBER", "index": 19, "name": "PROPERTY_ITEM_COUNT", "comment": null}, "PROPERTY_COLLECTIONS": {"type": "VARIANT", "index": 20, "name": "PROPERTY_COLLECTIONS", "comment": null}, "_FIVETRAN_SYNCED": {"type": "TIMESTAMP_TZ", "index": 21, "name": "_FIVETRAN_SYNCED", "comment": null}, "PROPERTY_CURRENCY_CODE": {"type": "TEXT", "index": 22, "name": "PROPERTY_CURRENCY_CODE", "comment": null}, "PROPERTY_PRODUCT_ID": {"type": "NUMBER", "index": 23, "name": "PROPERTY_PRODUCT_ID", "comment": null}, "PROPERTY_QUANTITY": {"type": "NUMBER", "index": 24, "name": "PROPERTY_QUANTITY", "comment": null}, "PROPERTY_NAME": {"type": "TEXT", "index": 25, "name": "PROPERTY_NAME", "comment": null}, "PROPERTY_VARIANT_OPTION_TITLE": {"type": "TEXT", "index": 26, "name": "PROPERTY_VARIANT_OPTION_TITLE", "comment": null}, "PROPERTY_SKU": {"type": "TEXT", "index": 27, "name": "PROPERTY_SKU", "comment": null}, "PROPERTY_VARIANT_NAME": {"type": "TEXT", "index": 28, "name": "PROPERTY_VARIANT_NAME", "comment": null}, "PROPERTY_VENDOR": {"type": "TEXT", "index": 29, "name": "PROPERTY_VENDOR", "comment": null}, "PROPERTY_EVENT_ID": {"type": "TEXT", "index": 30, "name": "PROPERTY_EVENT_ID", "comment": null}, "PROPERTY_TOTAL_DISCOUNTS": {"type": "FLOAT", "index": 31, "name": "PROPERTY_TOTAL_DISCOUNTS", "comment": null}, "PROPERTY_ATTRIBUTION": {"type": "VARIANT", "index": 32, "name": "PROPERTY_ATTRIBUTION", "comment": null}, "PROPERTY_DISCOUNT_CODES": {"type": "VARIANT", "index": 33, "name": "PROPERTY_DISCOUNT_CODES", "comment": null}, "PROPERTY_FULFILLMENT_HOURS": {"type": "NUMBER", "index": 34, "name": "PROPERTY_FULFILLMENT_HOURS", "comment": null}, "PROPERTY_FULFILLMENT_STATUS": {"type": "TEXT", "index": 35, "name": "PROPERTY_FULFILLMENT_STATUS", "comment": null}, "PROPERTY_SUBJECT": {"type": "TEXT", "index": 36, "name": "PROPERTY_SUBJECT", "comment": null}, "PROPERTY_TITLE": {"type": "TEXT", "index": 37, "name": "PROPERTY_TITLE", "comment": null}, "PROPERTY_MESSAGE_INTERACTION": {"type": "TEXT", "index": 38, "name": "PROPERTY_MESSAGE_INTERACTION", "comment": null}, "PROPERTY_URL": {"type": "TEXT", "index": 39, "name": "PROPERTY_URL", "comment": null}, "PROPERTY_SHIPMENT_TYPE": {"type": "TEXT", "index": 40, "name": "PROPERTY_SHIPMENT_TYPE", "comment": null}, "PROPERTY_COURIER_NAME": {"type": "TEXT", "index": 41, "name": "PROPERTY_COURIER_NAME", "comment": null}, "PROPERTY_CURRENT_STATUS": {"type": "TEXT", "index": 42, "name": "PROPERTY_CURRENT_STATUS", "comment": null}, "PROPERTY_TRACKING_SHIP_DATE": {"type": "NUMBER", "index": 43, "name": "PROPERTY_TRACKING_SHIP_DATE", "comment": null}, "PROPERTY_TRACKING_POSTAL_CODE": {"type": "TEXT", "index": 44, "name": "PROPERTY_TRACKING_POSTAL_CODE", "comment": null}, "PROPERTY_SHIPMENT_PACKAGE_COUNT": {"type": "NUMBER", "index": 45, "name": "PROPERTY_SHIPMENT_PACKAGE_COUNT", "comment": null}, "PROPERTY_CAMPAIGN_NAME": {"type": "TEXT", "index": 46, "name": "PROPERTY_CAMPAIGN_NAME", "comment": null}, "PROPERTY_COHORT_MESSAGE_SEND_COHORT": {"type": "TEXT", "index": 47, "name": "PROPERTY_COHORT_MESSAGE_SEND_COHORT", "comment": null}, "PROPERTY_EMAIL_DOMAIN": {"type": "TEXT", "index": 48, "name": "PROPERTY_EMAIL_DOMAIN", "comment": null}, "PROPERTY_BOUNCE_TYPE": {"type": "TEXT", "index": 49, "name": "PROPERTY_BOUNCE_TYPE", "comment": null}, "PROPERTY_CLIENT_TYPE": {"type": "TEXT", "index": 50, "name": "PROPERTY_CLIENT_TYPE", "comment": null}, "PROPERTY_CLIENT_OS": {"type": "TEXT", "index": 51, "name": "PROPERTY_CLIENT_OS", "comment": null}, "PROPERTY_CLIENT_NAME": {"type": "TEXT", "index": 52, "name": "PROPERTY_CLIENT_NAME", "comment": null}, "PROPERTY_CLIENT_OS_FAMILY": {"type": "TEXT", "index": 53, "name": "PROPERTY_CLIENT_OS_FAMILY", "comment": null}, "PROPERTY_CLIENT_CANONICAL": {"type": "TEXT", "index": 54, "name": "PROPERTY_CLIENT_CANONICAL", "comment": null}, "PROPERTY_PAGE": {"type": "TEXT", "index": 55, "name": "PROPERTY_PAGE", "comment": null}, "PROPERTY_IS_SESSION_ACTIVITY": {"type": "BOOLEAN", "index": 56, "name": "PROPERTY_IS_SESSION_ACTIVITY", "comment": null}, "PROPERTY_OS": {"type": "TEXT", "index": 57, "name": "PROPERTY_OS", "comment": null}, "PROPERTY_SESSION_END": {"type": "NUMBER", "index": 58, "name": "PROPERTY_SESSION_END", "comment": null}, "PROPERTY_BROWSER": {"type": "TEXT", "index": 59, "name": "PROPERTY_BROWSER", "comment": null}, "PROPERTY_LIST": {"type": "TEXT", "index": 60, "name": "PROPERTY_LIST", "comment": null}, "PROPERTY_COMPARE_AT_PRICE": {"type": "TEXT", "index": 61, "name": "PROPERTY_COMPARE_AT_PRICE", "comment": null}, "PROPERTY_PRICE": {"type": "TEXT", "index": 62, "name": "PROPERTY_PRICE", "comment": null}, "PROPERTY_IMAGE_URL": {"type": "TEXT", "index": 63, "name": "PROPERTY_IMAGE_URL", "comment": null}, "PROPERTY_BRAND": {"type": "TEXT", "index": 64, "name": "PROPERTY_BRAND", "comment": null}, "PROPERTY_CATEGORIES": {"type": "VARIANT", "index": 65, "name": "PROPERTY_CATEGORIES", "comment": null}, "PROPERTY_VARIANT_OPTION_SIZE": {"type": "TEXT", "index": 66, "name": "PROPERTY_VARIANT_OPTION_SIZE", "comment": null}, "PROPERTY_ATTRIBUTE_WORKOUT": {"type": "TEXT", "index": 67, "name": "PROPERTY_ATTRIBUTE_WORKOUT", "comment": null}, "PROPERTY_ATTRIBUTE_AGE": {"type": "TEXT", "index": 68, "name": "PROPERTY_ATTRIBUTE_AGE", "comment": null}, "PROPERTY_ATTRIBUTE_FITNESS_GOAL": {"type": "TEXT", "index": 69, "name": "PROPERTY_ATTRIBUTE_FITNESS_GOAL", "comment": null}, "PROPERTY_ATTRIBUTE_BREAKFAST": {"type": "TEXT", "index": 70, "name": "PROPERTY_ATTRIBUTE_BREAKFAST", "comment": null}, "PROPERTY_VARIANT_OPTION_TYPE": {"type": "TEXT", "index": 71, "name": "PROPERTY_VARIANT_OPTION_TYPE", "comment": null}, "PROPERTY_COHORT_VARIATION_SEND_COHORT": {"type": "TEXT", "index": 72, "name": "PROPERTY_COHORT_VARIATION_SEND_COHORT", "comment": null}, "PROPERTY_METHOD": {"type": "TEXT", "index": 73, "name": "PROPERTY_METHOD", "comment": null}, "PROPERTY_TO_NUMBER": {"type": "TEXT", "index": 74, "name": "PROPERTY_TO_NUMBER", "comment": null}, "PROPERTY_MESSAGE_TYPE": {"type": "TEXT", "index": 75, "name": "PROPERTY_MESSAGE_TYPE", "comment": null}, "PROPERTY_FROM_NUMBER": {"type": "TEXT", "index": 76, "name": "PROPERTY_FROM_NUMBER", "comment": null}, "PROPERTY_MESSAGE_FORMAT": {"type": "TEXT", "index": 77, "name": "PROPERTY_MESSAGE_FORMAT", "comment": null}, "PROPERTY_MESSAGE_NAME": {"type": "TEXT", "index": 78, "name": "PROPERTY_MESSAGE_NAME", "comment": null}, "PROPERTY_CARRIER_DELIVERY_STATUS": {"type": "TEXT", "index": 79, "name": "PROPERTY_CARRIER_DELIVERY_STATUS", "comment": null}, "PROPERTY_FAILURE_TYPE": {"type": "TEXT", "index": 80, "name": "PROPERTY_FAILURE_TYPE", "comment": null}, "PROPERTY_FAILURE_SOURCE": {"type": "TEXT", "index": 81, "name": "PROPERTY_FAILURE_SOURCE", "comment": null}, "PROPERTY_MESSAGE_BODY": {"type": "TEXT", "index": 82, "name": "PROPERTY_MESSAGE_BODY", "comment": null}, "PROPERTY_EMAIL": {"type": "TEXT", "index": 83, "name": "PROPERTY_EMAIL", "comment": null}, "PROPERTY_ATTRIBUTE_KIT": {"type": "TEXT", "index": 84, "name": "PROPERTY_ATTRIBUTE_KIT", "comment": null}, "PROPERTY_VENDOR_ERROR_CODE": {"type": "TEXT", "index": 85, "name": "PROPERTY_VENDOR_ERROR_CODE", "comment": null}, "PROPERTY_ORDR_DETAILS": {"type": "VARIANT", "index": 86, "name": "PROPERTY_ORDR_DETAILS", "comment": null}, "PROPERTY_DATE_TO_SEND_GIFT": {"type": "TEXT", "index": 87, "name": "PROPERTY_DATE_TO_SEND_GIFT", "comment": null}, "PROPERTY_RECIPIENT_NAME": {"type": "TEXT", "index": 88, "name": "PROPERTY_RECIPIENT_NAME", "comment": null}, "PROPERTY_ATTRIBUTE_FACEBOOK_ORDER_RETAILER_ID": {"type": "NUMBER", "index": 89, "name": "PROPERTY_ATTRIBUTE_FACEBOOK_ORDER_RETAILER_ID", "comment": null}, "PROPERTY_SENDER_S_NAME": {"type": "TEXT", "index": 90, "name": "PROPERTY_SENDER_S_NAME", "comment": null}, "PROPERTY_ATTRIBUTE_KITID": {"type": "NUMBER", "index": 91, "name": "PROPERTY_ATTRIBUTE_KITID", "comment": null}, "PROPERTY_CONVERSATION_ID": {"type": "TEXT", "index": 92, "name": "PROPERTY_CONVERSATION_ID", "comment": null}, "PROPERTY_CONVERSATION_LINK": {"type": "TEXT", "index": 93, "name": "PROPERTY_CONVERSATION_LINK", "comment": null}, "PROPERTY_CONVERSATION_CHANNEL": {"type": "TEXT", "index": 94, "name": "PROPERTY_CONVERSATION_CHANNEL", "comment": null}, "PROPERTY_RATING": {"type": "NUMBER", "index": 95, "name": "PROPERTY_RATING", "comment": null}, "PROPERTY_SCORE": {"type": "NUMBER", "index": 96, "name": "PROPERTY_SCORE", "comment": null}, "PROPERTY_FROM_PHONE_REGION": {"type": "TEXT", "index": 97, "name": "PROPERTY_FROM_PHONE_REGION", "comment": null}, "PROPERTY_SHIPMENT_CARRIER": {"type": "TEXT", "index": 98, "name": "PROPERTY_SHIPMENT_CARRIER", "comment": null}, "PROPERTY_SHIPMENT_STATUS": {"type": "TEXT", "index": 99, "name": "PROPERTY_SHIPMENT_STATUS", "comment": null}, "PROPERTY_TO_PHONE_REGION": {"type": "TEXT", "index": 100, "name": "PROPERTY_TO_PHONE_REGION", "comment": null}}, "stats": {"bytes": {"id": "bytes", "label": "Approximate Size", "value": 2533341184.0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2021-04-14 07:49UTC", "include": true, "description": "The timestamp for last update/change"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 15181494.0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "source.klaviyo_source.klaviyo.event"}, "source.klaviyo_source.klaviyo.campaign": {"metadata": {"type": "BASE TABLE", "schema": "KLAVIYO", "name": "CAMPAIGN", "database": "FIVETRAN_STAGING", "comment": null, "owner": "FIVETRAN_ROLE"}, "columns": {"ID": {"type": "TEXT", "index": 1, "name": "ID", "comment": null}, "FROM_NAME": {"type": "TEXT", "index": 2, "name": "FROM_NAME", "comment": null}, "STATUS_ID": {"type": "TEXT", "index": 3, "name": "STATUS_ID", "comment": null}, "IS_SEGMENTED": {"type": "BOOLEAN", "index": 4, "name": "IS_SEGMENTED", "comment": null}, "CAMPAIGN_TYPE": {"type": "TEXT", "index": 5, "name": "CAMPAIGN_TYPE", "comment": null}, "STATUS_LABEL": {"type": "TEXT", "index": 6, "name": "STATUS_LABEL", "comment": null}, "FROM_EMAIL": {"type": "TEXT", "index": 7, "name": "FROM_EMAIL", "comment": null}, "SUBJECT": {"type": "TEXT", "index": 8, "name": "SUBJECT", "comment": null}, "NAME": {"type": "TEXT", "index": 9, "name": "NAME", "comment": null}, "STATUS": {"type": "TEXT", "index": 10, "name": "STATUS", "comment": null}, "CREATED": {"type": "TIMESTAMP_TZ", "index": 11, "name": "CREATED", "comment": null}, "UPDATED": {"type": "TIMESTAMP_TZ", "index": 12, "name": "UPDATED", "comment": null}, "SEND_TIME": {"type": "TIMESTAMP_TZ", "index": 13, "name": "SEND_TIME", "comment": null}, "SENT_AT": {"type": "TIMESTAMP_TZ", "index": 14, "name": "SENT_AT", "comment": null}, "_FIVETRAN_DELETED": {"type": "BOOLEAN", "index": 15, "name": "_FIVETRAN_DELETED", "comment": null}, "EMAIL_TEMPLATE_ID": {"type": "TEXT", "index": 16, "name": "EMAIL_TEMPLATE_ID", "comment": null}, "_FIVETRAN_SYNCED": {"type": "TIMESTAMP_TZ", "index": 17, "name": "_FIVETRAN_SYNCED", "comment": null}}, "stats": {"bytes": {"id": "bytes", "label": "Approximate Size", "value": 14336.0, "include": true, "description": "Approximate size of the table as reported by Snowflake"}, "last_modified": {"id": "last_modified", "label": "Last Modified", "value": "2021-04-14 07:49UTC", "include": true, "description": "The timestamp for last update/change"}, "row_count": {"id": "row_count", "label": "Row Count", "value": 98.0, "include": true, "description": "An approximate count of rows in this table"}, "has_stats": {"id": "has_stats", "label": "Has Stats?", "value": true, "include": false, "description": "Indicates whether there are statistics for this table"}}, "unique_id": "source.klaviyo_source.klaviyo.campaign"}}, "errors": null}
\ No newline at end of file
diff --git a/docs/index.html b/docs/index.html
new file mode 100644
index 0000000..360349a
--- /dev/null
+++ b/docs/index.html
@@ -0,0 +1,102 @@
+
+
+
+
+
+
+ dbt Docs
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/manifest.json b/docs/manifest.json
new file mode 100644
index 0000000..24cf15a
--- /dev/null
+++ b/docs/manifest.json
@@ -0,0 +1 @@
+{"metadata": {"dbt_schema_version": "https://schemas.getdbt.com/dbt/manifest/v1.json", "dbt_version": "0.19.1", "generated_at": "2021-05-14T22:08:36.406703Z", "invocation_id": "f7550b65-aa65-41a7-947e-4f59ca100216", "env": {}, "project_id": "925e385b52fb405715f3616c337cc65c", "user_id": "3ba29a2e-e6c1-4d02-90b0-62926a040844", "send_anonymous_usage_stats": true, "adapter_type": "snowflake"}, "nodes": {"model.klaviyo.klaviyo__person_campaign_flow": {"raw_sql": "with events as (\n select *\n from {{ ref('klaviyo__events') }}\n),\n\npivot_out_events as (\n \n select \n person_id,\n last_touch_campaign_id,\n last_touch_flow_id,\n campaign_name,\n flow_name,\n variation_id,\n min(occurred_at) as first_event_at,\n max(occurred_at) as last_event_at\n\n -- sum up the numeric value associated with events (most likely will mean revenue)\n {% for rm in var('klaviyo__sum_revenue_metrics') %}\n , sum(case when lower(type) = '{{ rm | lower }}' then numeric_value else 0 end) \n as {{ 'sum_revenue_' ~ rm | replace(' ', '_') | replace('(', '') | replace(')', '') | lower }} -- removing special characters that I have seen in different integration events\n {% endfor %}\n\n -- count up the number of instances of each metric\n {% for cm in var('klaviyo__count_metrics') %}\n , sum(case when lower(type) = '{{ cm | lower }}' then 1 else 0 end) \n as {{ 'count_' ~ cm | replace(' ', '_') | replace('(', '') | replace(')', '') | lower }} -- removing special characters that I have seen in different integration events\n {% endfor %}\n\n from events\n group by 1,2,3,4,5,6\n)\n\nselect *\nfrom pivot_out_events", "compiled": true, "resource_type": "model", "depends_on": {"macros": [], "nodes": ["model.klaviyo.klaviyo__events"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "klaviyo", "database": null, "tags": [], "full_refresh": null, "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_klaviyo", "fqn": ["klaviyo", "klaviyo__person_campaign_flow"], "unique_id": "model.klaviyo.klaviyo__person_campaign_flow", "package_name": "klaviyo", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo", "path": "klaviyo__person_campaign_flow.sql", "original_file_path": "models/klaviyo__person_campaign_flow.sql", "name": "klaviyo__person_campaign_flow", "alias": "klaviyo__person_campaign_flow", "checksum": {"name": "sha256", "checksum": "666d0ae8663de7c80029d83b90141ef2b1b69babd0e6377ceede8adae34baedd"}, "tags": [], "refs": [["klaviyo__events"]], "sources": [], "description": "Table that aggregates event metrics to the person-campaign or -flow grain (but note that if a user interacts with 2 different variations of a flow/campaign somehow, they will have 2 records). Also note that organic interactions (someone with null campaign_id/flow_id) are included in this table. \n**Counts** of the instances of the events, as well as **sums** of the numeric value associated with events (i.e. revenue) will be pivoted out into columns, as configured by the `klaviyo__count_metrics` and `klaviyo__sum_revenue_metrics` variables, respectively. See the dbt_project.yml file for the default metrics used. These columns will be prefixed with `count_` and `sum_revenue_`.\n", "columns": {"person_id": {"name": "person_id", "description": "Foreign key referencing the PERSON who interacted with the flow/message.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "last_touch_campaign_id": {"name": "last_touch_campaign_id", "description": "Foreign key referencing the CAMPAIGN attributed with these metrics (by the package's attribution model).", "meta": {}, "data_type": null, "quote": null, "tags": []}, "last_touch_flow_id": {"name": "last_touch_flow_id", "description": "Foreign key referencing the FLOW attributed with these metrics (by the package's attribution model).", "meta": {}, "data_type": null, "quote": null, "tags": []}, "campaign_name": {"name": "campaign_name", "description": "A name for this campaign. If not specified, this will default to the subject of the campaign.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "flow_name": {"name": "flow_name", "description": "Name of the flow.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "variation_id": {"name": "variation_id", "description": "Unique ID of the attributed flow or campaign variation group. This does not map onto another table. \n", "meta": {}, "data_type": null, "quote": null, "tags": []}, "first_event_at": {"name": "first_event_at", "description": "Timestamp of the first ever interaction between this campaign/flow and a person. In other words, the first event trigger attributed to the campaign/flow.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "last_event_at": {"name": "last_event_at", "description": "Timestamp of the most recent interaction between this campaign/flow and a person. In other words, the last event trigger attributed to the campaign/flow.", "meta": {}, "data_type": null, "quote": null, "tags": []}}, "meta": {}, "docs": {"show": true}, "patch_path": "models/klaviyo.yml", "build_path": "target/compiled/klaviyo/models/klaviyo__person_campaign_flow.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "klaviyo"}, "compiled_sql": "with events as (\n select *\n from FIVETRAN_STAGING.DBT_FIVETRAN_klaviyo.klaviyo__events\n),\n\npivot_out_events as (\n \n select \n person_id,\n last_touch_campaign_id,\n last_touch_flow_id,\n campaign_name,\n flow_name,\n variation_id,\n min(occurred_at) as first_event_at,\n max(occurred_at) as last_event_at\n\n -- sum up the numeric value associated with events (most likely will mean revenue)\n \n , sum(case when lower(type) = 'refunded order' then numeric_value else 0 end) \n as sum_revenue_refunded_order -- removing special characters that I have seen in different integration events\n \n , sum(case when lower(type) = 'placed order' then numeric_value else 0 end) \n as sum_revenue_placed_order -- removing special characters that I have seen in different integration events\n \n , sum(case when lower(type) = 'ordered product' then numeric_value else 0 end) \n as sum_revenue_ordered_product -- removing special characters that I have seen in different integration events\n \n , sum(case when lower(type) = 'checkout started' then numeric_value else 0 end) \n as sum_revenue_checkout_started -- removing special characters that I have seen in different integration events\n \n , sum(case when lower(type) = 'cancelled order' then numeric_value else 0 end) \n as sum_revenue_cancelled_order -- removing special characters that I have seen in different integration events\n \n\n -- count up the number of instances of each metric\n \n , sum(case when lower(type) = 'active on site' then 1 else 0 end) \n as count_active_on_site -- removing special characters that I have seen in different integration events\n \n , sum(case when lower(type) = 'viewed product' then 1 else 0 end) \n as count_viewed_product -- removing special characters that I have seen in different integration events\n \n , sum(case when lower(type) = 'ordered product' then 1 else 0 end) \n as count_ordered_product -- removing special characters that I have seen in different integration events\n \n , sum(case when lower(type) = 'placed order' then 1 else 0 end) \n as count_placed_order -- removing special characters that I have seen in different integration events\n \n , sum(case when lower(type) = 'refunded order' then 1 else 0 end) \n as count_refunded_order -- removing special characters that I have seen in different integration events\n \n , sum(case when lower(type) = 'received email' then 1 else 0 end) \n as count_received_email -- removing special characters that I have seen in different integration events\n \n , sum(case when lower(type) = 'clicked email' then 1 else 0 end) \n as count_clicked_email -- removing special characters that I have seen in different integration events\n \n , sum(case when lower(type) = 'opened email' then 1 else 0 end) \n as count_opened_email -- removing special characters that I have seen in different integration events\n \n , sum(case when lower(type) = 'marked email as spam' then 1 else 0 end) \n as count_marked_email_as_spam -- removing special characters that I have seen in different integration events\n \n , sum(case when lower(type) = 'unsubscribed' then 1 else 0 end) \n as count_unsubscribed -- removing special characters that I have seen in different integration events\n \n , sum(case when lower(type) = 'received sms' then 1 else 0 end) \n as count_received_sms -- removing special characters that I have seen in different integration events\n \n , sum(case when lower(type) = 'clicked sms' then 1 else 0 end) \n as count_clicked_sms -- removing special characters that I have seen in different integration events\n \n , sum(case when lower(type) = 'sent sms' then 1 else 0 end) \n as count_sent_sms -- removing special characters that I have seen in different integration events\n \n , sum(case when lower(type) = 'unsubscribed from sms' then 1 else 0 end) \n as count_unsubscribed_from_sms -- removing special characters that I have seen in different integration events\n \n\n from events\n group by 1,2,3,4,5,6\n)\n\nselect *\nfrom pivot_out_events", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": "FIVETRAN_STAGING.DBT_FIVETRAN_klaviyo.klaviyo__person_campaign_flow"}, "model.klaviyo.klaviyo__persons": {"raw_sql": "with person as (\n\n select *\n from {{ var('person') }}\n),\n\nperson_metrics as (\n\n select *\n from {{ ref('int_klaviyo__person_metrics') }}\n),\n\nperson_join as (\n\n select\n person.*,\n {{ dbt_utils.star(from=ref('int_klaviyo__person_metrics'), except=['person_id'] if target.type != 'snowflake' else ['PERSON_ID'] ) }}\n\n from person\n left join person_metrics using(person_id)\n\n)\n\nselect *\nfrom person_join", "compiled": true, "resource_type": "model", "depends_on": {"macros": ["macro.dbt_utils.star"], "nodes": ["model.klaviyo_source.stg_klaviyo__person", "model.klaviyo.int_klaviyo__person_metrics", "model.klaviyo.int_klaviyo__person_metrics"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "klaviyo", "database": null, "tags": [], "full_refresh": null, "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_klaviyo", "fqn": ["klaviyo", "klaviyo__persons"], "unique_id": "model.klaviyo.klaviyo__persons", "package_name": "klaviyo", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo", "path": "klaviyo__persons.sql", "original_file_path": "models/klaviyo__persons.sql", "name": "klaviyo__persons", "alias": "klaviyo__persons", "checksum": {"name": "sha256", "checksum": "de3a571d8abc3f5d28cb453e41e458fee7e8d830d1156b6d400a3451cfaffc2c"}, "tags": [], "refs": [["stg_klaviyo__person"], ["int_klaviyo__person_metrics"], ["int_klaviyo__person_metrics"]], "sources": [], "description": "Table of unique person profiles, enhanced with event, campaign, flow, and revenue metrics. \n**Counts** of instances of triggered events and **sums** of the numeric value (i.e. revenue) associated with events (total vs organic/not attributed to flows or campaigns) will be pivoted out into columns, as configured by the `klaviyo__count_metrics` and `klaviyo__sum_revenue_metrics`variables, respectively. See the dbt_project.yml file for the default metrics used. These columns will be prefixed with `total_count_`, `total_sum_revenue_` (organic + attributed), and `organic_sum_revenue_` (not attributed to a campaign or flow). \n", "columns": {"person_id": {"name": "person_id", "description": "Unique ID of the user if you use your own unique identifier. Otherwise, Klaviyo recommends using the email as the primary key. \n", "meta": {}, "data_type": null, "quote": null, "tags": []}, "address_1": {"name": "address_1", "description": "First line of the person's address.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "address_2": {"name": "address_2", "description": "Second line of the person's address.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "city": {"name": "city", "description": "City they live in.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "country": {"name": "country", "description": "Country they live in.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "zip": {"name": "zip", "description": "Postal code where they live.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "created_at": {"name": "created_at", "description": "Timestamp of when the person's profile was created.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "email": {"name": "email", "description": "The email address and the unique identifier for a profile.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "full_name": {"name": "full_name", "description": "Person's full name.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "latitude": {"name": "latitude", "description": "Latitude of the person's location.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "longitude": {"name": "longitude", "description": "Longitude of the person's location.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "organization": {"name": "organization", "description": "Business organization they belong to.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "phone_number": {"name": "phone_number", "description": "Associated phone number.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "region": {"name": "region", "description": "Region or state they live in.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "timezone": {"name": "timezone", "description": "Timezone they are situated in.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "title": {"name": "title", "description": "Title at their business or organization.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "updated_at": {"name": "updated_at", "description": "Timestamp of when the person profile was last updated.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "count_total_campaigns": {"name": "count_total_campaigns", "description": "Count of the number of campaigns this person has interacted with.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "count_total_flows": {"name": "count_total_flows", "description": "Count of the number of flows this person has interacted with.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "first_event_at": {"name": "first_event_at", "description": "Timestamp of when the user first triggered an event (not limited to campaign and flow interactions).", "meta": {}, "data_type": null, "quote": null, "tags": []}, "last_event_at": {"name": "last_event_at", "description": "Timestamp of when the user last triggered an event (not limited to campaign and flow interactions).", "meta": {}, "data_type": null, "quote": null, "tags": []}, "first_campaign_touch_at": {"name": "first_campaign_touch_at", "description": "Timestamp of when the user first interacted with a campaign.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "last_campaign_touch_at": {"name": "last_campaign_touch_at", "description": "Timestamp of when the user last interacted with a campaign.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "first_flow_touch_at": {"name": "first_flow_touch_at", "description": "Timestamp of when the user first interacted with a flow.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "last_flow_touch_at": {"name": "last_flow_touch_at", "description": "Timestamp of when the user last interacted with a flow.", "meta": {}, "data_type": null, "quote": null, "tags": []}}, "meta": {}, "docs": {"show": true}, "patch_path": "models/klaviyo.yml", "build_path": "target/compiled/klaviyo/models/klaviyo__persons.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "klaviyo"}, "compiled_sql": "with person as (\n\n select *\n from FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__person\n),\n\nperson_metrics as (\n\n select *\n from FIVETRAN_STAGING.DBT_FIVETRAN_int_klaviyo.int_klaviyo__person_metrics\n),\n\nperson_join as (\n\n select\n person.*,\n \"COUNT_TOTAL_CAMPAIGNS\",\n \"COUNT_TOTAL_FLOWS\",\n \"FIRST_EVENT_AT\",\n \"LAST_EVENT_AT\",\n \"FIRST_CAMPAIGN_TOUCH_AT\",\n \"LAST_CAMPAIGN_TOUCH_AT\",\n \"FIRST_FLOW_TOUCH_AT\",\n \"LAST_FLOW_TOUCH_AT\",\n \"TOTAL_SUM_REVENUE_REFUNDED_ORDER\",\n \"ORGANIC_SUM_REVENUE_REFUNDED_ORDER\",\n \"TOTAL_SUM_REVENUE_PLACED_ORDER\",\n \"ORGANIC_SUM_REVENUE_PLACED_ORDER\",\n \"TOTAL_SUM_REVENUE_ORDERED_PRODUCT\",\n \"ORGANIC_SUM_REVENUE_ORDERED_PRODUCT\",\n \"TOTAL_SUM_REVENUE_CHECKOUT_STARTED\",\n \"ORGANIC_SUM_REVENUE_CHECKOUT_STARTED\",\n \"TOTAL_SUM_REVENUE_CANCELLED_ORDER\",\n \"ORGANIC_SUM_REVENUE_CANCELLED_ORDER\",\n \"TOTAL_COUNT_ACTIVE_ON_SITE\",\n \"TOTAL_COUNT_VIEWED_PRODUCT\",\n \"TOTAL_COUNT_ORDERED_PRODUCT\",\n \"TOTAL_COUNT_PLACED_ORDER\",\n \"TOTAL_COUNT_REFUNDED_ORDER\",\n \"TOTAL_COUNT_RECEIVED_EMAIL\",\n \"TOTAL_COUNT_CLICKED_EMAIL\",\n \"TOTAL_COUNT_OPENED_EMAIL\",\n \"TOTAL_COUNT_MARKED_EMAIL_AS_SPAM\",\n \"TOTAL_COUNT_UNSUBSCRIBED\",\n \"TOTAL_COUNT_RECEIVED_SMS\",\n \"TOTAL_COUNT_CLICKED_SMS\",\n \"TOTAL_COUNT_SENT_SMS\",\n \"TOTAL_COUNT_UNSUBSCRIBED_FROM_SMS\"\n\n from person\n left join person_metrics using(person_id)\n\n)\n\nselect *\nfrom person_join", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": "FIVETRAN_STAGING.DBT_FIVETRAN_klaviyo.klaviyo__persons"}, "model.klaviyo.klaviyo__flows": {"raw_sql": "with flow as (\n\n select *\n from {{ var('flow') }}\n),\n\nflow_metrics as (\n\n select *\n from {{ ref('int_klaviyo__campaign_flow_metrics') }}\n),\n\nflow_join as (\n \n {% set exclude_fields = [ 'last_touch_campaign_id', 'last_touch_flow_id'] %}\n {% set exclude_fields = exclude_fields | upper if target.type == 'snowflake' else exclude_fields %} -- snowflake needs uppercase :)\n\n select\n flow.*, -- has flow_id\n {{ dbt_utils.star(from=ref('int_klaviyo__campaign_flow_metrics'), except=exclude_fields) }}\n\n from flow\n left join flow_metrics on flow.flow_id = flow_metrics.last_touch_flow_id\n),\n\nfinal as (\n\n select \n *,\n {{ dbt_utils.surrogate_key(['flow_id','variation_id']) }} as flow_variation_key\n\n from flow_join\n)\n\nselect *\nfrom final", "compiled": true, "resource_type": "model", "depends_on": {"macros": ["macro.dbt_utils.star", "macro.dbt_utils.surrogate_key"], "nodes": ["model.klaviyo_source.stg_klaviyo__flow", "model.klaviyo.int_klaviyo__campaign_flow_metrics", "model.klaviyo.int_klaviyo__campaign_flow_metrics"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "klaviyo", "database": null, "tags": [], "full_refresh": null, "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_klaviyo", "fqn": ["klaviyo", "klaviyo__flows"], "unique_id": "model.klaviyo.klaviyo__flows", "package_name": "klaviyo", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo", "path": "klaviyo__flows.sql", "original_file_path": "models/klaviyo__flows.sql", "name": "klaviyo__flows", "alias": "klaviyo__flows", "checksum": {"name": "sha256", "checksum": "9780ed945faf615cc57c6032e7bd491fb17d9505186f0c98566cdf3cbec96e20"}, "tags": [], "refs": [["stg_klaviyo__flow"], ["int_klaviyo__campaign_flow_metrics"], ["int_klaviyo__campaign_flow_metrics"]], "sources": [], "description": "Table of unique flow versions. A flow with 2 variations will have 2 distinct rows. **Counts** of the unique users and instances of the events, as well as **sums** of the numeric value associated with events (i.e. revenue) will be pivoted out into columns, as configured by the `klaviyo__count_metrics` and `klaviyo__sum_revenue_metrics` variables, respectively. See the dbt_project.yml file for the default metrics used. These columns will be prefixed with `count_`, `unique_count_`, and `sum_revenue_`.\n", "columns": {"flow_variation_key": {"name": "flow_variation_key", "description": "Unique key hashed on the flow and variation IDs.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "created_at": {"name": "created_at", "description": "Timestamp of when the flow was first created.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "flow_id": {"name": "flow_id", "description": "Unique ID of the flow.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "flow_name": {"name": "flow_name", "description": "Name of the flow.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "status": {"name": "status", "description": "Current status of the flow. Either 'manual', 'live', or 'draft'. Read more [here](https://help.klaviyo.com/hc/en-us/articles/115002774932-Getting-Started-with-Flows#the-flow-action-status9).", "meta": {}, "data_type": null, "quote": null, "tags": []}, "flow_trigger": {"name": "flow_trigger", "description": "JSON of metric, segment, list, and/or date-property filters that will trigger this flow. These are applied to the **event level**.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "updated_at": {"name": "updated_at", "description": "Timestamp of when the flow was last updated.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "person_filter": {"name": "person_filter", "description": "JSON of flow filters placed on the **person level** that will trigger this flow.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "variation_id": {"name": "variation_id", "description": "Unique ID of the attributed flow variation group. This does not map onto another table. \n", "meta": {}, "data_type": null, "quote": null, "tags": []}, "total_count_unique_people": {"name": "total_count_unique_people", "description": "The count of the distinct people that have interacted with this flow.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "first_event_at": {"name": "first_event_at", "description": "Timestamp of the first ever interaction between this flow and a person.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "last_event_at": {"name": "last_event_at", "description": "Timestamp of the most recent interaction between this flow and a person.", "meta": {}, "data_type": null, "quote": null, "tags": []}}, "meta": {}, "docs": {"show": true}, "patch_path": "models/klaviyo.yml", "build_path": "target/compiled/klaviyo/models/klaviyo__flows.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "klaviyo"}, "compiled_sql": "with flow as (\n\n select *\n from FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__flow\n),\n\nflow_metrics as (\n\n select *\n from FIVETRAN_STAGING.DBT_FIVETRAN_int_klaviyo.int_klaviyo__campaign_flow_metrics\n),\n\nflow_join as (\n \n \n -- snowflake needs uppercase :)\n\n select\n flow.*, -- has flow_id\n \"VARIATION_ID\",\n \"TOTAL_COUNT_UNIQUE_PEOPLE\",\n \"FIRST_EVENT_AT\",\n \"LAST_EVENT_AT\",\n \"SUM_REVENUE_REFUNDED_ORDER\",\n \"SUM_REVENUE_PLACED_ORDER\",\n \"SUM_REVENUE_ORDERED_PRODUCT\",\n \"SUM_REVENUE_CHECKOUT_STARTED\",\n \"SUM_REVENUE_CANCELLED_ORDER\",\n \"COUNT_ACTIVE_ON_SITE\",\n \"UNIQUE_COUNT_ACTIVE_ON_SITE\",\n \"COUNT_VIEWED_PRODUCT\",\n \"UNIQUE_COUNT_VIEWED_PRODUCT\",\n \"COUNT_ORDERED_PRODUCT\",\n \"UNIQUE_COUNT_ORDERED_PRODUCT\",\n \"COUNT_PLACED_ORDER\",\n \"UNIQUE_COUNT_PLACED_ORDER\",\n \"COUNT_REFUNDED_ORDER\",\n \"UNIQUE_COUNT_REFUNDED_ORDER\",\n \"COUNT_RECEIVED_EMAIL\",\n \"UNIQUE_COUNT_RECEIVED_EMAIL\",\n \"COUNT_CLICKED_EMAIL\",\n \"UNIQUE_COUNT_CLICKED_EMAIL\",\n \"COUNT_OPENED_EMAIL\",\n \"UNIQUE_COUNT_OPENED_EMAIL\",\n \"COUNT_MARKED_EMAIL_AS_SPAM\",\n \"UNIQUE_COUNT_MARKED_EMAIL_AS_SPAM\",\n \"COUNT_UNSUBSCRIBED\",\n \"UNIQUE_COUNT_UNSUBSCRIBED\",\n \"COUNT_RECEIVED_SMS\",\n \"UNIQUE_COUNT_RECEIVED_SMS\",\n \"COUNT_CLICKED_SMS\",\n \"UNIQUE_COUNT_CLICKED_SMS\",\n \"COUNT_SENT_SMS\",\n \"UNIQUE_COUNT_SENT_SMS\",\n \"COUNT_UNSUBSCRIBED_FROM_SMS\",\n \"UNIQUE_COUNT_UNSUBSCRIBED_FROM_SMS\"\n\n from flow\n left join flow_metrics on flow.flow_id = flow_metrics.last_touch_flow_id\n),\n\nfinal as (\n\n select \n *,\n md5(cast(\n \n coalesce(cast(flow_id as \n varchar\n), '') || '-' || coalesce(cast(variation_id as \n varchar\n), '')\n\n as \n varchar\n)) as flow_variation_key\n\n from flow_join\n)\n\nselect *\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": "FIVETRAN_STAGING.DBT_FIVETRAN_klaviyo.klaviyo__flows"}, "model.klaviyo.klaviyo__campaigns": {"raw_sql": "with campaign as (\n\n select *\n from {{ var('campaign') }}\n),\n\ncampaign_metrics as (\n\n select *\n from {{ ref('int_klaviyo__campaign_flow_metrics') }}\n),\n\ncampaign_join as (\n \n {% set exclude_fields = [ 'last_touch_campaign_id', 'last_touch_flow_id'] %}\n {% set exclude_fields = exclude_fields | upper if target.type == 'snowflake' else exclude_fields %} -- snowflake needs uppercase :)\n\n select\n campaign.*, -- has campaign_id\n {{ dbt_utils.star(from=ref('int_klaviyo__campaign_flow_metrics'), except=exclude_fields) }}\n\n from campaign\n left join campaign_metrics on campaign.campaign_id = campaign_metrics.last_touch_campaign_id\n),\n\nfinal as (\n\n select \n *,\n {{ dbt_utils.surrogate_key(['campaign_id','variation_id']) }} as campaign_variation_key\n\n from campaign_join\n)\n\nselect *\nfrom final", "compiled": true, "resource_type": "model", "depends_on": {"macros": ["macro.dbt_utils.star", "macro.dbt_utils.surrogate_key"], "nodes": ["model.klaviyo_source.stg_klaviyo__campaign", "model.klaviyo.int_klaviyo__campaign_flow_metrics", "model.klaviyo.int_klaviyo__campaign_flow_metrics"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "klaviyo", "database": null, "tags": [], "full_refresh": null, "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_klaviyo", "fqn": ["klaviyo", "klaviyo__campaigns"], "unique_id": "model.klaviyo.klaviyo__campaigns", "package_name": "klaviyo", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo", "path": "klaviyo__campaigns.sql", "original_file_path": "models/klaviyo__campaigns.sql", "name": "klaviyo__campaigns", "alias": "klaviyo__campaigns", "checksum": {"name": "sha256", "checksum": "37dfe113f613b66cf643009f3da120c58153d03551901abf1c578fbf1b7dd8a9"}, "tags": [], "refs": [["stg_klaviyo__campaign"], ["int_klaviyo__campaign_flow_metrics"], ["int_klaviyo__campaign_flow_metrics"]], "sources": [], "description": "Table of unique campaign versions. A campaign with 2 variations will have 2 distinct rows. **Counts** of the unique users and instances of the events, as well as **sums** of the numeric value associated with events (i.e. revenue) will be pivoted out into columns, as configured by the `klaviyo__count_metrics` and `klaviyo__sum_revenue_metrics` variables, respectively. See the dbt_project.yml file for the default metrics used. These columns will be prefixed with `count_`, `unique_count_`, and `sum_revenue_`.\n", "columns": {"campaign_variation_key": {"name": "campaign_variation_key", "description": "Unique key hashed on the campaign and variation IDs.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "campaign_type": {"name": "campaign_type", "description": "Type of campaign.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "created_at": {"name": "created_at", "description": "Timestamp of when the campaign was created, in UTC.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "email_template_id": {"name": "email_template_id", "description": "Foreign key referencing the ID of the `email_template` object that will be the content of this campaign. Note the Email Template is copied when creating this campaign, so future changes to that Email Template will not alter the content of this campaign.\n", "meta": {}, "data_type": null, "quote": null, "tags": []}, "from_email": {"name": "from_email", "description": "The email address your email will be sent from and will be used in the reply-to header.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "from_name": {"name": "from_name", "description": "The name or label associated with the email address you're sending from.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "campaign_id": {"name": "campaign_id", "description": "Unique ID of the campaign.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "is_segmented": {"name": "is_segmented", "description": "Boolean that is true if the campaign is directed at a Klaviyo segment (not a list).", "meta": {}, "data_type": null, "quote": null, "tags": []}, "campaign_name": {"name": "campaign_name", "description": "A name for this campaign. If not specified, this will default to the subject of the campaign.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "scheduled_to_send_at": {"name": "scheduled_to_send_at", "description": "Timestamp of when the campaign is scheduled to be sent in the future, if [\"smart send time\"](https://help.klaviyo.com/hc/en-us/articles/360029794371-Smart-Send-Time-in-Klaviyo#how-to-utilize-smart-send-time3) is used. \n", "meta": {}, "data_type": null, "quote": null, "tags": []}, "sent_at": {"name": "sent_at", "description": "Timestamp of when the campaign was first sent out to users.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "status": {"name": "status", "description": "Current status of the campaign. Either \"draft\", \"scheduled\", \"sent\", or \"cancelled\".", "meta": {}, "data_type": null, "quote": null, "tags": []}, "status_id": {"name": "status_id", "description": "Corresponding ID to the current status.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "subject": {"name": "subject", "description": "The subject line of the campaign's email.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "updated_at": {"name": "updated_at", "description": "Timestamp of when the campaign was last updated.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "variation_id": {"name": "variation_id", "description": "Unique ID of the attributed campaign variation group. This does not map onto another table. \n", "meta": {}, "data_type": null, "quote": null, "tags": []}, "total_count_unique_people": {"name": "total_count_unique_people", "description": "The count of the distinct people that have interacted with this campaign.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "first_event_at": {"name": "first_event_at", "description": "Timestamp of the first ever interaction between this campaign and a person.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "last_event_at": {"name": "last_event_at", "description": "Timestamp of the most recent interaction between this campaign and a person.", "meta": {}, "data_type": null, "quote": null, "tags": []}}, "meta": {}, "docs": {"show": true}, "patch_path": "models/klaviyo.yml", "build_path": "target/compiled/klaviyo/models/klaviyo__campaigns.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "klaviyo"}, "compiled_sql": "with campaign as (\n\n select *\n from FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__campaign\n),\n\ncampaign_metrics as (\n\n select *\n from FIVETRAN_STAGING.DBT_FIVETRAN_int_klaviyo.int_klaviyo__campaign_flow_metrics\n),\n\ncampaign_join as (\n \n \n -- snowflake needs uppercase :)\n\n select\n campaign.*, -- has campaign_id\n \"VARIATION_ID\",\n \"TOTAL_COUNT_UNIQUE_PEOPLE\",\n \"FIRST_EVENT_AT\",\n \"LAST_EVENT_AT\",\n \"SUM_REVENUE_REFUNDED_ORDER\",\n \"SUM_REVENUE_PLACED_ORDER\",\n \"SUM_REVENUE_ORDERED_PRODUCT\",\n \"SUM_REVENUE_CHECKOUT_STARTED\",\n \"SUM_REVENUE_CANCELLED_ORDER\",\n \"COUNT_ACTIVE_ON_SITE\",\n \"UNIQUE_COUNT_ACTIVE_ON_SITE\",\n \"COUNT_VIEWED_PRODUCT\",\n \"UNIQUE_COUNT_VIEWED_PRODUCT\",\n \"COUNT_ORDERED_PRODUCT\",\n \"UNIQUE_COUNT_ORDERED_PRODUCT\",\n \"COUNT_PLACED_ORDER\",\n \"UNIQUE_COUNT_PLACED_ORDER\",\n \"COUNT_REFUNDED_ORDER\",\n \"UNIQUE_COUNT_REFUNDED_ORDER\",\n \"COUNT_RECEIVED_EMAIL\",\n \"UNIQUE_COUNT_RECEIVED_EMAIL\",\n \"COUNT_CLICKED_EMAIL\",\n \"UNIQUE_COUNT_CLICKED_EMAIL\",\n \"COUNT_OPENED_EMAIL\",\n \"UNIQUE_COUNT_OPENED_EMAIL\",\n \"COUNT_MARKED_EMAIL_AS_SPAM\",\n \"UNIQUE_COUNT_MARKED_EMAIL_AS_SPAM\",\n \"COUNT_UNSUBSCRIBED\",\n \"UNIQUE_COUNT_UNSUBSCRIBED\",\n \"COUNT_RECEIVED_SMS\",\n \"UNIQUE_COUNT_RECEIVED_SMS\",\n \"COUNT_CLICKED_SMS\",\n \"UNIQUE_COUNT_CLICKED_SMS\",\n \"COUNT_SENT_SMS\",\n \"UNIQUE_COUNT_SENT_SMS\",\n \"COUNT_UNSUBSCRIBED_FROM_SMS\",\n \"UNIQUE_COUNT_UNSUBSCRIBED_FROM_SMS\"\n\n from campaign\n left join campaign_metrics on campaign.campaign_id = campaign_metrics.last_touch_campaign_id\n),\n\nfinal as (\n\n select \n *,\n md5(cast(\n \n coalesce(cast(campaign_id as \n varchar\n), '') || '-' || coalesce(cast(variation_id as \n varchar\n), '')\n\n as \n varchar\n)) as campaign_variation_key\n\n from campaign_join\n)\n\nselect *\nfrom final", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": "FIVETRAN_STAGING.DBT_FIVETRAN_klaviyo.klaviyo__campaigns"}, "model.klaviyo.klaviyo__events": {"raw_sql": "{{\n config(\n materialized='incremental',\n unique_key='event_id',\n partition_by={\n \"field\": \"occurred_on\",\n \"data_type\": \"date\"\n }\n )\n}}\n\nwith events as (\n\n select *\n from {{ ref('int_klaviyo__event_attribution') }}\n\n {% if is_incremental() %}\n\n -- most events (from all kinds of integrations) at least once every hour\n where _fivetran_synced >= cast(coalesce( \n (\n select {{ dbt_utils.dateadd(datepart = 'hour', \n interval = -1,\n from_date_or_timestamp = 'max(_fivetran_synced)' ) }} \n from {{ this }}\n ), '2012-01-01') as {{ dbt_utils.type_timestamp() }} ) -- klaviyo was founded in 2012, so let's default the min date to then\n {% endif %}\n),\n\nevent_fields as (\n\n -- excluding some fields to rename them and/or make them null if needed\n {% set exclude_fields = ['touch_session', 'last_touch_id', 'session_start_at', 'session_event_type', 'type'] %}\n -- snowflake has to be uppercase :)\n {% set exclude_fields = exclude_fields | upper if target.type == 'snowflake' else exclude_fields %}\n\n select \n {{ dbt_utils.star(from=ref('int_klaviyo__event_attribution'), except=exclude_fields) }},\n\n type, -- need to pull this out because it gets removed by dbt_utils.star, due to being a substring of 'last_touch_event_type'\n\n -- split out campaign and flow IDs\n case \n when last_touch_type = 'campaign' then last_touch_id \n else null end as last_touch_campaign_id,\n case \n when last_touch_type = 'flow' then last_touch_id \n else null end as last_touch_flow_id,\n\n -- only make these non-null if the event indeed qualified for attribution\n case \n when last_touch_id is not null then session_start_at \n else null end as last_touch_at,\n case \n when last_touch_id is not null then session_event_type \n else null end as last_touch_event_type\n \n from events\n),\n\ncampaign as (\n\n select *\n from {{ var('campaign') }}\n),\n\nflow as (\n\n select *\n from {{ var('flow') }}\n),\n\nperson as (\n\n select *\n from {{ var('person') }}\n),\n\n-- just pulling this to join with INTEGRATION\nmetric as (\n\n select *\n from {{ var('metric') }}\n),\n\nintegration as (\n\n select *\n from {{ var('integration') }}\n),\n\njoin_fields as (\n\n select\n event_fields.*,\n campaign.campaign_name,\n campaign.campaign_type,\n campaign.subject as campaign_subject_line,\n flow.flow_name, \n person.city as person_city,\n person.country as person_country,\n person.region as person_region,\n person.email as person_email,\n person.timezone as person_timezone,\n integration.integration_name,\n integration.category as integration_category\n\n from event_fields\n left join campaign on event_fields.last_touch_campaign_id = campaign.campaign_id \n left join flow on event_fields.last_touch_flow_id = flow.flow_id\n left join person on event_fields.person_id = person.person_id\n left join metric on event_fields.metric_id = metric.metric_id \n left join integration on metric.integration_id = integration.integration_id\n)\n\nselect * from join_fields", "compiled": true, "resource_type": "model", "depends_on": {"macros": ["macro.dbt.is_incremental", "macro.dbt_utils.star", "macro.dbt_utils.dateadd", "macro.dbt_utils.type_timestamp"], "nodes": ["model.klaviyo.int_klaviyo__event_attribution", "model.klaviyo.int_klaviyo__event_attribution", "model.klaviyo_source.stg_klaviyo__campaign", "model.klaviyo_source.stg_klaviyo__flow", "model.klaviyo_source.stg_klaviyo__person", "model.klaviyo_source.stg_klaviyo__metric", "model.klaviyo_source.stg_klaviyo__integration"]}, "config": {"enabled": true, "materialized": "incremental", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "klaviyo", "database": null, "tags": [], "full_refresh": null, "unique_key": "event_id", "partition_by": {"field": "occurred_on", "data_type": "date"}, "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_klaviyo", "fqn": ["klaviyo", "klaviyo__events"], "unique_id": "model.klaviyo.klaviyo__events", "package_name": "klaviyo", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo", "path": "klaviyo__events.sql", "original_file_path": "models/klaviyo__events.sql", "name": "klaviyo__events", "alias": "klaviyo__events", "checksum": {"name": "sha256", "checksum": "dc254d3b83ba003ed6edd764beff200dc1f4aadc29c97f347405d1e75ed1e4b4"}, "tags": [], "refs": [["int_klaviyo__event_attribution"], ["int_klaviyo__event_attribution"], ["stg_klaviyo__campaign"], ["stg_klaviyo__flow"], ["stg_klaviyo__person"], ["stg_klaviyo__metric"], ["stg_klaviyo__integration"]], "sources": [], "description": "Table of Klaviyo events, enriched with attribution data (see `int_klaviyo__event_attribution` for details), and information regarding the event's associated user, flow, campaign, and platform/integration. \nNote: this model has an incremental materialization. Custom event-columns specified by the `klaviyo__event_pass_through_columns` variable will appear here as well.\n", "columns": {"variation_id": {"name": "variation_id", "description": "Unique ID of the attributed flow or campaign variation group. This does not map onto another table. \n", "meta": {}, "data_type": null, "quote": null, "tags": []}, "campaign_id": {"name": "campaign_id", "description": "Foreign key referencing the CAMPAIGN that the event is attributed to.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "occurred_at": {"name": "occurred_at", "description": "Timestamp of when the event was triggered.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "flow_id": {"name": "flow_id", "description": "Foreign key referencing the FLOW that the event is attributed to.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "flow_message_id": {"name": "flow_message_id", "description": "Unique ID of the FLOW_MESSAGE that the event is attributed to. This does not map onto another table.\n", "meta": {}, "data_type": null, "quote": null, "tags": []}, "event_id": {"name": "event_id", "description": "Unique ID of the event.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "metric_id": {"name": "metric_id", "description": "Foreign key referencing the metric being captured.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "person_id": {"name": "person_id", "description": "Foreign key referencing the PERSON who triggered the event.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "type": {"name": "type", "description": "Type of event that was triggered. This is the same as the METRIC name.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "uuid": {"name": "uuid", "description": "Universally Unique Identifier of the event.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "numeric_value": {"name": "numeric_value", "description": "Numeric value associated with the event (ie the dollars associated with a purchase).", "meta": {}, "data_type": null, "quote": null, "tags": []}, "touch_type": {"name": "touch_type", "description": "Type of touch/message that the event itself is already attributed to in Klaviyo. Either 'flow', 'campaign', or null. Note that the package will refer to campaign and flow interactions as \"touches\".\n", "meta": {}, "data_type": null, "quote": null, "tags": []}, "occurred_on": {"name": "occurred_on", "description": "Calendar date (UTC) on which the event occurred.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "touch_id": {"name": "touch_id", "description": "Coalescing of the Klaviyo-attributed campaign_id and flow_id.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "last_touch_at": {"name": "last_touch_at", "description": "Timestamp of when, relative to the current event, this person last interacted with a campaign or flow according to Klaviyo. This will be null if the event is not attributed to any flow or campaign. \n", "meta": {}, "data_type": null, "quote": null, "tags": []}, "last_touch_event_type": {"name": "last_touch_event_type", "description": "The type of event through which, relative to the current event, the person last interacted with a campaign or flow. This information is used to determine which lookback window to use (email vs sms). This will be null if the event is not attributed to any flow or campaign.\n", "meta": {}, "data_type": null, "quote": null, "tags": []}, "last_touch_type": {"name": "last_touch_type", "description": "What kind of touch the event was attributed to by the package -- 'campaign', 'flow', or null.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "last_touch_campaign_id": {"name": "last_touch_campaign_id", "description": "Foreign key referencing the CAMPAIGN that the event is attributed to by the package.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "last_touch_flow_id": {"name": "last_touch_flow_id", "description": "Foreign key referencing the FLOW that the event is attributed to by the package.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "campaign_name": {"name": "campaign_name", "description": "A name for this campaign. If not specified, this will default to the subject of the campaign.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "campaign_type": {"name": "campaign_type", "description": "Type of campaign.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "campaign_subject_line": {"name": "campaign_subject_line", "description": "Type of campaign.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "flow_name": {"name": "flow_name", "description": "Name of the flow.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "person_city": {"name": "person_city", "description": "City that the person who triggered this event lives in.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "person_country": {"name": "person_country", "description": "Country that the person who triggered this event lives in.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "person_region": {"name": "person_region", "description": "Region or state that the person who triggered this event lives in.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "person_email": {"name": "person_email", "description": "The email address and the unique identifier for the person who triggered the event.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "person_timezone": {"name": "person_timezone", "description": "Timezone that the person who triggered this event is situated in.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "integration_name": {"name": "integration_name", "description": "Name of the platform that triggered the event (either Klaviyo, the API, or another integration).", "meta": {}, "data_type": null, "quote": null, "tags": []}, "integration_category": {"name": "integration_category", "description": "Use-case category of the platform that sent the event.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "_fivetran_synced": {"name": "_fivetran_synced", "description": "UTC Timestamp that indicates the start time of the Fivetran job that synced this event row.", "meta": {}, "data_type": null, "quote": null, "tags": []}}, "meta": {}, "docs": {"show": true}, "patch_path": "models/klaviyo.yml", "build_path": "target/compiled/klaviyo/models/klaviyo__events.sql", "deferred": false, "unrendered_config": {"materialized": "incremental", "schema": "klaviyo", "unique_key": "event_id", "partition_by": {"field": "occurred_on", "data_type": "date"}}, "compiled_sql": "\n\nwith events as (\n\n select *\n from FIVETRAN_STAGING.DBT_FIVETRAN_int_klaviyo.int_klaviyo__event_attribution\n\n \n\n -- most events (from all kinds of integrations) at least once every hour\n where _fivetran_synced >= cast(coalesce( \n (\n select \n\n dateadd(\n hour,\n -1,\n max(_fivetran_synced)\n )\n\n \n from FIVETRAN_STAGING.DBT_FIVETRAN_klaviyo.klaviyo__events\n ), '2012-01-01') as \n timestamp_ntz\n ) -- klaviyo was founded in 2012, so let's default the min date to then\n \n),\n\nevent_fields as (\n\n -- excluding some fields to rename them and/or make them null if needed\n \n -- snowflake has to be uppercase :)\n \n\n select \n \"VARIATION_ID\",\n \"CAMPAIGN_ID\",\n \"OCCURRED_AT\",\n \"FLOW_ID\",\n \"FLOW_MESSAGE_ID\",\n \"EVENT_ID\",\n \"METRIC_ID\",\n \"PERSON_ID\",\n \"UUID\",\n \"NUMERIC_VALUE\",\n \"_FIVETRAN_SYNCED\",\n \"OCCURRED_ON\",\n \"TOUCH_TYPE\",\n \"LAST_TOUCH_TYPE\",\n\n type, -- need to pull this out because it gets removed by dbt_utils.star, due to being a substring of 'last_touch_event_type'\n\n -- split out campaign and flow IDs\n case \n when last_touch_type = 'campaign' then last_touch_id \n else null end as last_touch_campaign_id,\n case \n when last_touch_type = 'flow' then last_touch_id \n else null end as last_touch_flow_id,\n\n -- only make these non-null if the event indeed qualified for attribution\n case \n when last_touch_id is not null then session_start_at \n else null end as last_touch_at,\n case \n when last_touch_id is not null then session_event_type \n else null end as last_touch_event_type\n \n from events\n),\n\ncampaign as (\n\n select *\n from FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__campaign\n),\n\nflow as (\n\n select *\n from FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__flow\n),\n\nperson as (\n\n select *\n from FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__person\n),\n\n-- just pulling this to join with INTEGRATION\nmetric as (\n\n select *\n from FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__metric\n),\n\nintegration as (\n\n select *\n from FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__integration\n),\n\njoin_fields as (\n\n select\n event_fields.*,\n campaign.campaign_name,\n campaign.campaign_type,\n campaign.subject as campaign_subject_line,\n flow.flow_name, \n person.city as person_city,\n person.country as person_country,\n person.region as person_region,\n person.email as person_email,\n person.timezone as person_timezone,\n integration.integration_name,\n integration.category as integration_category\n\n from event_fields\n left join campaign on event_fields.last_touch_campaign_id = campaign.campaign_id \n left join flow on event_fields.last_touch_flow_id = flow.flow_id\n left join person on event_fields.person_id = person.person_id\n left join metric on event_fields.metric_id = metric.metric_id \n left join integration on metric.integration_id = integration.integration_id\n)\n\nselect * from join_fields", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": "FIVETRAN_STAGING.DBT_FIVETRAN_klaviyo.klaviyo__events"}, "model.klaviyo.int_klaviyo__campaign_flow_metrics": {"raw_sql": "with person_campaign_flow as (\n\n select *\n from {{ ref('klaviyo__person_campaign_flow') }}\n),\n\n{%- set pcf_columns = adapter.get_columns_in_relation(ref('klaviyo__person_campaign_flow')) %}\n\n-- aggregating to the campaign/flow - variation level. so a flow with A/B versions will have 2 rows\nagg_metrics as (\n\n select\n last_touch_campaign_id,\n last_touch_flow_id,\n variation_id,\n count(distinct person_id) as total_count_unique_people,\n min(first_event_at) as first_event_at,\n max(last_event_at) as last_event_at\n \n {% for col in pcf_columns if col.name|lower not in ['last_touch_campaign_id', 'person_id', 'last_touch_flow_id', \n 'campaign_name', 'flow_name','variation_id', 'first_event_at', 'last_event_at'] %}\n -- sum up any person-level metrics to the flow/campaign level\n , sum( {{ col.name }} ) as {{ col.name }}\n\n {% if 'sum_revenue' not in col.name|lower %} -- only look at 'count' metrics for unique people counts\n -- get unique number of people who did each kind of event\n -- each record in person_campaign_flow is at the person-campaign/flow-variation level, \n -- so we can just sum up 0s and 1s to get totals at the campaign/flow-variation grain.\n , sum(case when {{ col.name }} > 0 then 1 else 0 end) as {{ 'unique_' ~ col.name }}\n\n {% endif %}\n {% endfor -%}\n\n from person_campaign_flow\n group by 1,2,3\n)\n\nselect * from agg_metrics", "compiled": true, "resource_type": "model", "depends_on": {"macros": [], "nodes": ["model.klaviyo.klaviyo__person_campaign_flow", "model.klaviyo.klaviyo__person_campaign_flow"]}, "config": {"enabled": true, "materialized": "view", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "int_klaviyo", "database": null, "tags": [], "full_refresh": null, "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_int_klaviyo", "fqn": ["klaviyo", "intermediate", "int_klaviyo__campaign_flow_metrics"], "unique_id": "model.klaviyo.int_klaviyo__campaign_flow_metrics", "package_name": "klaviyo", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo", "path": "intermediate/int_klaviyo__campaign_flow_metrics.sql", "original_file_path": "models/intermediate/int_klaviyo__campaign_flow_metrics.sql", "name": "int_klaviyo__campaign_flow_metrics", "alias": "int_klaviyo__campaign_flow_metrics", "checksum": {"name": "sha256", "checksum": "891b96f6acc47d792ebcacff46b093ee7381b275d1e910bcaa246e63f219aa75"}, "tags": [], "refs": [["klaviyo__person_campaign_flow"], ["klaviyo__person_campaign_flow"]], "sources": [], "description": "Table that draws from the `klaviyo__person_campaign_flow` model to aggregate event metrics to the campaign or flow AND variation grain. A campaign with A/B versions will have 2 records. **Counts** of the unique users and instances of the events, as well as **sums** of the numeric value associated with events (i.e. revenue) will be pivoted out into columns, as configured by the `klaviyo__count_metrics` and `klaviyo__sum_revenue_metrics` variables, respectively. See the dbt_project.yml file for the default metrics used. These columns will be prefixed with `count_`, `unique_count_`, and `sum_revenue_`.\n", "columns": {"last_touch_campaign_id": {"name": "last_touch_campaign_id", "description": "Foreign key referencing the CAMPAIGN attributed with these metrics (by the package's attribution model).", "meta": {}, "data_type": null, "quote": null, "tags": []}, "last_touch_flow_id": {"name": "last_touch_flow_id", "description": "Foreign key referencing the FLOW attributed with these metrics (by the package's attribution model).", "meta": {}, "data_type": null, "quote": null, "tags": []}, "variation_id": {"name": "variation_id", "description": "Unique ID of the attributed flow or campaign variation group. This does not map onto another table. \n", "meta": {}, "data_type": null, "quote": null, "tags": []}, "total_count_unique_people": {"name": "total_count_unique_people", "description": "The count of the distinct people that have interacted with this campaign or flow.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "first_event_at": {"name": "first_event_at", "description": "Timestamp of the first ever interaction between this campaign/flow and a person.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "last_event_at": {"name": "last_event_at", "description": "Timestamp of the most recent interaction between this campaign/flow and a person.", "meta": {}, "data_type": null, "quote": null, "tags": []}}, "meta": {}, "docs": {"show": true}, "patch_path": "models/intermediate/int_klaviyo.yml", "build_path": "target/compiled/klaviyo/models/intermediate/int_klaviyo__campaign_flow_metrics.sql", "deferred": false, "unrendered_config": {"materialized": "view", "schema": "int_klaviyo"}, "compiled_sql": "with person_campaign_flow as (\n\n select *\n from FIVETRAN_STAGING.DBT_FIVETRAN_klaviyo.klaviyo__person_campaign_flow\n),\n\n-- aggregating to the campaign/flow - variation level. so a flow with A/B versions will have 2 rows\nagg_metrics as (\n\n select\n last_touch_campaign_id,\n last_touch_flow_id,\n variation_id,\n count(distinct person_id) as total_count_unique_people,\n min(first_event_at) as first_event_at,\n max(last_event_at) as last_event_at\n \n \n -- sum up any person-level metrics to the flow/campaign level\n , sum( SUM_REVENUE_REFUNDED_ORDER ) as SUM_REVENUE_REFUNDED_ORDER\n\n \n \n -- sum up any person-level metrics to the flow/campaign level\n , sum( SUM_REVENUE_PLACED_ORDER ) as SUM_REVENUE_PLACED_ORDER\n\n \n \n -- sum up any person-level metrics to the flow/campaign level\n , sum( SUM_REVENUE_ORDERED_PRODUCT ) as SUM_REVENUE_ORDERED_PRODUCT\n\n \n \n -- sum up any person-level metrics to the flow/campaign level\n , sum( SUM_REVENUE_CHECKOUT_STARTED ) as SUM_REVENUE_CHECKOUT_STARTED\n\n \n \n -- sum up any person-level metrics to the flow/campaign level\n , sum( SUM_REVENUE_CANCELLED_ORDER ) as SUM_REVENUE_CANCELLED_ORDER\n\n \n \n -- sum up any person-level metrics to the flow/campaign level\n , sum( COUNT_ACTIVE_ON_SITE ) as COUNT_ACTIVE_ON_SITE\n\n -- only look at 'count' metrics for unique people counts\n -- get unique number of people who did each kind of event\n -- each record in person_campaign_flow is at the person-campaign/flow-variation level, \n -- so we can just sum up 0s and 1s to get totals at the campaign/flow-variation grain.\n , sum(case when COUNT_ACTIVE_ON_SITE > 0 then 1 else 0 end) as unique_COUNT_ACTIVE_ON_SITE\n\n \n \n -- sum up any person-level metrics to the flow/campaign level\n , sum( COUNT_VIEWED_PRODUCT ) as COUNT_VIEWED_PRODUCT\n\n -- only look at 'count' metrics for unique people counts\n -- get unique number of people who did each kind of event\n -- each record in person_campaign_flow is at the person-campaign/flow-variation level, \n -- so we can just sum up 0s and 1s to get totals at the campaign/flow-variation grain.\n , sum(case when COUNT_VIEWED_PRODUCT > 0 then 1 else 0 end) as unique_COUNT_VIEWED_PRODUCT\n\n \n \n -- sum up any person-level metrics to the flow/campaign level\n , sum( COUNT_ORDERED_PRODUCT ) as COUNT_ORDERED_PRODUCT\n\n -- only look at 'count' metrics for unique people counts\n -- get unique number of people who did each kind of event\n -- each record in person_campaign_flow is at the person-campaign/flow-variation level, \n -- so we can just sum up 0s and 1s to get totals at the campaign/flow-variation grain.\n , sum(case when COUNT_ORDERED_PRODUCT > 0 then 1 else 0 end) as unique_COUNT_ORDERED_PRODUCT\n\n \n \n -- sum up any person-level metrics to the flow/campaign level\n , sum( COUNT_PLACED_ORDER ) as COUNT_PLACED_ORDER\n\n -- only look at 'count' metrics for unique people counts\n -- get unique number of people who did each kind of event\n -- each record in person_campaign_flow is at the person-campaign/flow-variation level, \n -- so we can just sum up 0s and 1s to get totals at the campaign/flow-variation grain.\n , sum(case when COUNT_PLACED_ORDER > 0 then 1 else 0 end) as unique_COUNT_PLACED_ORDER\n\n \n \n -- sum up any person-level metrics to the flow/campaign level\n , sum( COUNT_REFUNDED_ORDER ) as COUNT_REFUNDED_ORDER\n\n -- only look at 'count' metrics for unique people counts\n -- get unique number of people who did each kind of event\n -- each record in person_campaign_flow is at the person-campaign/flow-variation level, \n -- so we can just sum up 0s and 1s to get totals at the campaign/flow-variation grain.\n , sum(case when COUNT_REFUNDED_ORDER > 0 then 1 else 0 end) as unique_COUNT_REFUNDED_ORDER\n\n \n \n -- sum up any person-level metrics to the flow/campaign level\n , sum( COUNT_RECEIVED_EMAIL ) as COUNT_RECEIVED_EMAIL\n\n -- only look at 'count' metrics for unique people counts\n -- get unique number of people who did each kind of event\n -- each record in person_campaign_flow is at the person-campaign/flow-variation level, \n -- so we can just sum up 0s and 1s to get totals at the campaign/flow-variation grain.\n , sum(case when COUNT_RECEIVED_EMAIL > 0 then 1 else 0 end) as unique_COUNT_RECEIVED_EMAIL\n\n \n \n -- sum up any person-level metrics to the flow/campaign level\n , sum( COUNT_CLICKED_EMAIL ) as COUNT_CLICKED_EMAIL\n\n -- only look at 'count' metrics for unique people counts\n -- get unique number of people who did each kind of event\n -- each record in person_campaign_flow is at the person-campaign/flow-variation level, \n -- so we can just sum up 0s and 1s to get totals at the campaign/flow-variation grain.\n , sum(case when COUNT_CLICKED_EMAIL > 0 then 1 else 0 end) as unique_COUNT_CLICKED_EMAIL\n\n \n \n -- sum up any person-level metrics to the flow/campaign level\n , sum( COUNT_OPENED_EMAIL ) as COUNT_OPENED_EMAIL\n\n -- only look at 'count' metrics for unique people counts\n -- get unique number of people who did each kind of event\n -- each record in person_campaign_flow is at the person-campaign/flow-variation level, \n -- so we can just sum up 0s and 1s to get totals at the campaign/flow-variation grain.\n , sum(case when COUNT_OPENED_EMAIL > 0 then 1 else 0 end) as unique_COUNT_OPENED_EMAIL\n\n \n \n -- sum up any person-level metrics to the flow/campaign level\n , sum( COUNT_MARKED_EMAIL_AS_SPAM ) as COUNT_MARKED_EMAIL_AS_SPAM\n\n -- only look at 'count' metrics for unique people counts\n -- get unique number of people who did each kind of event\n -- each record in person_campaign_flow is at the person-campaign/flow-variation level, \n -- so we can just sum up 0s and 1s to get totals at the campaign/flow-variation grain.\n , sum(case when COUNT_MARKED_EMAIL_AS_SPAM > 0 then 1 else 0 end) as unique_COUNT_MARKED_EMAIL_AS_SPAM\n\n \n \n -- sum up any person-level metrics to the flow/campaign level\n , sum( COUNT_UNSUBSCRIBED ) as COUNT_UNSUBSCRIBED\n\n -- only look at 'count' metrics for unique people counts\n -- get unique number of people who did each kind of event\n -- each record in person_campaign_flow is at the person-campaign/flow-variation level, \n -- so we can just sum up 0s and 1s to get totals at the campaign/flow-variation grain.\n , sum(case when COUNT_UNSUBSCRIBED > 0 then 1 else 0 end) as unique_COUNT_UNSUBSCRIBED\n\n \n \n -- sum up any person-level metrics to the flow/campaign level\n , sum( COUNT_RECEIVED_SMS ) as COUNT_RECEIVED_SMS\n\n -- only look at 'count' metrics for unique people counts\n -- get unique number of people who did each kind of event\n -- each record in person_campaign_flow is at the person-campaign/flow-variation level, \n -- so we can just sum up 0s and 1s to get totals at the campaign/flow-variation grain.\n , sum(case when COUNT_RECEIVED_SMS > 0 then 1 else 0 end) as unique_COUNT_RECEIVED_SMS\n\n \n \n -- sum up any person-level metrics to the flow/campaign level\n , sum( COUNT_CLICKED_SMS ) as COUNT_CLICKED_SMS\n\n -- only look at 'count' metrics for unique people counts\n -- get unique number of people who did each kind of event\n -- each record in person_campaign_flow is at the person-campaign/flow-variation level, \n -- so we can just sum up 0s and 1s to get totals at the campaign/flow-variation grain.\n , sum(case when COUNT_CLICKED_SMS > 0 then 1 else 0 end) as unique_COUNT_CLICKED_SMS\n\n \n \n -- sum up any person-level metrics to the flow/campaign level\n , sum( COUNT_SENT_SMS ) as COUNT_SENT_SMS\n\n -- only look at 'count' metrics for unique people counts\n -- get unique number of people who did each kind of event\n -- each record in person_campaign_flow is at the person-campaign/flow-variation level, \n -- so we can just sum up 0s and 1s to get totals at the campaign/flow-variation grain.\n , sum(case when COUNT_SENT_SMS > 0 then 1 else 0 end) as unique_COUNT_SENT_SMS\n\n \n \n -- sum up any person-level metrics to the flow/campaign level\n , sum( COUNT_UNSUBSCRIBED_FROM_SMS ) as COUNT_UNSUBSCRIBED_FROM_SMS\n\n -- only look at 'count' metrics for unique people counts\n -- get unique number of people who did each kind of event\n -- each record in person_campaign_flow is at the person-campaign/flow-variation level, \n -- so we can just sum up 0s and 1s to get totals at the campaign/flow-variation grain.\n , sum(case when COUNT_UNSUBSCRIBED_FROM_SMS > 0 then 1 else 0 end) as unique_COUNT_UNSUBSCRIBED_FROM_SMS\n\n \n from person_campaign_flow\n group by 1,2,3\n)\n\nselect * from agg_metrics", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": "FIVETRAN_STAGING.DBT_FIVETRAN_int_klaviyo.int_klaviyo__campaign_flow_metrics"}, "model.klaviyo.int_klaviyo__person_metrics": {"raw_sql": "with person_campaign_flow as (\n\n select *\n from {{ ref('klaviyo__person_campaign_flow') }}\n),\n\n{%- set pcf_columns = adapter.get_columns_in_relation(ref('klaviyo__person_campaign_flow')) %}\n\nagg_metrics as (\n\n select\n person_id,\n count(distinct last_touch_campaign_id) as count_total_campaigns,\n count(distinct last_touch_flow_id) as count_total_flows,\n min(first_event_at) as first_event_at, -- first ever event occurred at\n max(last_event_at) as last_event_at, -- last ever event occurred at\n min(distinct case when last_touch_campaign_id is not null then first_event_at end) as first_campaign_touch_at,\n max(distinct case when last_touch_campaign_id is not null then last_event_at end) as last_campaign_touch_at,\n min(distinct case when last_touch_flow_id is not null then first_event_at end) as first_flow_touch_at,\n max(distinct case when last_touch_flow_id is not null then last_event_at end) as last_flow_touch_at\n\n {% for col in pcf_columns if col.name|lower not in ['last_touch_campaign_id', 'person_id', 'last_touch_flow_id', \n 'campaign_name', 'flow_name','variation_id', 'first_event_at', 'last_event_at'] %}\n -- sum up any count/sum_revenue metrics -> prefix with `total` since we're pulling out organic sums as well\n , sum( {{ col.name }} ) as {{ 'total_' ~ col.name }}\n\n -- let's pull out the organic (not attributed to a flow or campaign) revenue sums\n {% if 'sum_revenue' in col.name|lower %}\n , sum( case when coalesce(last_touch_campaign_id, last_touch_flow_id) is null then {{ col.name }} else 0 end ) as {{ 'organic_' ~ col.name }}\n {% endif %}\n\n {% endfor -%}\n\n from person_campaign_flow\n group by 1\n\n)\n\nselect * from agg_metrics", "compiled": true, "resource_type": "model", "depends_on": {"macros": [], "nodes": ["model.klaviyo.klaviyo__person_campaign_flow", "model.klaviyo.klaviyo__person_campaign_flow"]}, "config": {"enabled": true, "materialized": "view", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "int_klaviyo", "database": null, "tags": [], "full_refresh": null, "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_int_klaviyo", "fqn": ["klaviyo", "intermediate", "int_klaviyo__person_metrics"], "unique_id": "model.klaviyo.int_klaviyo__person_metrics", "package_name": "klaviyo", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo", "path": "intermediate/int_klaviyo__person_metrics.sql", "original_file_path": "models/intermediate/int_klaviyo__person_metrics.sql", "name": "int_klaviyo__person_metrics", "alias": "int_klaviyo__person_metrics", "checksum": {"name": "sha256", "checksum": "99ee8b0688d1cb4011e7df186b3a6a27e639e80eb22240aed3d0fcfc515f8839"}, "tags": [], "refs": [["klaviyo__person_campaign_flow"], ["klaviyo__person_campaign_flow"]], "sources": [], "description": "Table that draws from the `klaviyo__person_campaign_flow` model to aggregate event metrics to the person grain. \n \n**Counts** of instances of the events and **sums** of the numeric value (i.e. revenue) associated with events (total vs organic/not attributed to flows or campaigns) will be pivoted out into columns, as configured by the `klaviyo__count_metrics` and `klaviyo__sum_revenue_metrics`variables, respectively. See the dbt_project.yml file for the default metrics used. \nThese columns will be prefixed with `total_count_`, `total_sum_revenue_` (organic + attributed), and `organic_sum_revenue_` (not attributed to a campaign or flow). \n", "columns": {"person_id": {"name": "person_id", "description": "Unique ID of the person.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "count_total_campaigns": {"name": "count_total_campaigns", "description": "Count of the number of campaigns this person has interacted with.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "count_total_flows": {"name": "count_total_flows", "description": "Count of the number of flows this person has interacted with.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "first_event_at": {"name": "first_event_at", "description": "Timestamp of when the user first triggered an event (not limited to campaign and flow interactions).", "meta": {}, "data_type": null, "quote": null, "tags": []}, "last_event_at": {"name": "last_event_at", "description": "Timestamp of when the user last triggered an event (not limited to campaign and flow interactions).", "meta": {}, "data_type": null, "quote": null, "tags": []}, "first_campaign_touch_at": {"name": "first_campaign_touch_at", "description": "Timestamp of when the user first interacted with a campaign.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "last_campaign_touch_at": {"name": "last_campaign_touch_at", "description": "Timestamp of when the user last interacted with a campaign.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "first_flow_touch_at": {"name": "first_flow_touch_at", "description": "Timestamp of when the user first interacted with a flow.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "last_flow_touch_at": {"name": "last_flow_touch_at", "description": "Timestamp of when the user last interacted with a flow.", "meta": {}, "data_type": null, "quote": null, "tags": []}}, "meta": {}, "docs": {"show": true}, "patch_path": "models/intermediate/int_klaviyo.yml", "build_path": "target/compiled/klaviyo/models/intermediate/int_klaviyo__person_metrics.sql", "deferred": false, "unrendered_config": {"materialized": "view", "schema": "int_klaviyo"}, "compiled_sql": "with person_campaign_flow as (\n\n select *\n from FIVETRAN_STAGING.DBT_FIVETRAN_klaviyo.klaviyo__person_campaign_flow\n),\n\nagg_metrics as (\n\n select\n person_id,\n count(distinct last_touch_campaign_id) as count_total_campaigns,\n count(distinct last_touch_flow_id) as count_total_flows,\n min(first_event_at) as first_event_at, -- first ever event occurred at\n max(last_event_at) as last_event_at, -- last ever event occurred at\n min(distinct case when last_touch_campaign_id is not null then first_event_at end) as first_campaign_touch_at,\n max(distinct case when last_touch_campaign_id is not null then last_event_at end) as last_campaign_touch_at,\n min(distinct case when last_touch_flow_id is not null then first_event_at end) as first_flow_touch_at,\n max(distinct case when last_touch_flow_id is not null then last_event_at end) as last_flow_touch_at\n\n \n -- sum up any count/sum_revenue metrics -> prefix with `total` since we're pulling out organic sums as well\n , sum( SUM_REVENUE_REFUNDED_ORDER ) as total_SUM_REVENUE_REFUNDED_ORDER\n\n -- let's pull out the organic (not attributed to a flow or campaign) revenue sums\n \n , sum( case when coalesce(last_touch_campaign_id, last_touch_flow_id) is null then SUM_REVENUE_REFUNDED_ORDER else 0 end ) as organic_SUM_REVENUE_REFUNDED_ORDER\n \n\n \n -- sum up any count/sum_revenue metrics -> prefix with `total` since we're pulling out organic sums as well\n , sum( SUM_REVENUE_PLACED_ORDER ) as total_SUM_REVENUE_PLACED_ORDER\n\n -- let's pull out the organic (not attributed to a flow or campaign) revenue sums\n \n , sum( case when coalesce(last_touch_campaign_id, last_touch_flow_id) is null then SUM_REVENUE_PLACED_ORDER else 0 end ) as organic_SUM_REVENUE_PLACED_ORDER\n \n\n \n -- sum up any count/sum_revenue metrics -> prefix with `total` since we're pulling out organic sums as well\n , sum( SUM_REVENUE_ORDERED_PRODUCT ) as total_SUM_REVENUE_ORDERED_PRODUCT\n\n -- let's pull out the organic (not attributed to a flow or campaign) revenue sums\n \n , sum( case when coalesce(last_touch_campaign_id, last_touch_flow_id) is null then SUM_REVENUE_ORDERED_PRODUCT else 0 end ) as organic_SUM_REVENUE_ORDERED_PRODUCT\n \n\n \n -- sum up any count/sum_revenue metrics -> prefix with `total` since we're pulling out organic sums as well\n , sum( SUM_REVENUE_CHECKOUT_STARTED ) as total_SUM_REVENUE_CHECKOUT_STARTED\n\n -- let's pull out the organic (not attributed to a flow or campaign) revenue sums\n \n , sum( case when coalesce(last_touch_campaign_id, last_touch_flow_id) is null then SUM_REVENUE_CHECKOUT_STARTED else 0 end ) as organic_SUM_REVENUE_CHECKOUT_STARTED\n \n\n \n -- sum up any count/sum_revenue metrics -> prefix with `total` since we're pulling out organic sums as well\n , sum( SUM_REVENUE_CANCELLED_ORDER ) as total_SUM_REVENUE_CANCELLED_ORDER\n\n -- let's pull out the organic (not attributed to a flow or campaign) revenue sums\n \n , sum( case when coalesce(last_touch_campaign_id, last_touch_flow_id) is null then SUM_REVENUE_CANCELLED_ORDER else 0 end ) as organic_SUM_REVENUE_CANCELLED_ORDER\n \n\n \n -- sum up any count/sum_revenue metrics -> prefix with `total` since we're pulling out organic sums as well\n , sum( COUNT_ACTIVE_ON_SITE ) as total_COUNT_ACTIVE_ON_SITE\n\n -- let's pull out the organic (not attributed to a flow or campaign) revenue sums\n \n\n \n -- sum up any count/sum_revenue metrics -> prefix with `total` since we're pulling out organic sums as well\n , sum( COUNT_VIEWED_PRODUCT ) as total_COUNT_VIEWED_PRODUCT\n\n -- let's pull out the organic (not attributed to a flow or campaign) revenue sums\n \n\n \n -- sum up any count/sum_revenue metrics -> prefix with `total` since we're pulling out organic sums as well\n , sum( COUNT_ORDERED_PRODUCT ) as total_COUNT_ORDERED_PRODUCT\n\n -- let's pull out the organic (not attributed to a flow or campaign) revenue sums\n \n\n \n -- sum up any count/sum_revenue metrics -> prefix with `total` since we're pulling out organic sums as well\n , sum( COUNT_PLACED_ORDER ) as total_COUNT_PLACED_ORDER\n\n -- let's pull out the organic (not attributed to a flow or campaign) revenue sums\n \n\n \n -- sum up any count/sum_revenue metrics -> prefix with `total` since we're pulling out organic sums as well\n , sum( COUNT_REFUNDED_ORDER ) as total_COUNT_REFUNDED_ORDER\n\n -- let's pull out the organic (not attributed to a flow or campaign) revenue sums\n \n\n \n -- sum up any count/sum_revenue metrics -> prefix with `total` since we're pulling out organic sums as well\n , sum( COUNT_RECEIVED_EMAIL ) as total_COUNT_RECEIVED_EMAIL\n\n -- let's pull out the organic (not attributed to a flow or campaign) revenue sums\n \n\n \n -- sum up any count/sum_revenue metrics -> prefix with `total` since we're pulling out organic sums as well\n , sum( COUNT_CLICKED_EMAIL ) as total_COUNT_CLICKED_EMAIL\n\n -- let's pull out the organic (not attributed to a flow or campaign) revenue sums\n \n\n \n -- sum up any count/sum_revenue metrics -> prefix with `total` since we're pulling out organic sums as well\n , sum( COUNT_OPENED_EMAIL ) as total_COUNT_OPENED_EMAIL\n\n -- let's pull out the organic (not attributed to a flow or campaign) revenue sums\n \n\n \n -- sum up any count/sum_revenue metrics -> prefix with `total` since we're pulling out organic sums as well\n , sum( COUNT_MARKED_EMAIL_AS_SPAM ) as total_COUNT_MARKED_EMAIL_AS_SPAM\n\n -- let's pull out the organic (not attributed to a flow or campaign) revenue sums\n \n\n \n -- sum up any count/sum_revenue metrics -> prefix with `total` since we're pulling out organic sums as well\n , sum( COUNT_UNSUBSCRIBED ) as total_COUNT_UNSUBSCRIBED\n\n -- let's pull out the organic (not attributed to a flow or campaign) revenue sums\n \n\n \n -- sum up any count/sum_revenue metrics -> prefix with `total` since we're pulling out organic sums as well\n , sum( COUNT_RECEIVED_SMS ) as total_COUNT_RECEIVED_SMS\n\n -- let's pull out the organic (not attributed to a flow or campaign) revenue sums\n \n\n \n -- sum up any count/sum_revenue metrics -> prefix with `total` since we're pulling out organic sums as well\n , sum( COUNT_CLICKED_SMS ) as total_COUNT_CLICKED_SMS\n\n -- let's pull out the organic (not attributed to a flow or campaign) revenue sums\n \n\n \n -- sum up any count/sum_revenue metrics -> prefix with `total` since we're pulling out organic sums as well\n , sum( COUNT_SENT_SMS ) as total_COUNT_SENT_SMS\n\n -- let's pull out the organic (not attributed to a flow or campaign) revenue sums\n \n\n \n -- sum up any count/sum_revenue metrics -> prefix with `total` since we're pulling out organic sums as well\n , sum( COUNT_UNSUBSCRIBED_FROM_SMS ) as total_COUNT_UNSUBSCRIBED_FROM_SMS\n\n -- let's pull out the organic (not attributed to a flow or campaign) revenue sums\n \n\n from person_campaign_flow\n group by 1\n\n)\n\nselect * from agg_metrics", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": "FIVETRAN_STAGING.DBT_FIVETRAN_int_klaviyo.int_klaviyo__person_metrics"}, "model.klaviyo.int_klaviyo__event_attribution": {"raw_sql": "{{\n config(\n materialized='incremental',\n unique_key='event_id',\n partition_by={\n \"field\": \"occurred_on\",\n \"data_type\": \"date\"\n } if target.type != 'spark' else ['occurred_on']\n )\n}}\n\nwith events as (\n\n select \n *,\n -- no event will be attributed to both a campaign and flow\n coalesce(campaign_id, flow_id) as touch_id,\n case \n when campaign_id is not null then 'campaign' \n when flow_id is not null then 'flow' \n else null end as touch_type -- defintion: touch = interaction with campaign/flow\n\n from {{ var('event_table') }}\n\n {% if is_incremental() %}\n -- grab **ALL** events for users who have any events in this new increment\n where person_id in (\n\n select distinct person_id\n from {{ var('event_table') }}\n\n -- most events (from all kinds of integrations) at least once every hour\n -- https://help.klaviyo.com/hc/en-us/articles/115005253208\n where _fivetran_synced >= cast(coalesce( \n (\n select {{ dbt_utils.dateadd(datepart = 'hour', \n interval = -1,\n from_date_or_timestamp = 'max(_fivetran_synced)' ) }} \n from {{ this }}\n ), '2012-01-01') as {{ dbt_utils.type_timestamp() }} ) -- klaviyo was founded in 2012, so let's default the min date to then\n )\n {% endif %}\n),\n\n-- sessionize events based on attribution eligibility -- is it the right kind of event, and does it have a campaign or flow?\ncreate_sessions as (\n select\n *,\n -- default klaviyo__event_attribution_filter limits attribution-eligible events to to email opens, email clicks, and sms opens\n -- https://help.klaviyo.com/hc/en-us/articles/115005248128\n\n -- events that come with flow/campaign attributions (and are eligible event types) will create new sessions.\n -- non-attributed events that come in afterward will be batched into the same attribution-session\n sum(case when touch_id is not null\n {% if var('klaviyo__eligible_attribution_events') != [] %}\n and lower(type) in {{ \"('\" ~ (var('klaviyo__eligible_attribution_events') | join(\"', '\")) ~ \"')\" }}\n {% endif %}\n then 1 else 0 end) over (\n partition by person_id order by occurred_at asc rows between unbounded preceding and current row) as touch_session \n\n from events\n\n),\n\n-- \"session start\" refers to the event in a \"touch session\" that is already attributed with a campaign or flow by Klaviyo\n-- a new event that is attributed with a campaign/flow will trigger a new session, so there will only be one already-attributed event per each session \n-- events that are missing attributions will borrow data from the event that triggered the session, if they are in the lookback window (see `attribute` CTE)\nlast_touches as (\n\n select \n *,\n -- when did the touch session begin?\n min(occurred_at) over(partition by person_id, touch_session) as session_start_at,\n\n -- get the kind of metric/event that triggered the attribution session, in order to decide \n -- to use the sms or email lookback value. \n first_value(type) over(\n partition by person_id, touch_session order by occurred_at asc rows between unbounded preceding and current row) as session_event_type\n\n from create_sessions\n),\n\nattribute as (\n\n select \n *,\n -- klaviyo uses different lookback windows for email and sms events\n -- default email lookback = 5 days (120 hours) -> https://help.klaviyo.com/hc/en-us/articles/115005248128#conversion-tracking1\n -- default sms lookback: 1 day (24 hours -> https://help.klaviyo.com/hc/en-us/articles/115005248128#sms-conversion-tracking7\n\n coalesce(touch_id, -- use pre-attributed flow/campaign if provided\n case \n when {{ dbt_utils.datediff('session_start_at', 'occurred_at', 'hour') }} <= (\n case \n when lower(session_event_type) like '%sms%' then {{ var('klaviyo__sms_attribution_lookback') }}\n else {{ var('klaviyo__email_attribution_lookback') }} end\n ) -- if the events fall within the lookback window, attribute\n then first_value(touch_id) over (\n partition by person_id, touch_session order by occurred_at asc rows between unbounded preceding and current row)\n else null end) as last_touch_id -- session qualified for attribution -> we will call this \"last touch\"\n\n from last_touches \n),\n\nfinal as (\n\n select\n *,\n\n -- get whether the event is attributed to a flow or campaign\n case when last_touch_id is not null then \n coalesce(touch_type, first_value(touch_type) over(\n partition by person_id, touch_session order by occurred_at asc rows between unbounded preceding and current row)) \n\n else null end as last_touch_type -- if the session events qualified for attribution, extract the type of touch they are attributed to\n\n from attribute \n)\n\nselect * from final", "compiled": true, "resource_type": "model", "depends_on": {"macros": ["macro.dbt.is_incremental", "macro.dbt_utils.datediff", "macro.dbt_utils.dateadd", "macro.dbt_utils.type_timestamp"], "nodes": ["model.klaviyo_source.stg_klaviyo__event"]}, "config": {"enabled": true, "materialized": "incremental", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "int_klaviyo", "database": null, "tags": [], "full_refresh": null, "unique_key": "event_id", "partition_by": {"field": "occurred_on", "data_type": "date"}, "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_int_klaviyo", "fqn": ["klaviyo", "intermediate", "int_klaviyo__event_attribution"], "unique_id": "model.klaviyo.int_klaviyo__event_attribution", "package_name": "klaviyo", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo", "path": "intermediate/int_klaviyo__event_attribution.sql", "original_file_path": "models/intermediate/int_klaviyo__event_attribution.sql", "name": "int_klaviyo__event_attribution", "alias": "int_klaviyo__event_attribution", "checksum": {"name": "sha256", "checksum": "a277c7044d8fc321b8b72088d85c7fa82bf96968c8befb11a5b4feb17e79ff4b"}, "tags": [], "refs": [["stg_klaviyo__event"]], "sources": [], "description": "Table enriching events with an additional layer of last-touch attribution. Though Klaviyo already performs attribution on events each day, this extra step is necessary, as certain kinds of events/metrics never get attributed to flows or campaigns via Klaviyo's internal model. \nBy default, the package performs attribution [in line with Klaviyo](https://help.klaviyo.com/hc/en-us/articles/115005248128). It considers email opens and clicks, and SMS opens as the events eligible to be credited with conversions. This attribution-eligibility can be configured by the `klaviyo__eligible_attribution_events` variable. Note that this refers to the events eligible to credit campaigns and flows with conversions, _not_ the events eligible to receive attribution (all kinds of events are privy to this).\nSimilar to Klaviyo, the package by default considers the conversion period/lookback window for email events to be 120 hours (5 days) and 24 hours for SMS events. These can be configured through the `klaviyo__email_attribution_lookback` and `klaviyo__sms_attribution_lookback` variables, respectively (in integer-hours).\nNote: this model has an incremental materialization. Custom event-columns specified by the `klaviyo__event_pass_through_columns` variable will appear here as well.\n", "columns": {"variation_id": {"name": "variation_id", "description": "Unique ID of the attributed flow or campaign variation group. This does not map onto another table. \n", "meta": {}, "data_type": null, "quote": null, "tags": []}, "campaign_id": {"name": "campaign_id", "description": "Foreign key referencing the CAMPAIGN that the event is attributed to.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "occurred_at": {"name": "occurred_at", "description": "Timestamp of when the event was triggered.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "flow_id": {"name": "flow_id", "description": "Foreign key referencing the FLOW that the event is attributed to.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "flow_message_id": {"name": "flow_message_id", "description": "Unique ID of the FLOW_MESSAGE that the event is attributed to. This does not map onto another table.\n", "meta": {}, "data_type": null, "quote": null, "tags": []}, "event_id": {"name": "event_id", "description": "Unique ID of the event.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "metric_id": {"name": "metric_id", "description": "Foreign key referencing the metric being captured.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "person_id": {"name": "person_id", "description": "Foreign key referencing the PERSON who triggered the event.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "type": {"name": "type", "description": "Type of event that was triggered. This is the same as the METRIC name.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "uuid": {"name": "uuid", "description": "Universally Unique Identifier of the event.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "numeric_value": {"name": "numeric_value", "description": "Numeric value associated with the event (ie the dollars associated with a purchase).", "meta": {}, "data_type": null, "quote": null, "tags": []}, "touch_type": {"name": "touch_type", "description": "Type of touch/message that the event itself is already attributed to in Klaviyo. Either 'flow', 'campaign', or null. Note that the package will refer to campaign and flow interactions as \"touches\".\n", "meta": {}, "data_type": null, "quote": null, "tags": []}, "occurred_on": {"name": "occurred_on", "description": "Calendar date (UTC) on which the event occurred.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "touch_id": {"name": "touch_id", "description": "Coalescing of the Klaviyo-attributed campaign_id and flow_id.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "touch_session": {"name": "touch_session", "description": "ID used to batch an individual person's events into attribution-groups. Each event that comes attributed to a campaign or flow begins a new session/batch, in which the following events without a flow/campaign_id have the same `touch_session` (and may be attributed to the same flow/campaign).\n", "meta": {}, "data_type": null, "quote": null, "tags": []}, "session_start_at": {"name": "session_start_at", "description": "Timestamp of when, relative to the current event, this person last interacted with a campaign or flow according to Klaviyo. This is the beginning of the event's touch-session.\n", "meta": {}, "data_type": null, "quote": null, "tags": []}, "session_event_type": {"name": "session_event_type", "description": "The type of event through which, relative to the current event, the person last interacted with a campaign or flow. This information is used to determine which lookback window to use (email vs sms).\n", "meta": {}, "data_type": null, "quote": null, "tags": []}, "last_touch_id": {"name": "last_touch_id", "description": "The campaign or flow that the package attributed the event to.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "last_touch_type": {"name": "last_touch_type", "description": "What kind of touch the event was attributed to by the package -- 'campaign', 'flow', or null.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "_fivetran_synced": {"name": "_fivetran_synced", "description": "UTC Timestamp that indicates the start time of the Fivetran job that synced this event row.", "meta": {}, "data_type": null, "quote": null, "tags": []}}, "meta": {}, "docs": {"show": true}, "patch_path": "models/intermediate/int_klaviyo.yml", "build_path": "target/compiled/klaviyo/models/intermediate/int_klaviyo__event_attribution.sql", "deferred": false, "unrendered_config": {"materialized": "incremental", "schema": "int_klaviyo", "unique_key": "event_id", "partition_by": {"field": "occurred_on", "data_type": "date"}}, "compiled_sql": "\n\nwith events as (\n\n select \n *,\n -- no event will be attributed to both a campaign and flow\n coalesce(campaign_id, flow_id) as touch_id,\n case \n when campaign_id is not null then 'campaign' \n when flow_id is not null then 'flow' \n else null end as touch_type -- defintion: touch = interaction with campaign/flow\n\n from FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__event\n\n \n -- grab **ALL** events for users who have any events in this new increment\n where person_id in (\n\n select distinct person_id\n from FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__event\n\n -- most events (from all kinds of integrations) at least once every hour\n -- https://help.klaviyo.com/hc/en-us/articles/115005253208\n where _fivetran_synced >= cast(coalesce( \n (\n select \n\n dateadd(\n hour,\n -1,\n max(_fivetran_synced)\n )\n\n \n from FIVETRAN_STAGING.DBT_FIVETRAN_int_klaviyo.int_klaviyo__event_attribution\n ), '2012-01-01') as \n timestamp_ntz\n ) -- klaviyo was founded in 2012, so let's default the min date to then\n )\n \n),\n\n-- sessionize events based on attribution eligibility -- is it the right kind of event, and does it have a campaign or flow?\ncreate_sessions as (\n select\n *,\n -- default klaviyo__event_attribution_filter limits attribution-eligible events to to email opens, email clicks, and sms opens\n -- https://help.klaviyo.com/hc/en-us/articles/115005248128\n\n -- events that come with flow/campaign attributions (and are eligible event types) will create new sessions.\n -- non-attributed events that come in afterward will be batched into the same attribution-session\n sum(case when touch_id is not null\n \n and lower(type) in ('opened email', 'clicked email', 'clicked sms')\n \n then 1 else 0 end) over (\n partition by person_id order by occurred_at asc rows between unbounded preceding and current row) as touch_session \n\n from events\n\n),\n\n-- \"session start\" refers to the event in a \"touch session\" that is already attributed with a campaign or flow by Klaviyo\n-- a new event that is attributed with a campaign/flow will trigger a new session, so there will only be one already-attributed event per each session \n-- events that are missing attributions will borrow data from the event that triggered the session, if they are in the lookback window (see `attribute` CTE)\nlast_touches as (\n\n select \n *,\n -- when did the touch session begin?\n min(occurred_at) over(partition by person_id, touch_session) as session_start_at,\n\n -- get the kind of metric/event that triggered the attribution session, in order to decide \n -- to use the sms or email lookback value. \n first_value(type) over(\n partition by person_id, touch_session order by occurred_at asc rows between unbounded preceding and current row) as session_event_type\n\n from create_sessions\n),\n\nattribute as (\n\n select \n *,\n -- klaviyo uses different lookback windows for email and sms events\n -- default email lookback = 5 days (120 hours) -> https://help.klaviyo.com/hc/en-us/articles/115005248128#conversion-tracking1\n -- default sms lookback: 1 day (24 hours -> https://help.klaviyo.com/hc/en-us/articles/115005248128#sms-conversion-tracking7\n\n coalesce(touch_id, -- use pre-attributed flow/campaign if provided\n case \n when \n\n datediff(\n hour,\n session_start_at,\n occurred_at\n )\n\n <= (\n case \n when lower(session_event_type) like '%sms%' then 24\n else 120 end\n ) -- if the events fall within the lookback window, attribute\n then first_value(touch_id) over (\n partition by person_id, touch_session order by occurred_at asc rows between unbounded preceding and current row)\n else null end) as last_touch_id -- session qualified for attribution -> we will call this \"last touch\"\n\n from last_touches \n),\n\nfinal as (\n\n select\n *,\n\n -- get whether the event is attributed to a flow or campaign\n case when last_touch_id is not null then \n coalesce(touch_type, first_value(touch_type) over(\n partition by person_id, touch_session order by occurred_at asc rows between unbounded preceding and current row)) \n\n else null end as last_touch_type -- if the session events qualified for attribution, extract the type of touch they are attributed to\n\n from attribute \n)\n\nselect * from final", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": "FIVETRAN_STAGING.DBT_FIVETRAN_int_klaviyo.int_klaviyo__event_attribution"}, "test.klaviyo.unique_klaviyo__events_event_id": {"raw_sql": "{{ config(severity='ERROR') }}{{ test_unique(**_dbt_schema_test_kwargs) }}", "test_metadata": {"name": "unique", "kwargs": {"column_name": "event_id", "model": "{{ ref('klaviyo__events') }}"}, "namespace": null}, "compiled": true, "resource_type": "test", "depends_on": {"macros": ["macro.dbt.test_unique"], "nodes": ["model.klaviyo.klaviyo__events"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "klaviyo", "database": null, "tags": [], "full_refresh": null, "severity": "ERROR", "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_klaviyo", "fqn": ["klaviyo", "schema_test", "unique_klaviyo__events_event_id"], "unique_id": "test.klaviyo.unique_klaviyo__events_event_id", "package_name": "klaviyo", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo", "path": "schema_test/unique_klaviyo__events_event_id.sql", "original_file_path": "models/klaviyo.yml", "name": "unique_klaviyo__events_event_id", "alias": "unique_klaviyo__events_event_id", "checksum": {"name": "none", "checksum": ""}, "tags": ["schema"], "refs": [["klaviyo__events"]], "sources": [], "description": "", "columns": {}, "meta": {}, "docs": {"show": true}, "patch_path": null, "build_path": "target/compiled/klaviyo/models/klaviyo.yml/schema_test/unique_klaviyo__events_event_id.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "klaviyo", "severity": "ERROR"}, "compiled_sql": "\n \n \n\n\n\nselect count(*) as validation_errors\nfrom (\n\n select\n event_id\n\n from FIVETRAN_STAGING.DBT_FIVETRAN_klaviyo.klaviyo__events\n where event_id is not null\n group by event_id\n having count(*) > 1\n\n) validation_errors\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": null, "column_name": "event_id"}, "test.klaviyo.not_null_klaviyo__events_event_id": {"raw_sql": "{{ config(severity='ERROR') }}{{ test_not_null(**_dbt_schema_test_kwargs) }}", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "event_id", "model": "{{ ref('klaviyo__events') }}"}, "namespace": null}, "compiled": true, "resource_type": "test", "depends_on": {"macros": ["macro.dbt.test_not_null"], "nodes": ["model.klaviyo.klaviyo__events"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "klaviyo", "database": null, "tags": [], "full_refresh": null, "severity": "ERROR", "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_klaviyo", "fqn": ["klaviyo", "schema_test", "not_null_klaviyo__events_event_id"], "unique_id": "test.klaviyo.not_null_klaviyo__events_event_id", "package_name": "klaviyo", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo", "path": "schema_test/not_null_klaviyo__events_event_id.sql", "original_file_path": "models/klaviyo.yml", "name": "not_null_klaviyo__events_event_id", "alias": "not_null_klaviyo__events_event_id", "checksum": {"name": "none", "checksum": ""}, "tags": ["schema"], "refs": [["klaviyo__events"]], "sources": [], "description": "", "columns": {}, "meta": {}, "docs": {"show": true}, "patch_path": null, "build_path": "target/compiled/klaviyo/models/klaviyo.yml/schema_test/not_null_klaviyo__events_event_id.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "klaviyo", "severity": "ERROR"}, "compiled_sql": "\n \n \n\n\n\nselect count(*) as validation_errors\nfrom FIVETRAN_STAGING.DBT_FIVETRAN_klaviyo.klaviyo__events\nwhere event_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": null, "column_name": "event_id"}, "test.klaviyo.dbt_utils_unique_combination_of_columns_klaviyo__person_campaign_flow_person_id__last_touch_campaign_id__last_touch_flow_id__variation_id": {"raw_sql": "{{ config(severity='ERROR') }}{{ dbt_utils.test_unique_combination_of_columns(**_dbt_schema_test_kwargs) }}", "test_metadata": {"name": "unique_combination_of_columns", "kwargs": {"combination_of_columns": ["person_id", "last_touch_campaign_id", "last_touch_flow_id", "variation_id"], "model": "{{ ref('klaviyo__person_campaign_flow') }}"}, "namespace": "dbt_utils"}, "compiled": true, "resource_type": "test", "depends_on": {"macros": ["macro.dbt_utils.test_unique_combination_of_columns"], "nodes": ["model.klaviyo.klaviyo__person_campaign_flow"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "klaviyo", "database": null, "tags": [], "full_refresh": null, "severity": "ERROR", "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_klaviyo", "fqn": ["klaviyo", "schema_test", "dbt_utils_unique_combination_of_columns_klaviyo__person_campaign_flow_person_id__last_touch_campaign_id__last_touch_flow_id__variation_id"], "unique_id": "test.klaviyo.dbt_utils_unique_combination_of_columns_klaviyo__person_campaign_flow_person_id__last_touch_campaign_id__last_touch_flow_id__variation_id", "package_name": "klaviyo", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo", "path": "schema_test/dbt_utils_unique_combination_of_columns_klaviyo__person_campaign_flow_11f481d7c4955f4e816dd183e2822311.sql", "original_file_path": "models/klaviyo.yml", "name": "dbt_utils_unique_combination_of_columns_klaviyo__person_campaign_flow_person_id__last_touch_campaign_id__last_touch_flow_id__variation_id", "alias": "dbt_utils_unique_combination_of_columns_klaviyo__person_campaign_flow_person_id__last_touch_campaign_id__last_touch_flow_id__variation_id", "checksum": {"name": "none", "checksum": ""}, "tags": ["schema"], "refs": [["klaviyo__person_campaign_flow"]], "sources": [], "description": "", "columns": {}, "meta": {}, "docs": {"show": true}, "patch_path": null, "build_path": "target/compiled/klaviyo/models/klaviyo.yml/schema_test/dbt_utils_unique_combination_of_columns_klaviyo__person_campaign_flow_11f481d7c4955f4e816dd183e2822311.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "klaviyo", "severity": "ERROR"}, "compiled_sql": "\n\n\n\n\n\nwith validation_errors as (\n\n select\n person_id, last_touch_campaign_id, last_touch_flow_id, variation_id\n from FIVETRAN_STAGING.DBT_FIVETRAN_klaviyo.klaviyo__person_campaign_flow\n\n group by person_id, last_touch_campaign_id, last_touch_flow_id, variation_id\n having count(*) > 1\n\n)\n\nselect count(*)\nfrom validation_errors\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": null, "column_name": null}, "test.klaviyo.unique_klaviyo__campaigns_campaign_variation_key": {"raw_sql": "{{ config(severity='ERROR') }}{{ test_unique(**_dbt_schema_test_kwargs) }}", "test_metadata": {"name": "unique", "kwargs": {"column_name": "campaign_variation_key", "model": "{{ ref('klaviyo__campaigns') }}"}, "namespace": null}, "compiled": true, "resource_type": "test", "depends_on": {"macros": ["macro.dbt.test_unique"], "nodes": ["model.klaviyo.klaviyo__campaigns"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "klaviyo", "database": null, "tags": [], "full_refresh": null, "severity": "ERROR", "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_klaviyo", "fqn": ["klaviyo", "schema_test", "unique_klaviyo__campaigns_campaign_variation_key"], "unique_id": "test.klaviyo.unique_klaviyo__campaigns_campaign_variation_key", "package_name": "klaviyo", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo", "path": "schema_test/unique_klaviyo__campaigns_campaign_variation_key.sql", "original_file_path": "models/klaviyo.yml", "name": "unique_klaviyo__campaigns_campaign_variation_key", "alias": "unique_klaviyo__campaigns_campaign_variation_key", "checksum": {"name": "none", "checksum": ""}, "tags": ["schema"], "refs": [["klaviyo__campaigns"]], "sources": [], "description": "", "columns": {}, "meta": {}, "docs": {"show": true}, "patch_path": null, "build_path": "target/compiled/klaviyo/models/klaviyo.yml/schema_test/unique_klaviyo__campaigns_campaign_variation_key.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "klaviyo", "severity": "ERROR"}, "compiled_sql": "\n \n \n\n\n\nselect count(*) as validation_errors\nfrom (\n\n select\n campaign_variation_key\n\n from FIVETRAN_STAGING.DBT_FIVETRAN_klaviyo.klaviyo__campaigns\n where campaign_variation_key is not null\n group by campaign_variation_key\n having count(*) > 1\n\n) validation_errors\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": null, "column_name": "campaign_variation_key"}, "test.klaviyo.not_null_klaviyo__campaigns_campaign_variation_key": {"raw_sql": "{{ config(severity='ERROR') }}{{ test_not_null(**_dbt_schema_test_kwargs) }}", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "campaign_variation_key", "model": "{{ ref('klaviyo__campaigns') }}"}, "namespace": null}, "compiled": true, "resource_type": "test", "depends_on": {"macros": ["macro.dbt.test_not_null"], "nodes": ["model.klaviyo.klaviyo__campaigns"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "klaviyo", "database": null, "tags": [], "full_refresh": null, "severity": "ERROR", "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_klaviyo", "fqn": ["klaviyo", "schema_test", "not_null_klaviyo__campaigns_campaign_variation_key"], "unique_id": "test.klaviyo.not_null_klaviyo__campaigns_campaign_variation_key", "package_name": "klaviyo", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo", "path": "schema_test/not_null_klaviyo__campaigns_campaign_variation_key.sql", "original_file_path": "models/klaviyo.yml", "name": "not_null_klaviyo__campaigns_campaign_variation_key", "alias": "not_null_klaviyo__campaigns_campaign_variation_key", "checksum": {"name": "none", "checksum": ""}, "tags": ["schema"], "refs": [["klaviyo__campaigns"]], "sources": [], "description": "", "columns": {}, "meta": {}, "docs": {"show": true}, "patch_path": null, "build_path": "target/compiled/klaviyo/models/klaviyo.yml/schema_test/not_null_klaviyo__campaigns_campaign_variation_key.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "klaviyo", "severity": "ERROR"}, "compiled_sql": "\n \n \n\n\n\nselect count(*) as validation_errors\nfrom FIVETRAN_STAGING.DBT_FIVETRAN_klaviyo.klaviyo__campaigns\nwhere campaign_variation_key is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": null, "column_name": "campaign_variation_key"}, "test.klaviyo.unique_klaviyo__flows_flow_variation_key": {"raw_sql": "{{ config(severity='ERROR') }}{{ test_unique(**_dbt_schema_test_kwargs) }}", "test_metadata": {"name": "unique", "kwargs": {"column_name": "flow_variation_key", "model": "{{ ref('klaviyo__flows') }}"}, "namespace": null}, "compiled": true, "resource_type": "test", "depends_on": {"macros": ["macro.dbt.test_unique"], "nodes": ["model.klaviyo.klaviyo__flows"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "klaviyo", "database": null, "tags": [], "full_refresh": null, "severity": "ERROR", "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_klaviyo", "fqn": ["klaviyo", "schema_test", "unique_klaviyo__flows_flow_variation_key"], "unique_id": "test.klaviyo.unique_klaviyo__flows_flow_variation_key", "package_name": "klaviyo", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo", "path": "schema_test/unique_klaviyo__flows_flow_variation_key.sql", "original_file_path": "models/klaviyo.yml", "name": "unique_klaviyo__flows_flow_variation_key", "alias": "unique_klaviyo__flows_flow_variation_key", "checksum": {"name": "none", "checksum": ""}, "tags": ["schema"], "refs": [["klaviyo__flows"]], "sources": [], "description": "", "columns": {}, "meta": {}, "docs": {"show": true}, "patch_path": null, "build_path": "target/compiled/klaviyo/models/klaviyo.yml/schema_test/unique_klaviyo__flows_flow_variation_key.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "klaviyo", "severity": "ERROR"}, "compiled_sql": "\n \n \n\n\n\nselect count(*) as validation_errors\nfrom (\n\n select\n flow_variation_key\n\n from FIVETRAN_STAGING.DBT_FIVETRAN_klaviyo.klaviyo__flows\n where flow_variation_key is not null\n group by flow_variation_key\n having count(*) > 1\n\n) validation_errors\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": null, "column_name": "flow_variation_key"}, "test.klaviyo.not_null_klaviyo__flows_flow_variation_key": {"raw_sql": "{{ config(severity='ERROR') }}{{ test_not_null(**_dbt_schema_test_kwargs) }}", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "flow_variation_key", "model": "{{ ref('klaviyo__flows') }}"}, "namespace": null}, "compiled": true, "resource_type": "test", "depends_on": {"macros": ["macro.dbt.test_not_null"], "nodes": ["model.klaviyo.klaviyo__flows"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "klaviyo", "database": null, "tags": [], "full_refresh": null, "severity": "ERROR", "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_klaviyo", "fqn": ["klaviyo", "schema_test", "not_null_klaviyo__flows_flow_variation_key"], "unique_id": "test.klaviyo.not_null_klaviyo__flows_flow_variation_key", "package_name": "klaviyo", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo", "path": "schema_test/not_null_klaviyo__flows_flow_variation_key.sql", "original_file_path": "models/klaviyo.yml", "name": "not_null_klaviyo__flows_flow_variation_key", "alias": "not_null_klaviyo__flows_flow_variation_key", "checksum": {"name": "none", "checksum": ""}, "tags": ["schema"], "refs": [["klaviyo__flows"]], "sources": [], "description": "", "columns": {}, "meta": {}, "docs": {"show": true}, "patch_path": null, "build_path": "target/compiled/klaviyo/models/klaviyo.yml/schema_test/not_null_klaviyo__flows_flow_variation_key.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "klaviyo", "severity": "ERROR"}, "compiled_sql": "\n \n \n\n\n\nselect count(*) as validation_errors\nfrom FIVETRAN_STAGING.DBT_FIVETRAN_klaviyo.klaviyo__flows\nwhere flow_variation_key is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": null, "column_name": "flow_variation_key"}, "test.klaviyo.unique_klaviyo__persons_person_id": {"raw_sql": "{{ config(severity='ERROR') }}{{ test_unique(**_dbt_schema_test_kwargs) }}", "test_metadata": {"name": "unique", "kwargs": {"column_name": "person_id", "model": "{{ ref('klaviyo__persons') }}"}, "namespace": null}, "compiled": true, "resource_type": "test", "depends_on": {"macros": ["macro.dbt.test_unique"], "nodes": ["model.klaviyo.klaviyo__persons"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "klaviyo", "database": null, "tags": [], "full_refresh": null, "severity": "ERROR", "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_klaviyo", "fqn": ["klaviyo", "schema_test", "unique_klaviyo__persons_person_id"], "unique_id": "test.klaviyo.unique_klaviyo__persons_person_id", "package_name": "klaviyo", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo", "path": "schema_test/unique_klaviyo__persons_person_id.sql", "original_file_path": "models/klaviyo.yml", "name": "unique_klaviyo__persons_person_id", "alias": "unique_klaviyo__persons_person_id", "checksum": {"name": "none", "checksum": ""}, "tags": ["schema"], "refs": [["klaviyo__persons"]], "sources": [], "description": "", "columns": {}, "meta": {}, "docs": {"show": true}, "patch_path": null, "build_path": "target/compiled/klaviyo/models/klaviyo.yml/schema_test/unique_klaviyo__persons_person_id.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "klaviyo", "severity": "ERROR"}, "compiled_sql": "\n \n \n\n\n\nselect count(*) as validation_errors\nfrom (\n\n select\n person_id\n\n from FIVETRAN_STAGING.DBT_FIVETRAN_klaviyo.klaviyo__persons\n where person_id is not null\n group by person_id\n having count(*) > 1\n\n) validation_errors\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": null, "column_name": "person_id"}, "test.klaviyo.not_null_klaviyo__persons_person_id": {"raw_sql": "{{ config(severity='ERROR') }}{{ test_not_null(**_dbt_schema_test_kwargs) }}", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "person_id", "model": "{{ ref('klaviyo__persons') }}"}, "namespace": null}, "compiled": true, "resource_type": "test", "depends_on": {"macros": ["macro.dbt.test_not_null"], "nodes": ["model.klaviyo.klaviyo__persons"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "klaviyo", "database": null, "tags": [], "full_refresh": null, "severity": "ERROR", "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_klaviyo", "fqn": ["klaviyo", "schema_test", "not_null_klaviyo__persons_person_id"], "unique_id": "test.klaviyo.not_null_klaviyo__persons_person_id", "package_name": "klaviyo", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo", "path": "schema_test/not_null_klaviyo__persons_person_id.sql", "original_file_path": "models/klaviyo.yml", "name": "not_null_klaviyo__persons_person_id", "alias": "not_null_klaviyo__persons_person_id", "checksum": {"name": "none", "checksum": ""}, "tags": ["schema"], "refs": [["klaviyo__persons"]], "sources": [], "description": "", "columns": {}, "meta": {}, "docs": {"show": true}, "patch_path": null, "build_path": "target/compiled/klaviyo/models/klaviyo.yml/schema_test/not_null_klaviyo__persons_person_id.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "klaviyo", "severity": "ERROR"}, "compiled_sql": "\n \n \n\n\n\nselect count(*) as validation_errors\nfrom FIVETRAN_STAGING.DBT_FIVETRAN_klaviyo.klaviyo__persons\nwhere person_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": null, "column_name": "person_id"}, "test.klaviyo.unique_klaviyo__persons_email": {"raw_sql": "{{ config(severity='WARN') }}{{ test_unique(**_dbt_schema_test_kwargs) }}", "test_metadata": {"name": "unique", "kwargs": {"column_name": "email", "model": "{{ ref('klaviyo__persons') }}"}, "namespace": null}, "compiled": true, "resource_type": "test", "depends_on": {"macros": ["macro.dbt.test_unique"], "nodes": ["model.klaviyo.klaviyo__persons"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "klaviyo", "database": null, "tags": [], "full_refresh": null, "severity": "WARN", "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_klaviyo", "fqn": ["klaviyo", "schema_test", "unique_klaviyo__persons_email"], "unique_id": "test.klaviyo.unique_klaviyo__persons_email", "package_name": "klaviyo", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo", "path": "schema_test/unique_klaviyo__persons_email.sql", "original_file_path": "models/klaviyo.yml", "name": "unique_klaviyo__persons_email", "alias": "unique_klaviyo__persons_email", "checksum": {"name": "none", "checksum": ""}, "tags": ["schema"], "refs": [["klaviyo__persons"]], "sources": [], "description": "", "columns": {}, "meta": {}, "docs": {"show": true}, "patch_path": null, "build_path": "target/compiled/klaviyo/models/klaviyo.yml/schema_test/unique_klaviyo__persons_email.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "klaviyo", "severity": "WARN"}, "compiled_sql": "\n \n \n\n\n\nselect count(*) as validation_errors\nfrom (\n\n select\n email\n\n from FIVETRAN_STAGING.DBT_FIVETRAN_klaviyo.klaviyo__persons\n where email is not null\n group by email\n having count(*) > 1\n\n) validation_errors\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": null, "column_name": "email"}, "test.klaviyo.not_null_klaviyo__persons_email": {"raw_sql": "{{ config(severity='ERROR') }}{{ test_not_null(**_dbt_schema_test_kwargs) }}", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "email", "model": "{{ ref('klaviyo__persons') }}"}, "namespace": null}, "compiled": true, "resource_type": "test", "depends_on": {"macros": ["macro.dbt.test_not_null"], "nodes": ["model.klaviyo.klaviyo__persons"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "klaviyo", "database": null, "tags": [], "full_refresh": null, "severity": "ERROR", "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_klaviyo", "fqn": ["klaviyo", "schema_test", "not_null_klaviyo__persons_email"], "unique_id": "test.klaviyo.not_null_klaviyo__persons_email", "package_name": "klaviyo", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo", "path": "schema_test/not_null_klaviyo__persons_email.sql", "original_file_path": "models/klaviyo.yml", "name": "not_null_klaviyo__persons_email", "alias": "not_null_klaviyo__persons_email", "checksum": {"name": "none", "checksum": ""}, "tags": ["schema"], "refs": [["klaviyo__persons"]], "sources": [], "description": "", "columns": {}, "meta": {}, "docs": {"show": true}, "patch_path": null, "build_path": "target/compiled/klaviyo/models/klaviyo.yml/schema_test/not_null_klaviyo__persons_email.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "klaviyo", "severity": "ERROR"}, "compiled_sql": "\n \n \n\n\n\nselect count(*) as validation_errors\nfrom FIVETRAN_STAGING.DBT_FIVETRAN_klaviyo.klaviyo__persons\nwhere email is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": null, "column_name": "email"}, "test.klaviyo.unique_int_klaviyo__event_attribution_event_id": {"raw_sql": "{{ config(severity='ERROR') }}{{ test_unique(**_dbt_schema_test_kwargs) }}", "test_metadata": {"name": "unique", "kwargs": {"column_name": "event_id", "model": "{{ ref('int_klaviyo__event_attribution') }}"}, "namespace": null}, "compiled": true, "resource_type": "test", "depends_on": {"macros": ["macro.dbt.test_unique"], "nodes": ["model.klaviyo.int_klaviyo__event_attribution"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "klaviyo", "database": null, "tags": [], "full_refresh": null, "severity": "ERROR", "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_klaviyo", "fqn": ["klaviyo", "schema_test", "unique_int_klaviyo__event_attribution_event_id"], "unique_id": "test.klaviyo.unique_int_klaviyo__event_attribution_event_id", "package_name": "klaviyo", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo", "path": "schema_test/unique_int_klaviyo__event_attribution_event_id.sql", "original_file_path": "models/intermediate/int_klaviyo.yml", "name": "unique_int_klaviyo__event_attribution_event_id", "alias": "unique_int_klaviyo__event_attribution_event_id", "checksum": {"name": "none", "checksum": ""}, "tags": ["schema"], "refs": [["int_klaviyo__event_attribution"]], "sources": [], "description": "", "columns": {}, "meta": {}, "docs": {"show": true}, "patch_path": null, "build_path": "target/compiled/klaviyo/models/intermediate/int_klaviyo.yml/schema_test/unique_int_klaviyo__event_attribution_event_id.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "klaviyo", "severity": "ERROR"}, "compiled_sql": "\n \n \n\n\n\nselect count(*) as validation_errors\nfrom (\n\n select\n event_id\n\n from FIVETRAN_STAGING.DBT_FIVETRAN_int_klaviyo.int_klaviyo__event_attribution\n where event_id is not null\n group by event_id\n having count(*) > 1\n\n) validation_errors\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": null, "column_name": "event_id"}, "test.klaviyo.not_null_int_klaviyo__event_attribution_event_id": {"raw_sql": "{{ config(severity='ERROR') }}{{ test_not_null(**_dbt_schema_test_kwargs) }}", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "event_id", "model": "{{ ref('int_klaviyo__event_attribution') }}"}, "namespace": null}, "compiled": true, "resource_type": "test", "depends_on": {"macros": ["macro.dbt.test_not_null"], "nodes": ["model.klaviyo.int_klaviyo__event_attribution"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "klaviyo", "database": null, "tags": [], "full_refresh": null, "severity": "ERROR", "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_klaviyo", "fqn": ["klaviyo", "schema_test", "not_null_int_klaviyo__event_attribution_event_id"], "unique_id": "test.klaviyo.not_null_int_klaviyo__event_attribution_event_id", "package_name": "klaviyo", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo", "path": "schema_test/not_null_int_klaviyo__event_attribution_event_id.sql", "original_file_path": "models/intermediate/int_klaviyo.yml", "name": "not_null_int_klaviyo__event_attribution_event_id", "alias": "not_null_int_klaviyo__event_attribution_event_id", "checksum": {"name": "none", "checksum": ""}, "tags": ["schema"], "refs": [["int_klaviyo__event_attribution"]], "sources": [], "description": "", "columns": {}, "meta": {}, "docs": {"show": true}, "patch_path": null, "build_path": "target/compiled/klaviyo/models/intermediate/int_klaviyo.yml/schema_test/not_null_int_klaviyo__event_attribution_event_id.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "klaviyo", "severity": "ERROR"}, "compiled_sql": "\n \n \n\n\n\nselect count(*) as validation_errors\nfrom FIVETRAN_STAGING.DBT_FIVETRAN_int_klaviyo.int_klaviyo__event_attribution\nwhere event_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": null, "column_name": "event_id"}, "model.klaviyo_source.stg_klaviyo__person": {"raw_sql": "with base as (\n\n select * \n from {{ ref('stg_klaviyo__person_tmp') }}\n\n),\n\nfields as (\n\n select\n {{\n fivetran_utils.fill_staging_columns(\n source_columns=adapter.get_columns_in_relation(ref('stg_klaviyo__person_tmp')),\n staging_columns=get_person_columns()\n )\n }}\n \n from base\n),\n\nfinal as (\n \n select \n id as person_id,\n address_1,\n address_2,\n city,\n country,\n zip,\n created as created_at,\n email,\n first_name || ' ' || last_name as full_name,\n latitude,\n longitude,\n organization,\n phone_number,\n region, -- state in USA\n timezone,\n title,\n updated as updated_at\n \n \n {{ fivetran_utils.fill_pass_through_columns('klaviyo__person_pass_through_columns') }}\n\n from fields\n where not coalesce(_fivetran_deleted, false)\n)\n\nselect * from final", "compiled": true, "resource_type": "model", "depends_on": {"macros": ["macro.klaviyo_source.get_person_columns", "macro.fivetran_utils.fill_staging_columns", "macro.fivetran_utils.fill_pass_through_columns"], "nodes": ["model.klaviyo_source.stg_klaviyo__person_tmp", "model.klaviyo_source.stg_klaviyo__person_tmp"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "stg_klaviyo", "database": null, "tags": [], "full_refresh": null, "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_stg_klaviyo", "fqn": ["klaviyo_source", "stg_klaviyo__person"], "unique_id": "model.klaviyo_source.stg_klaviyo__person", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "stg_klaviyo__person.sql", "original_file_path": "models/stg_klaviyo__person.sql", "name": "stg_klaviyo__person", "alias": "stg_klaviyo__person", "checksum": {"name": "sha256", "checksum": "a7ed2968a5c1e107f64e917fb06b1927083da16f3a87f9d2e78ea93c7f2078d6"}, "tags": [], "refs": [["stg_klaviyo__person_tmp"], ["stg_klaviyo__person_tmp"]], "sources": [], "description": "Table storing the profiles of all people/users interacted with. Custom columns can be passed through to downstream models via the `klaviyo__person_pass_through_columns` variable (see README for details).\n", "columns": {"person_id": {"name": "person_id", "description": "Unique ID of the user if you use your own unique identifier. Otherwise, Klaviyo recommends using the email as the primary key. \n", "meta": {}, "data_type": null, "quote": null, "tags": []}, "address_1": {"name": "address_1", "description": "First line of the person's address.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "address_2": {"name": "address_2", "description": "Second line of the person's address.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "city": {"name": "city", "description": "City they live in.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "country": {"name": "country", "description": "Country they live in.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "zip": {"name": "zip", "description": "Postal code where they live.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "created_at": {"name": "created_at", "description": "Timestamp of when the person's profile was created.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "email": {"name": "email", "description": "The email address and the unique identifier for a profile.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "full_name": {"name": "full_name", "description": "Person's full name.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "latitude": {"name": "latitude", "description": "Latitude of the person's location.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "longitude": {"name": "longitude", "description": "Longitude of the person's location.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "organization": {"name": "organization", "description": "Business organization they belong to.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "phone_number": {"name": "phone_number", "description": "Associated phone number.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "region": {"name": "region", "description": "Region or state they live in.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "timezone": {"name": "timezone", "description": "Timezone they are situated in.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "title": {"name": "title", "description": "Title at their business or organization.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "updated_at": {"name": "updated_at", "description": "Timestamp of when the person profile was last updated.", "meta": {}, "data_type": null, "quote": null, "tags": []}}, "meta": {}, "docs": {"show": true}, "patch_path": "models/stg_klaviyo.yml", "build_path": "target/compiled/klaviyo_source/models/stg_klaviyo__person.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "stg_klaviyo"}, "compiled_sql": "with base as (\n\n select * \n from FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__person_tmp\n\n),\n\nfields as (\n\n select\n \n \n \n _fivetran_deleted\n \n as \n \n _fivetran_deleted\n \n, \n \n \n _fivetran_synced\n \n as \n \n _fivetran_synced\n \n, \n \n \n address_1\n \n as \n \n address_1\n \n, \n \n \n address_2\n \n as \n \n address_2\n \n, \n \n \n city\n \n as \n \n city\n \n, \n \n \n country\n \n as \n \n country\n \n, \n \n \n created\n \n as \n \n created\n \n, \n \n \n email\n \n as \n \n email\n \n, \n \n \n first_name\n \n as \n \n first_name\n \n, \n \n \n id\n \n as \n \n id\n \n, \n \n \n last_name\n \n as \n \n last_name\n \n, \n \n \n latitude\n \n as \n \n latitude\n \n, \n \n \n longitude\n \n as \n \n longitude\n \n, \n \n \n organization\n \n as \n \n organization\n \n, \n \n \n phone_number\n \n as \n \n phone_number\n \n, \n \n \n region\n \n as \n \n region\n \n, \n \n \n timezone\n \n as \n \n timezone\n \n, \n \n \n title\n \n as \n \n title\n \n, \n \n \n updated\n \n as \n \n updated\n \n, \n \n \n zip\n \n as \n \n zip\n \n\n\n\n \n from base\n),\n\nfinal as (\n \n select \n id as person_id,\n address_1,\n address_2,\n city,\n country,\n zip,\n created as created_at,\n email,\n first_name || ' ' || last_name as full_name,\n latitude,\n longitude,\n organization,\n phone_number,\n region, -- state in USA\n timezone,\n title,\n updated as updated_at\n \n \n \n\n\n\n\n\n from fields\n where not coalesce(_fivetran_deleted, false)\n)\n\nselect * from final", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": "FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__person"}, "model.klaviyo_source.stg_klaviyo__campaign": {"raw_sql": "with base as (\n\n select * \n from {{ ref('stg_klaviyo__campaign_tmp') }}\n\n),\n\nfields as (\n\n select\n {{\n fivetran_utils.fill_staging_columns(\n source_columns=adapter.get_columns_in_relation(ref('stg_klaviyo__campaign_tmp')),\n staging_columns=get_campaign_columns()\n )\n }}\n \n from base\n),\n\nfinal as (\n \n select\n campaign_type,\n created as created_at,\n email_template_id,\n from_email,\n from_name,\n id as campaign_id,\n is_segmented,\n name as campaign_name,\n send_time as scheduled_to_send_at,\n sent_at,\n coalesce(status, lower(status_label)) as status,\n status_id,\n subject,\n updated as updated_at\n\n from fields\n\n where not coalesce(_fivetran_deleted, false)\n)\n\nselect * from final", "compiled": true, "resource_type": "model", "depends_on": {"macros": ["macro.klaviyo_source.get_campaign_columns", "macro.fivetran_utils.fill_staging_columns"], "nodes": ["model.klaviyo_source.stg_klaviyo__campaign_tmp", "model.klaviyo_source.stg_klaviyo__campaign_tmp"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "stg_klaviyo", "database": null, "tags": [], "full_refresh": null, "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_stg_klaviyo", "fqn": ["klaviyo_source", "stg_klaviyo__campaign"], "unique_id": "model.klaviyo_source.stg_klaviyo__campaign", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "stg_klaviyo__campaign.sql", "original_file_path": "models/stg_klaviyo__campaign.sql", "name": "stg_klaviyo__campaign", "alias": "stg_klaviyo__campaign", "checksum": {"name": "sha256", "checksum": "4bfe25673841d6475cd7abcdfaec825675c4d1eb75af737ea263dc5015045357"}, "tags": [], "refs": [["stg_klaviyo__campaign_tmp"], ["stg_klaviyo__campaign_tmp"]], "sources": [], "description": "Table capturing email campaigns in Klaviyo. \n", "columns": {"campaign_type": {"name": "campaign_type", "description": "Type of campaign.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "created_at": {"name": "created_at", "description": "Timestamp of when the campaign was created, in UTC.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "email_template_id": {"name": "email_template_id", "description": "Foreign key referencing the ID of the `email_template` object that will be the content of this campaign. Note the Email Template is copied when creating this campaign, so future changes to that Email Template will not alter the content of this campaign.\n", "meta": {}, "data_type": null, "quote": null, "tags": []}, "from_email": {"name": "from_email", "description": "The email address your email will be sent from and will be used in the reply-to header.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "from_name": {"name": "from_name", "description": "The name or label associated with the email address you're sending from.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "campaign_id": {"name": "campaign_id", "description": "Unique ID of the campaign.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "is_segmented": {"name": "is_segmented", "description": "Boolean that is true if the campaign is directed at a Klaviyo segment (not a list).", "meta": {}, "data_type": null, "quote": null, "tags": []}, "campaign_name": {"name": "campaign_name", "description": "A name for this campaign. If not specified, this will default to the subject of the campaign.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "scheduled_to_send_at": {"name": "scheduled_to_send_at", "description": "Timestamp of when the campaign is scheduled to be sent in the future, if [\"smart send time\"](https://help.klaviyo.com/hc/en-us/articles/360029794371-Smart-Send-Time-in-Klaviyo#how-to-utilize-smart-send-time3) is used. \n", "meta": {}, "data_type": null, "quote": null, "tags": []}, "sent_at": {"name": "sent_at", "description": "Timestamp of when the campaign was first sent out to users.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "status": {"name": "status", "description": "Current status of the campaign. Either \"draft\", \"scheduled\", \"sent\", or \"cancelled\".", "meta": {}, "data_type": null, "quote": null, "tags": []}, "status_id": {"name": "status_id", "description": "Corresponding ID to the current status.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "subject": {"name": "subject", "description": "The subject line of the campaign's email.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "updated_at": {"name": "updated_at", "description": "Timestamp of when the campaign was last updated.", "meta": {}, "data_type": null, "quote": null, "tags": []}}, "meta": {}, "docs": {"show": true}, "patch_path": "models/stg_klaviyo.yml", "build_path": "target/compiled/klaviyo_source/models/stg_klaviyo__campaign.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "stg_klaviyo"}, "compiled_sql": "with base as (\n\n select * \n from FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__campaign_tmp\n\n),\n\nfields as (\n\n select\n \n \n \n _fivetran_deleted\n \n as \n \n _fivetran_deleted\n \n, \n \n \n _fivetran_synced\n \n as \n \n _fivetran_synced\n \n, \n \n \n campaign_type\n \n as \n \n campaign_type\n \n, \n \n \n created\n \n as \n \n created\n \n, \n \n \n email_template_id\n \n as \n \n email_template_id\n \n, \n \n \n from_email\n \n as \n \n from_email\n \n, \n \n \n from_name\n \n as \n \n from_name\n \n, \n \n \n id\n \n as \n \n id\n \n, \n \n \n is_segmented\n \n as \n \n is_segmented\n \n, \n \n \n name\n \n as \n \n name\n \n, \n \n \n send_time\n \n as \n \n send_time\n \n, \n \n \n sent_at\n \n as \n \n sent_at\n \n, \n \n \n status\n \n as \n \n status\n \n, \n \n \n status_id\n \n as \n \n status_id\n \n, \n \n \n status_label\n \n as \n \n status_label\n \n, \n \n \n subject\n \n as \n \n subject\n \n, \n \n \n updated\n \n as \n \n updated\n \n\n\n\n \n from base\n),\n\nfinal as (\n \n select\n campaign_type,\n created as created_at,\n email_template_id,\n from_email,\n from_name,\n id as campaign_id,\n is_segmented,\n name as campaign_name,\n send_time as scheduled_to_send_at,\n sent_at,\n coalesce(status, lower(status_label)) as status,\n status_id,\n subject,\n updated as updated_at\n\n from fields\n\n where not coalesce(_fivetran_deleted, false)\n)\n\nselect * from final", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": "FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__campaign"}, "model.klaviyo_source.stg_klaviyo__metric": {"raw_sql": "with base as (\n\n select * \n from {{ ref('stg_klaviyo__metric_tmp') }}\n\n),\n\nfields as (\n\n select\n {{\n fivetran_utils.fill_staging_columns(\n source_columns=adapter.get_columns_in_relation(ref('stg_klaviyo__metric_tmp')),\n staging_columns=get_metric_columns()\n )\n }}\n \n from base\n),\n\nfinal as (\n \n select \n created as created_at,\n id as metric_id,\n integration_id,\n name as metric_name,\n updated as updated_at\n\n from fields\n\n where not coalesce(_fivetran_deleted, false)\n)\n\nselect * from final", "compiled": true, "resource_type": "model", "depends_on": {"macros": ["macro.klaviyo_source.get_metric_columns", "macro.fivetran_utils.fill_staging_columns"], "nodes": ["model.klaviyo_source.stg_klaviyo__metric_tmp", "model.klaviyo_source.stg_klaviyo__metric_tmp"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "stg_klaviyo", "database": null, "tags": [], "full_refresh": null, "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_stg_klaviyo", "fqn": ["klaviyo_source", "stg_klaviyo__metric"], "unique_id": "model.klaviyo_source.stg_klaviyo__metric", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "stg_klaviyo__metric.sql", "original_file_path": "models/stg_klaviyo__metric.sql", "name": "stg_klaviyo__metric", "alias": "stg_klaviyo__metric", "checksum": {"name": "sha256", "checksum": "5e38b67cfc141afe49d171ac9bf90f240bf00e219e976f1d293030c97dee9aed"}, "tags": [], "refs": [["stg_klaviyo__metric_tmp"], ["stg_klaviyo__metric_tmp"]], "sources": [], "description": "Table of tracked metrics across integrations in Klaviyo.", "columns": {"created_at": {"name": "created_at", "description": "Timestamp of when the metric was created.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "metric_id": {"name": "metric_id", "description": "Unique ID of the metric being tracked.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "integration_id": {"name": "integration_id", "description": "Foreign key referencing the INTEGRATION that the metric is being pulled from.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "metric_name": {"name": "metric_name", "description": "Name of the metric (same as `EVENT.type`)", "meta": {}, "data_type": null, "quote": null, "tags": []}, "updated_at": {"name": "updated_at", "description": "Timestamp of when the metric was last updated.", "meta": {}, "data_type": null, "quote": null, "tags": []}}, "meta": {}, "docs": {"show": true}, "patch_path": "models/stg_klaviyo.yml", "build_path": "target/compiled/klaviyo_source/models/stg_klaviyo__metric.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "stg_klaviyo"}, "compiled_sql": "with base as (\n\n select * \n from FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__metric_tmp\n\n),\n\nfields as (\n\n select\n \n \n \n _fivetran_deleted\n \n as \n \n _fivetran_deleted\n \n, \n \n \n _fivetran_synced\n \n as \n \n _fivetran_synced\n \n, \n \n \n created\n \n as \n \n created\n \n, \n \n \n id\n \n as \n \n id\n \n, \n \n \n integration_id\n \n as \n \n integration_id\n \n, \n \n \n name\n \n as \n \n name\n \n, \n \n \n updated\n \n as \n \n updated\n \n\n\n\n \n from base\n),\n\nfinal as (\n \n select \n created as created_at,\n id as metric_id,\n integration_id,\n name as metric_name,\n updated as updated_at\n\n from fields\n\n where not coalesce(_fivetran_deleted, false)\n)\n\nselect * from final", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": "FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__metric"}, "model.klaviyo_source.stg_klaviyo__integration": {"raw_sql": "with base as (\n\n select * \n from {{ ref('stg_klaviyo__integration_tmp') }}\n\n),\n\nfields as (\n\n select\n {{\n fivetran_utils.fill_staging_columns(\n source_columns=adapter.get_columns_in_relation(ref('stg_klaviyo__integration_tmp')),\n staging_columns=get_integration_columns()\n )\n }}\n \n from base\n),\n\nfinal as (\n \n select \n category,\n id as integration_id,\n name as integration_name\n\n from fields\n where not coalesce(_fivetran_deleted, false)\n)\n\nselect * from final", "compiled": true, "resource_type": "model", "depends_on": {"macros": ["macro.klaviyo_source.get_integration_columns", "macro.fivetran_utils.fill_staging_columns"], "nodes": ["model.klaviyo_source.stg_klaviyo__integration_tmp", "model.klaviyo_source.stg_klaviyo__integration_tmp"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "stg_klaviyo", "database": null, "tags": [], "full_refresh": null, "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_stg_klaviyo", "fqn": ["klaviyo_source", "stg_klaviyo__integration"], "unique_id": "model.klaviyo_source.stg_klaviyo__integration", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "stg_klaviyo__integration.sql", "original_file_path": "models/stg_klaviyo__integration.sql", "name": "stg_klaviyo__integration", "alias": "stg_klaviyo__integration", "checksum": {"name": "sha256", "checksum": "f3635b66a029826db64c9fbb1fce0df6069e84a1c223027af2d7044df967f9b0"}, "tags": [], "refs": [["stg_klaviyo__integration_tmp"], ["stg_klaviyo__integration_tmp"]], "sources": [], "description": "Table storing third-party platforms integrated into Klaviyo.", "columns": {"category": {"name": "category", "description": "Use-case category of the integrated platform.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "integration_id": {"name": "integration_id", "description": "Unique ID of the integration.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "integration_name": {"name": "integration_name", "description": "Name of the integrated platform.", "meta": {}, "data_type": null, "quote": null, "tags": []}}, "meta": {}, "docs": {"show": true}, "patch_path": "models/stg_klaviyo.yml", "build_path": "target/compiled/klaviyo_source/models/stg_klaviyo__integration.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "stg_klaviyo"}, "compiled_sql": "with base as (\n\n select * \n from FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__integration_tmp\n\n),\n\nfields as (\n\n select\n \n \n \n _fivetran_deleted\n \n as \n \n _fivetran_deleted\n \n, \n \n \n _fivetran_synced\n \n as \n \n _fivetran_synced\n \n, \n \n \n category\n \n as \n \n category\n \n, \n \n \n id\n \n as \n \n id\n \n, \n \n \n name\n \n as \n \n name\n \n\n\n\n \n from base\n),\n\nfinal as (\n \n select \n category,\n id as integration_id,\n name as integration_name\n\n from fields\n where not coalesce(_fivetran_deleted, false)\n)\n\nselect * from final", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": "FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__integration"}, "model.klaviyo_source.stg_klaviyo__flow": {"raw_sql": "with base as (\n\n select * \n from {{ ref('stg_klaviyo__flow_tmp') }}\n\n),\n\nfields as (\n\n select\n {{\n fivetran_utils.fill_staging_columns(\n source_columns=adapter.get_columns_in_relation(ref('stg_klaviyo__flow_tmp')),\n staging_columns=get_flow_columns()\n )\n }}\n \n from base\n),\n\nfinal as (\n \n select \n created as created_at,\n id as flow_id,\n name as flow_name,\n status,\n {% if target.type == 'snowflake'%}\n \"TRIGGER\" \n {% else %}\n trigger\n {% endif %}\n as flow_trigger,\n updated as updated_at,\n customer_filter as person_filter\n\n from fields\n where not coalesce(_fivetran_deleted, false)\n)\n\nselect * from final", "compiled": true, "resource_type": "model", "depends_on": {"macros": ["macro.klaviyo_source.get_flow_columns", "macro.fivetran_utils.fill_staging_columns"], "nodes": ["model.klaviyo_source.stg_klaviyo__flow_tmp", "model.klaviyo_source.stg_klaviyo__flow_tmp"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "stg_klaviyo", "database": null, "tags": [], "full_refresh": null, "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_stg_klaviyo", "fqn": ["klaviyo_source", "stg_klaviyo__flow"], "unique_id": "model.klaviyo_source.stg_klaviyo__flow", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "stg_klaviyo__flow.sql", "original_file_path": "models/stg_klaviyo__flow.sql", "name": "stg_klaviyo__flow", "alias": "stg_klaviyo__flow", "checksum": {"name": "sha256", "checksum": "a5aa523bbbac2a1b81363775c4df06e5f6b58d7fd984cd1cdd93bcb1dcb6adb4"}, "tags": [], "refs": [["stg_klaviyo__flow_tmp"], ["stg_klaviyo__flow_tmp"]], "sources": [], "description": "Table of automated, triggered flow sequences in Klaviyo.", "columns": {"created_at": {"name": "created_at", "description": "Timestamp of when the flow was first created.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "flow_id": {"name": "flow_id", "description": "Unique ID of the flow.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "flow_name": {"name": "flow_name", "description": "Name of the flow.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "status": {"name": "status", "description": "Current status of the flow. Either 'manual', 'live', or 'draft'. Read more [here](https://help.klaviyo.com/hc/en-us/articles/115002774932-Getting-Started-with-Flows#the-flow-action-status9).", "meta": {}, "data_type": null, "quote": null, "tags": []}, "flow_trigger": {"name": "flow_trigger", "description": "JSON of metric, segment, list, and/or date-property filters that will trigger this flow. These are applied to the **event level**.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "updated_at": {"name": "updated_at", "description": "Timestamp of when the flow was last updated.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "person_filter": {"name": "person_filter", "description": "JSON of flow filters placed on the **person level** that will trigger this flow.", "meta": {}, "data_type": null, "quote": null, "tags": []}}, "meta": {}, "docs": {"show": true}, "patch_path": "models/stg_klaviyo.yml", "build_path": "target/compiled/klaviyo_source/models/stg_klaviyo__flow.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "stg_klaviyo"}, "compiled_sql": "with base as (\n\n select * \n from FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__flow_tmp\n\n),\n\nfields as (\n\n select\n \n \n \n _fivetran_deleted\n \n as \n \n _fivetran_deleted\n \n, \n \n \n _fivetran_synced\n \n as \n \n _fivetran_synced\n \n, \n \n \n created\n \n as \n \n created\n \n, \n \n \n id\n \n as \n \n id\n \n, \n \n \n name\n \n as \n \n name\n \n, \n \n \n status\n \n as \n \n status\n \n, \n \n \n \n \n \"TRIGGER\"\n \n \n \n as \n \n \n \n \"TRIGGER\"\n \n \n \n, \n \n \n updated\n \n as \n \n updated\n \n, \n \n \n customer_filter\n \n as \n \n customer_filter\n \n\n\n\n \n from base\n),\n\nfinal as (\n \n select \n created as created_at,\n id as flow_id,\n name as flow_name,\n status,\n \n \"TRIGGER\" \n \n as flow_trigger,\n updated as updated_at,\n customer_filter as person_filter\n\n from fields\n where not coalesce(_fivetran_deleted, false)\n)\n\nselect * from final", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": "FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__flow"}, "model.klaviyo_source.stg_klaviyo__event": {"raw_sql": "with base as (\n\n select * \n from {{ ref('stg_klaviyo__event_tmp') }}\n\n),\n\nfields as (\n\n select\n {{\n fivetran_utils.fill_staging_columns(\n source_columns=adapter.get_columns_in_relation(ref('stg_klaviyo__event_tmp')),\n staging_columns=get_event_columns()\n )\n }}\n \n from base\n),\n\nrename as (\n \n select \n _variation as variation_id,\n campaign_id,\n cast(timestamp as {{ dbt_utils.type_timestamp() }} ) as occurred_at,\n flow_id,\n flow_message_id,\n id as event_id,\n metric_id,\n person_id,\n type,\n uuid,\n property_value as numeric_value,\n _fivetran_synced\n\n {{ fivetran_utils.fill_pass_through_columns('klaviyo__event_pass_through_columns') }}\n \n from fields\n where not coalesce(_fivetran_deleted, false)\n),\n\nfinal as (\n \n select \n *,\n cast( {{ dbt_utils.date_trunc('day', 'occurred_at') }} as date) as occurred_on\n\n from rename\n\n)\n\nselect * from final", "compiled": true, "resource_type": "model", "depends_on": {"macros": ["macro.klaviyo_source.get_event_columns", "macro.fivetran_utils.fill_staging_columns", "macro.dbt_utils.type_timestamp", "macro.fivetran_utils.fill_pass_through_columns", "macro.dbt_utils.date_trunc"], "nodes": ["model.klaviyo_source.stg_klaviyo__event_tmp", "model.klaviyo_source.stg_klaviyo__event_tmp"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "stg_klaviyo", "database": null, "tags": [], "full_refresh": null, "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_stg_klaviyo", "fqn": ["klaviyo_source", "stg_klaviyo__event"], "unique_id": "model.klaviyo_source.stg_klaviyo__event", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "stg_klaviyo__event.sql", "original_file_path": "models/stg_klaviyo__event.sql", "name": "stg_klaviyo__event", "alias": "stg_klaviyo__event", "checksum": {"name": "sha256", "checksum": "f82e6f22953d1e822b008f8c10255e23dd2e346bbc8e3ca933e9d70f89b1d238"}, "tags": [], "refs": [["stg_klaviyo__event_tmp"], ["stg_klaviyo__event_tmp"]], "sources": [], "description": "Table of events (and metrics) triggered in Klaviyo or via its integrations. Custom columns can be passed through to downstream models via the `klaviyo__event_pass_through_columns` variable (see README for details).\n", "columns": {"variation_id": {"name": "variation_id", "description": "Unique ID of the attributed flow or campaign variation group. This does not map onto another table. \n", "meta": {}, "data_type": null, "quote": null, "tags": []}, "campaign_id": {"name": "campaign_id", "description": "Foreign key referencing the CAMPAIGN that the event is attributed to.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "occurred_at": {"name": "occurred_at", "description": "Timestamp of when the event was triggered.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "flow_id": {"name": "flow_id", "description": "Foreign key referencing the FLOW that the event is attributed to.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "flow_message_id": {"name": "flow_message_id", "description": "Unique ID of the FLOW_MESSAGE that the event is attributed to. This does not map onto another table.\n", "meta": {}, "data_type": null, "quote": null, "tags": []}, "event_id": {"name": "event_id", "description": "Unique ID of the event.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "metric_id": {"name": "metric_id", "description": "Foreign key referencing the metric being captured.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "person_id": {"name": "person_id", "description": "Foreign key referencing the PERSON who triggered the event.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "type": {"name": "type", "description": "Type of event that was triggered. This is the same as the METRIC name.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "uuid": {"name": "uuid", "description": "Universally Unique Identifier of the event.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "numeric_value": {"name": "numeric_value", "description": "Numeric value associated with the event (ie the dollars associated with a purchase).", "meta": {}, "data_type": null, "quote": null, "tags": []}, "occurred_on": {"name": "occurred_on", "description": "Calendar date (UTC) on which the event occurred.", "meta": {}, "data_type": null, "quote": null, "tags": []}}, "meta": {}, "docs": {"show": true}, "patch_path": "models/stg_klaviyo.yml", "build_path": "target/compiled/klaviyo_source/models/stg_klaviyo__event.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "stg_klaviyo"}, "compiled_sql": "with base as (\n\n select * \n from FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__event_tmp\n\n),\n\nfields as (\n\n select\n \n \n \n _fivetran_deleted\n \n as \n \n _fivetran_deleted\n \n, \n \n \n _fivetran_synced\n \n as \n \n _fivetran_synced\n \n, \n \n \n _variation\n \n as \n \n _variation\n \n, \n \n \n campaign_id\n \n as \n \n campaign_id\n \n, \n \n \n datetime\n \n as \n \n datetime\n \n, \n \n \n flow_id\n \n as \n \n flow_id\n \n, \n \n \n flow_message_id\n \n as \n \n flow_message_id\n \n, \n \n \n id\n \n as \n \n id\n \n, \n \n \n metric_id\n \n as \n \n metric_id\n \n, \n \n \n person_id\n \n as \n \n person_id\n \n, \n \n \n timestamp\n \n as \n \n timestamp\n \n, \n \n \n type\n \n as \n \n type\n \n, \n \n \n uuid\n \n as \n \n uuid\n \n, \n \n \n property_value\n \n as \n \n property_value\n \n\n\n\n \n from base\n),\n\nrename as (\n \n select \n _variation as variation_id,\n campaign_id,\n cast(timestamp as \n timestamp_ntz\n ) as occurred_at,\n flow_id,\n flow_message_id,\n id as event_id,\n metric_id,\n person_id,\n type,\n uuid,\n property_value as numeric_value,\n _fivetran_synced\n\n \n\n\n\n\n \n from fields\n where not coalesce(_fivetran_deleted, false)\n),\n\nfinal as (\n \n select \n *,\n cast( \n date_trunc('day', occurred_at)\n as date) as occurred_on\n\n from rename\n\n)\n\nselect * from final", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": "FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__event"}, "model.klaviyo_source.stg_klaviyo__event_tmp": {"raw_sql": "select * from {{ var('event_table') }}", "compiled": true, "resource_type": "model", "depends_on": {"macros": [], "nodes": ["source.klaviyo_source.klaviyo.event"]}, "config": {"enabled": true, "materialized": "view", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "stg_klaviyo", "database": null, "tags": [], "full_refresh": null, "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_stg_klaviyo", "fqn": ["klaviyo_source", "tmp", "stg_klaviyo__event_tmp"], "unique_id": "model.klaviyo_source.stg_klaviyo__event_tmp", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "tmp/stg_klaviyo__event_tmp.sql", "original_file_path": "models/tmp/stg_klaviyo__event_tmp.sql", "name": "stg_klaviyo__event_tmp", "alias": "stg_klaviyo__event_tmp", "checksum": {"name": "sha256", "checksum": "b59b71ceb869bc877c37918b08e1d921cd7729e799b2fe12638f6b9c4a4ff512"}, "tags": [], "refs": [], "sources": [["klaviyo", "event"]], "description": "", "columns": {}, "meta": {}, "docs": {"show": true}, "patch_path": null, "build_path": "target/compiled/klaviyo_source/models/tmp/stg_klaviyo__event_tmp.sql", "deferred": false, "unrendered_config": {"materialized": "view", "schema": "stg_klaviyo"}, "compiled_sql": "select * from FIVETRAN_STAGING.klaviyo.event", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": "FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__event_tmp"}, "model.klaviyo_source.stg_klaviyo__metric_tmp": {"raw_sql": "select * from {{ var('metric') }}", "compiled": true, "resource_type": "model", "depends_on": {"macros": [], "nodes": ["source.klaviyo_source.klaviyo.metric"]}, "config": {"enabled": true, "materialized": "view", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "stg_klaviyo", "database": null, "tags": [], "full_refresh": null, "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_stg_klaviyo", "fqn": ["klaviyo_source", "tmp", "stg_klaviyo__metric_tmp"], "unique_id": "model.klaviyo_source.stg_klaviyo__metric_tmp", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "tmp/stg_klaviyo__metric_tmp.sql", "original_file_path": "models/tmp/stg_klaviyo__metric_tmp.sql", "name": "stg_klaviyo__metric_tmp", "alias": "stg_klaviyo__metric_tmp", "checksum": {"name": "sha256", "checksum": "04dbebf47a485c17afe2341fc44036cf0ae50c77fa51b075d47a2f2dd2a91786"}, "tags": [], "refs": [], "sources": [["klaviyo", "metric"]], "description": "", "columns": {}, "meta": {}, "docs": {"show": true}, "patch_path": null, "build_path": "target/compiled/klaviyo_source/models/tmp/stg_klaviyo__metric_tmp.sql", "deferred": false, "unrendered_config": {"materialized": "view", "schema": "stg_klaviyo"}, "compiled_sql": "select * from FIVETRAN_STAGING.klaviyo.metric", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": "FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__metric_tmp"}, "model.klaviyo_source.stg_klaviyo__campaign_tmp": {"raw_sql": "select * from {{ var('campaign') }}", "compiled": true, "resource_type": "model", "depends_on": {"macros": [], "nodes": ["source.klaviyo_source.klaviyo.campaign"]}, "config": {"enabled": true, "materialized": "view", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "stg_klaviyo", "database": null, "tags": [], "full_refresh": null, "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_stg_klaviyo", "fqn": ["klaviyo_source", "tmp", "stg_klaviyo__campaign_tmp"], "unique_id": "model.klaviyo_source.stg_klaviyo__campaign_tmp", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "tmp/stg_klaviyo__campaign_tmp.sql", "original_file_path": "models/tmp/stg_klaviyo__campaign_tmp.sql", "name": "stg_klaviyo__campaign_tmp", "alias": "stg_klaviyo__campaign_tmp", "checksum": {"name": "sha256", "checksum": "9ceeb111f8fd9683a5fd75c76535ada5db1531aeb4a71f179faf1982b5ccbf8c"}, "tags": [], "refs": [], "sources": [["klaviyo", "campaign"]], "description": "", "columns": {}, "meta": {}, "docs": {"show": true}, "patch_path": null, "build_path": "target/compiled/klaviyo_source/models/tmp/stg_klaviyo__campaign_tmp.sql", "deferred": false, "unrendered_config": {"materialized": "view", "schema": "stg_klaviyo"}, "compiled_sql": "select * from FIVETRAN_STAGING.klaviyo.campaign", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": "FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__campaign_tmp"}, "model.klaviyo_source.stg_klaviyo__integration_tmp": {"raw_sql": "select * from {{ var('integration') }}", "compiled": true, "resource_type": "model", "depends_on": {"macros": [], "nodes": ["source.klaviyo_source.klaviyo.integration"]}, "config": {"enabled": true, "materialized": "view", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "stg_klaviyo", "database": null, "tags": [], "full_refresh": null, "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_stg_klaviyo", "fqn": ["klaviyo_source", "tmp", "stg_klaviyo__integration_tmp"], "unique_id": "model.klaviyo_source.stg_klaviyo__integration_tmp", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "tmp/stg_klaviyo__integration_tmp.sql", "original_file_path": "models/tmp/stg_klaviyo__integration_tmp.sql", "name": "stg_klaviyo__integration_tmp", "alias": "stg_klaviyo__integration_tmp", "checksum": {"name": "sha256", "checksum": "f9c7489448d8a816971c24282a0c70c3c803038bc73a08c3ed3de624446276f5"}, "tags": [], "refs": [], "sources": [["klaviyo", "integration"]], "description": "", "columns": {}, "meta": {}, "docs": {"show": true}, "patch_path": null, "build_path": "target/compiled/klaviyo_source/models/tmp/stg_klaviyo__integration_tmp.sql", "deferred": false, "unrendered_config": {"materialized": "view", "schema": "stg_klaviyo"}, "compiled_sql": "select * from FIVETRAN_STAGING.klaviyo.integration", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": "FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__integration_tmp"}, "model.klaviyo_source.stg_klaviyo__flow_tmp": {"raw_sql": "select * from {{ var('flow') }}", "compiled": true, "resource_type": "model", "depends_on": {"macros": [], "nodes": ["source.klaviyo_source.klaviyo.flow"]}, "config": {"enabled": true, "materialized": "view", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "stg_klaviyo", "database": null, "tags": [], "full_refresh": null, "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_stg_klaviyo", "fqn": ["klaviyo_source", "tmp", "stg_klaviyo__flow_tmp"], "unique_id": "model.klaviyo_source.stg_klaviyo__flow_tmp", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "tmp/stg_klaviyo__flow_tmp.sql", "original_file_path": "models/tmp/stg_klaviyo__flow_tmp.sql", "name": "stg_klaviyo__flow_tmp", "alias": "stg_klaviyo__flow_tmp", "checksum": {"name": "sha256", "checksum": "d13b30517ca4423ff5bebdcb31dc961c177b274f99e951e9b7a3940eb64ed8ef"}, "tags": [], "refs": [], "sources": [["klaviyo", "flow"]], "description": "", "columns": {}, "meta": {}, "docs": {"show": true}, "patch_path": null, "build_path": "target/compiled/klaviyo_source/models/tmp/stg_klaviyo__flow_tmp.sql", "deferred": false, "unrendered_config": {"materialized": "view", "schema": "stg_klaviyo"}, "compiled_sql": "select * from FIVETRAN_STAGING.klaviyo.flow", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": "FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__flow_tmp"}, "model.klaviyo_source.stg_klaviyo__person_tmp": {"raw_sql": "select * from {{ var('person') }}", "compiled": true, "resource_type": "model", "depends_on": {"macros": [], "nodes": ["source.klaviyo_source.klaviyo.person"]}, "config": {"enabled": true, "materialized": "view", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "stg_klaviyo", "database": null, "tags": [], "full_refresh": null, "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_stg_klaviyo", "fqn": ["klaviyo_source", "tmp", "stg_klaviyo__person_tmp"], "unique_id": "model.klaviyo_source.stg_klaviyo__person_tmp", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "tmp/stg_klaviyo__person_tmp.sql", "original_file_path": "models/tmp/stg_klaviyo__person_tmp.sql", "name": "stg_klaviyo__person_tmp", "alias": "stg_klaviyo__person_tmp", "checksum": {"name": "sha256", "checksum": "f3ad6c6303eac0e72ffa6c78500e60151167b7bb39bcff09053f2ef0d02233a3"}, "tags": [], "refs": [], "sources": [["klaviyo", "person"]], "description": "", "columns": {}, "meta": {}, "docs": {"show": true}, "patch_path": null, "build_path": "target/compiled/klaviyo_source/models/tmp/stg_klaviyo__person_tmp.sql", "deferred": false, "unrendered_config": {"materialized": "view", "schema": "stg_klaviyo"}, "compiled_sql": "select * from FIVETRAN_STAGING.klaviyo.person", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": "FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__person_tmp"}, "test.klaviyo_source.unique_stg_klaviyo__campaign_campaign_id": {"raw_sql": "{{ config(severity='ERROR') }}{{ test_unique(**_dbt_schema_test_kwargs) }}", "test_metadata": {"name": "unique", "kwargs": {"column_name": "campaign_id", "model": "{{ ref('stg_klaviyo__campaign') }}"}, "namespace": null}, "compiled": true, "resource_type": "test", "depends_on": {"macros": ["macro.dbt.test_unique"], "nodes": ["model.klaviyo_source.stg_klaviyo__campaign"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "stg_klaviyo", "database": null, "tags": [], "full_refresh": null, "severity": "ERROR", "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_stg_klaviyo", "fqn": ["klaviyo_source", "schema_test", "unique_stg_klaviyo__campaign_campaign_id"], "unique_id": "test.klaviyo_source.unique_stg_klaviyo__campaign_campaign_id", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "schema_test/unique_stg_klaviyo__campaign_campaign_id.sql", "original_file_path": "models/stg_klaviyo.yml", "name": "unique_stg_klaviyo__campaign_campaign_id", "alias": "unique_stg_klaviyo__campaign_campaign_id", "checksum": {"name": "none", "checksum": ""}, "tags": ["schema"], "refs": [["stg_klaviyo__campaign"]], "sources": [], "description": "", "columns": {}, "meta": {}, "docs": {"show": true}, "patch_path": null, "build_path": "target/compiled/klaviyo_source/models/stg_klaviyo.yml/schema_test/unique_stg_klaviyo__campaign_campaign_id.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "stg_klaviyo", "severity": "ERROR"}, "compiled_sql": "\n \n \n\n\n\nselect count(*) as validation_errors\nfrom (\n\n select\n campaign_id\n\n from FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__campaign\n where campaign_id is not null\n group by campaign_id\n having count(*) > 1\n\n) validation_errors\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": null, "column_name": "campaign_id"}, "test.klaviyo_source.not_null_stg_klaviyo__campaign_campaign_id": {"raw_sql": "{{ config(severity='ERROR') }}{{ test_not_null(**_dbt_schema_test_kwargs) }}", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "campaign_id", "model": "{{ ref('stg_klaviyo__campaign') }}"}, "namespace": null}, "compiled": true, "resource_type": "test", "depends_on": {"macros": ["macro.dbt.test_not_null"], "nodes": ["model.klaviyo_source.stg_klaviyo__campaign"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "stg_klaviyo", "database": null, "tags": [], "full_refresh": null, "severity": "ERROR", "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_stg_klaviyo", "fqn": ["klaviyo_source", "schema_test", "not_null_stg_klaviyo__campaign_campaign_id"], "unique_id": "test.klaviyo_source.not_null_stg_klaviyo__campaign_campaign_id", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "schema_test/not_null_stg_klaviyo__campaign_campaign_id.sql", "original_file_path": "models/stg_klaviyo.yml", "name": "not_null_stg_klaviyo__campaign_campaign_id", "alias": "not_null_stg_klaviyo__campaign_campaign_id", "checksum": {"name": "none", "checksum": ""}, "tags": ["schema"], "refs": [["stg_klaviyo__campaign"]], "sources": [], "description": "", "columns": {}, "meta": {}, "docs": {"show": true}, "patch_path": null, "build_path": "target/compiled/klaviyo_source/models/stg_klaviyo.yml/schema_test/not_null_stg_klaviyo__campaign_campaign_id.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "stg_klaviyo", "severity": "ERROR"}, "compiled_sql": "\n \n \n\n\n\nselect count(*) as validation_errors\nfrom FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__campaign\nwhere campaign_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": null, "column_name": "campaign_id"}, "test.klaviyo_source.unique_stg_klaviyo__event_event_id": {"raw_sql": "{{ config(severity='ERROR') }}{{ test_unique(**_dbt_schema_test_kwargs) }}", "test_metadata": {"name": "unique", "kwargs": {"column_name": "event_id", "model": "{{ ref('stg_klaviyo__event') }}"}, "namespace": null}, "compiled": true, "resource_type": "test", "depends_on": {"macros": ["macro.dbt.test_unique"], "nodes": ["model.klaviyo_source.stg_klaviyo__event"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "stg_klaviyo", "database": null, "tags": [], "full_refresh": null, "severity": "ERROR", "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_stg_klaviyo", "fqn": ["klaviyo_source", "schema_test", "unique_stg_klaviyo__event_event_id"], "unique_id": "test.klaviyo_source.unique_stg_klaviyo__event_event_id", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "schema_test/unique_stg_klaviyo__event_event_id.sql", "original_file_path": "models/stg_klaviyo.yml", "name": "unique_stg_klaviyo__event_event_id", "alias": "unique_stg_klaviyo__event_event_id", "checksum": {"name": "none", "checksum": ""}, "tags": ["schema"], "refs": [["stg_klaviyo__event"]], "sources": [], "description": "", "columns": {}, "meta": {}, "docs": {"show": true}, "patch_path": null, "build_path": "target/compiled/klaviyo_source/models/stg_klaviyo.yml/schema_test/unique_stg_klaviyo__event_event_id.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "stg_klaviyo", "severity": "ERROR"}, "compiled_sql": "\n \n \n\n\n\nselect count(*) as validation_errors\nfrom (\n\n select\n event_id\n\n from FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__event\n where event_id is not null\n group by event_id\n having count(*) > 1\n\n) validation_errors\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": null, "column_name": "event_id"}, "test.klaviyo_source.not_null_stg_klaviyo__event_event_id": {"raw_sql": "{{ config(severity='ERROR') }}{{ test_not_null(**_dbt_schema_test_kwargs) }}", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "event_id", "model": "{{ ref('stg_klaviyo__event') }}"}, "namespace": null}, "compiled": true, "resource_type": "test", "depends_on": {"macros": ["macro.dbt.test_not_null"], "nodes": ["model.klaviyo_source.stg_klaviyo__event"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "stg_klaviyo", "database": null, "tags": [], "full_refresh": null, "severity": "ERROR", "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_stg_klaviyo", "fqn": ["klaviyo_source", "schema_test", "not_null_stg_klaviyo__event_event_id"], "unique_id": "test.klaviyo_source.not_null_stg_klaviyo__event_event_id", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "schema_test/not_null_stg_klaviyo__event_event_id.sql", "original_file_path": "models/stg_klaviyo.yml", "name": "not_null_stg_klaviyo__event_event_id", "alias": "not_null_stg_klaviyo__event_event_id", "checksum": {"name": "none", "checksum": ""}, "tags": ["schema"], "refs": [["stg_klaviyo__event"]], "sources": [], "description": "", "columns": {}, "meta": {}, "docs": {"show": true}, "patch_path": null, "build_path": "target/compiled/klaviyo_source/models/stg_klaviyo.yml/schema_test/not_null_stg_klaviyo__event_event_id.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "stg_klaviyo", "severity": "ERROR"}, "compiled_sql": "\n \n \n\n\n\nselect count(*) as validation_errors\nfrom FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__event\nwhere event_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": null, "column_name": "event_id"}, "test.klaviyo_source.unique_stg_klaviyo__flow_flow_id": {"raw_sql": "{{ config(severity='ERROR') }}{{ test_unique(**_dbt_schema_test_kwargs) }}", "test_metadata": {"name": "unique", "kwargs": {"column_name": "flow_id", "model": "{{ ref('stg_klaviyo__flow') }}"}, "namespace": null}, "compiled": true, "resource_type": "test", "depends_on": {"macros": ["macro.dbt.test_unique"], "nodes": ["model.klaviyo_source.stg_klaviyo__flow"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "stg_klaviyo", "database": null, "tags": [], "full_refresh": null, "severity": "ERROR", "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_stg_klaviyo", "fqn": ["klaviyo_source", "schema_test", "unique_stg_klaviyo__flow_flow_id"], "unique_id": "test.klaviyo_source.unique_stg_klaviyo__flow_flow_id", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "schema_test/unique_stg_klaviyo__flow_flow_id.sql", "original_file_path": "models/stg_klaviyo.yml", "name": "unique_stg_klaviyo__flow_flow_id", "alias": "unique_stg_klaviyo__flow_flow_id", "checksum": {"name": "none", "checksum": ""}, "tags": ["schema"], "refs": [["stg_klaviyo__flow"]], "sources": [], "description": "", "columns": {}, "meta": {}, "docs": {"show": true}, "patch_path": null, "build_path": "target/compiled/klaviyo_source/models/stg_klaviyo.yml/schema_test/unique_stg_klaviyo__flow_flow_id.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "stg_klaviyo", "severity": "ERROR"}, "compiled_sql": "\n \n \n\n\n\nselect count(*) as validation_errors\nfrom (\n\n select\n flow_id\n\n from FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__flow\n where flow_id is not null\n group by flow_id\n having count(*) > 1\n\n) validation_errors\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": null, "column_name": "flow_id"}, "test.klaviyo_source.not_null_stg_klaviyo__flow_flow_id": {"raw_sql": "{{ config(severity='ERROR') }}{{ test_not_null(**_dbt_schema_test_kwargs) }}", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "flow_id", "model": "{{ ref('stg_klaviyo__flow') }}"}, "namespace": null}, "compiled": true, "resource_type": "test", "depends_on": {"macros": ["macro.dbt.test_not_null"], "nodes": ["model.klaviyo_source.stg_klaviyo__flow"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "stg_klaviyo", "database": null, "tags": [], "full_refresh": null, "severity": "ERROR", "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_stg_klaviyo", "fqn": ["klaviyo_source", "schema_test", "not_null_stg_klaviyo__flow_flow_id"], "unique_id": "test.klaviyo_source.not_null_stg_klaviyo__flow_flow_id", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "schema_test/not_null_stg_klaviyo__flow_flow_id.sql", "original_file_path": "models/stg_klaviyo.yml", "name": "not_null_stg_klaviyo__flow_flow_id", "alias": "not_null_stg_klaviyo__flow_flow_id", "checksum": {"name": "none", "checksum": ""}, "tags": ["schema"], "refs": [["stg_klaviyo__flow"]], "sources": [], "description": "", "columns": {}, "meta": {}, "docs": {"show": true}, "patch_path": null, "build_path": "target/compiled/klaviyo_source/models/stg_klaviyo.yml/schema_test/not_null_stg_klaviyo__flow_flow_id.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "stg_klaviyo", "severity": "ERROR"}, "compiled_sql": "\n \n \n\n\n\nselect count(*) as validation_errors\nfrom FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__flow\nwhere flow_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": null, "column_name": "flow_id"}, "test.klaviyo_source.unique_stg_klaviyo__integration_integration_id": {"raw_sql": "{{ config(severity='ERROR') }}{{ test_unique(**_dbt_schema_test_kwargs) }}", "test_metadata": {"name": "unique", "kwargs": {"column_name": "integration_id", "model": "{{ ref('stg_klaviyo__integration') }}"}, "namespace": null}, "compiled": true, "resource_type": "test", "depends_on": {"macros": ["macro.dbt.test_unique"], "nodes": ["model.klaviyo_source.stg_klaviyo__integration"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "stg_klaviyo", "database": null, "tags": [], "full_refresh": null, "severity": "ERROR", "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_stg_klaviyo", "fqn": ["klaviyo_source", "schema_test", "unique_stg_klaviyo__integration_integration_id"], "unique_id": "test.klaviyo_source.unique_stg_klaviyo__integration_integration_id", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "schema_test/unique_stg_klaviyo__integration_integration_id.sql", "original_file_path": "models/stg_klaviyo.yml", "name": "unique_stg_klaviyo__integration_integration_id", "alias": "unique_stg_klaviyo__integration_integration_id", "checksum": {"name": "none", "checksum": ""}, "tags": ["schema"], "refs": [["stg_klaviyo__integration"]], "sources": [], "description": "", "columns": {}, "meta": {}, "docs": {"show": true}, "patch_path": null, "build_path": "target/compiled/klaviyo_source/models/stg_klaviyo.yml/schema_test/unique_stg_klaviyo__integration_integration_id.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "stg_klaviyo", "severity": "ERROR"}, "compiled_sql": "\n \n \n\n\n\nselect count(*) as validation_errors\nfrom (\n\n select\n integration_id\n\n from FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__integration\n where integration_id is not null\n group by integration_id\n having count(*) > 1\n\n) validation_errors\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": null, "column_name": "integration_id"}, "test.klaviyo_source.not_null_stg_klaviyo__integration_integration_id": {"raw_sql": "{{ config(severity='ERROR') }}{{ test_not_null(**_dbt_schema_test_kwargs) }}", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "integration_id", "model": "{{ ref('stg_klaviyo__integration') }}"}, "namespace": null}, "compiled": true, "resource_type": "test", "depends_on": {"macros": ["macro.dbt.test_not_null"], "nodes": ["model.klaviyo_source.stg_klaviyo__integration"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "stg_klaviyo", "database": null, "tags": [], "full_refresh": null, "severity": "ERROR", "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_stg_klaviyo", "fqn": ["klaviyo_source", "schema_test", "not_null_stg_klaviyo__integration_integration_id"], "unique_id": "test.klaviyo_source.not_null_stg_klaviyo__integration_integration_id", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "schema_test/not_null_stg_klaviyo__integration_integration_id.sql", "original_file_path": "models/stg_klaviyo.yml", "name": "not_null_stg_klaviyo__integration_integration_id", "alias": "not_null_stg_klaviyo__integration_integration_id", "checksum": {"name": "none", "checksum": ""}, "tags": ["schema"], "refs": [["stg_klaviyo__integration"]], "sources": [], "description": "", "columns": {}, "meta": {}, "docs": {"show": true}, "patch_path": null, "build_path": "target/compiled/klaviyo_source/models/stg_klaviyo.yml/schema_test/not_null_stg_klaviyo__integration_integration_id.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "stg_klaviyo", "severity": "ERROR"}, "compiled_sql": "\n \n \n\n\n\nselect count(*) as validation_errors\nfrom FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__integration\nwhere integration_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": null, "column_name": "integration_id"}, "test.klaviyo_source.unique_stg_klaviyo__person_person_id": {"raw_sql": "{{ config(severity='ERROR') }}{{ test_unique(**_dbt_schema_test_kwargs) }}", "test_metadata": {"name": "unique", "kwargs": {"column_name": "person_id", "model": "{{ ref('stg_klaviyo__person') }}"}, "namespace": null}, "compiled": true, "resource_type": "test", "depends_on": {"macros": ["macro.dbt.test_unique"], "nodes": ["model.klaviyo_source.stg_klaviyo__person"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "stg_klaviyo", "database": null, "tags": [], "full_refresh": null, "severity": "ERROR", "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_stg_klaviyo", "fqn": ["klaviyo_source", "schema_test", "unique_stg_klaviyo__person_person_id"], "unique_id": "test.klaviyo_source.unique_stg_klaviyo__person_person_id", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "schema_test/unique_stg_klaviyo__person_person_id.sql", "original_file_path": "models/stg_klaviyo.yml", "name": "unique_stg_klaviyo__person_person_id", "alias": "unique_stg_klaviyo__person_person_id", "checksum": {"name": "none", "checksum": ""}, "tags": ["schema"], "refs": [["stg_klaviyo__person"]], "sources": [], "description": "", "columns": {}, "meta": {}, "docs": {"show": true}, "patch_path": null, "build_path": "target/compiled/klaviyo_source/models/stg_klaviyo.yml/schema_test/unique_stg_klaviyo__person_person_id.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "stg_klaviyo", "severity": "ERROR"}, "compiled_sql": "\n \n \n\n\n\nselect count(*) as validation_errors\nfrom (\n\n select\n person_id\n\n from FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__person\n where person_id is not null\n group by person_id\n having count(*) > 1\n\n) validation_errors\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": null, "column_name": "person_id"}, "test.klaviyo_source.not_null_stg_klaviyo__person_person_id": {"raw_sql": "{{ config(severity='ERROR') }}{{ test_not_null(**_dbt_schema_test_kwargs) }}", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "person_id", "model": "{{ ref('stg_klaviyo__person') }}"}, "namespace": null}, "compiled": true, "resource_type": "test", "depends_on": {"macros": ["macro.dbt.test_not_null"], "nodes": ["model.klaviyo_source.stg_klaviyo__person"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "stg_klaviyo", "database": null, "tags": [], "full_refresh": null, "severity": "ERROR", "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_stg_klaviyo", "fqn": ["klaviyo_source", "schema_test", "not_null_stg_klaviyo__person_person_id"], "unique_id": "test.klaviyo_source.not_null_stg_klaviyo__person_person_id", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "schema_test/not_null_stg_klaviyo__person_person_id.sql", "original_file_path": "models/stg_klaviyo.yml", "name": "not_null_stg_klaviyo__person_person_id", "alias": "not_null_stg_klaviyo__person_person_id", "checksum": {"name": "none", "checksum": ""}, "tags": ["schema"], "refs": [["stg_klaviyo__person"]], "sources": [], "description": "", "columns": {}, "meta": {}, "docs": {"show": true}, "patch_path": null, "build_path": "target/compiled/klaviyo_source/models/stg_klaviyo.yml/schema_test/not_null_stg_klaviyo__person_person_id.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "stg_klaviyo", "severity": "ERROR"}, "compiled_sql": "\n \n \n\n\n\nselect count(*) as validation_errors\nfrom FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__person\nwhere person_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": null, "column_name": "person_id"}, "test.klaviyo_source.unique_stg_klaviyo__person_email": {"raw_sql": "{{ config(severity='WARN') }}{{ test_unique(**_dbt_schema_test_kwargs) }}", "test_metadata": {"name": "unique", "kwargs": {"column_name": "email", "model": "{{ ref('stg_klaviyo__person') }}"}, "namespace": null}, "compiled": true, "resource_type": "test", "depends_on": {"macros": ["macro.dbt.test_unique"], "nodes": ["model.klaviyo_source.stg_klaviyo__person"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "stg_klaviyo", "database": null, "tags": [], "full_refresh": null, "severity": "WARN", "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_stg_klaviyo", "fqn": ["klaviyo_source", "schema_test", "unique_stg_klaviyo__person_email"], "unique_id": "test.klaviyo_source.unique_stg_klaviyo__person_email", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "schema_test/unique_stg_klaviyo__person_email.sql", "original_file_path": "models/stg_klaviyo.yml", "name": "unique_stg_klaviyo__person_email", "alias": "unique_stg_klaviyo__person_email", "checksum": {"name": "none", "checksum": ""}, "tags": ["schema"], "refs": [["stg_klaviyo__person"]], "sources": [], "description": "", "columns": {}, "meta": {}, "docs": {"show": true}, "patch_path": null, "build_path": "target/compiled/klaviyo_source/models/stg_klaviyo.yml/schema_test/unique_stg_klaviyo__person_email.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "stg_klaviyo", "severity": "WARN"}, "compiled_sql": "\n \n \n\n\n\nselect count(*) as validation_errors\nfrom (\n\n select\n email\n\n from FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__person\n where email is not null\n group by email\n having count(*) > 1\n\n) validation_errors\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": null, "column_name": "email"}, "test.klaviyo_source.not_null_stg_klaviyo__person_email": {"raw_sql": "{{ config(severity='ERROR') }}{{ test_not_null(**_dbt_schema_test_kwargs) }}", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "email", "model": "{{ ref('stg_klaviyo__person') }}"}, "namespace": null}, "compiled": true, "resource_type": "test", "depends_on": {"macros": ["macro.dbt.test_not_null"], "nodes": ["model.klaviyo_source.stg_klaviyo__person"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "stg_klaviyo", "database": null, "tags": [], "full_refresh": null, "severity": "ERROR", "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_stg_klaviyo", "fqn": ["klaviyo_source", "schema_test", "not_null_stg_klaviyo__person_email"], "unique_id": "test.klaviyo_source.not_null_stg_klaviyo__person_email", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "schema_test/not_null_stg_klaviyo__person_email.sql", "original_file_path": "models/stg_klaviyo.yml", "name": "not_null_stg_klaviyo__person_email", "alias": "not_null_stg_klaviyo__person_email", "checksum": {"name": "none", "checksum": ""}, "tags": ["schema"], "refs": [["stg_klaviyo__person"]], "sources": [], "description": "", "columns": {}, "meta": {}, "docs": {"show": true}, "patch_path": null, "build_path": "target/compiled/klaviyo_source/models/stg_klaviyo.yml/schema_test/not_null_stg_klaviyo__person_email.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "stg_klaviyo", "severity": "ERROR"}, "compiled_sql": "\n \n \n\n\n\nselect count(*) as validation_errors\nfrom FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__person\nwhere email is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": null, "column_name": "email"}, "test.klaviyo_source.unique_stg_klaviyo__metric_metric_id": {"raw_sql": "{{ config(severity='ERROR') }}{{ test_unique(**_dbt_schema_test_kwargs) }}", "test_metadata": {"name": "unique", "kwargs": {"column_name": "metric_id", "model": "{{ ref('stg_klaviyo__metric') }}"}, "namespace": null}, "compiled": true, "resource_type": "test", "depends_on": {"macros": ["macro.dbt.test_unique"], "nodes": ["model.klaviyo_source.stg_klaviyo__metric"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "stg_klaviyo", "database": null, "tags": [], "full_refresh": null, "severity": "ERROR", "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_stg_klaviyo", "fqn": ["klaviyo_source", "schema_test", "unique_stg_klaviyo__metric_metric_id"], "unique_id": "test.klaviyo_source.unique_stg_klaviyo__metric_metric_id", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "schema_test/unique_stg_klaviyo__metric_metric_id.sql", "original_file_path": "models/stg_klaviyo.yml", "name": "unique_stg_klaviyo__metric_metric_id", "alias": "unique_stg_klaviyo__metric_metric_id", "checksum": {"name": "none", "checksum": ""}, "tags": ["schema"], "refs": [["stg_klaviyo__metric"]], "sources": [], "description": "", "columns": {}, "meta": {}, "docs": {"show": true}, "patch_path": null, "build_path": "target/compiled/klaviyo_source/models/stg_klaviyo.yml/schema_test/unique_stg_klaviyo__metric_metric_id.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "stg_klaviyo", "severity": "ERROR"}, "compiled_sql": "\n \n \n\n\n\nselect count(*) as validation_errors\nfrom (\n\n select\n metric_id\n\n from FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__metric\n where metric_id is not null\n group by metric_id\n having count(*) > 1\n\n) validation_errors\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": null, "column_name": "metric_id"}, "test.klaviyo_source.not_null_stg_klaviyo__metric_metric_id": {"raw_sql": "{{ config(severity='ERROR') }}{{ test_not_null(**_dbt_schema_test_kwargs) }}", "test_metadata": {"name": "not_null", "kwargs": {"column_name": "metric_id", "model": "{{ ref('stg_klaviyo__metric') }}"}, "namespace": null}, "compiled": true, "resource_type": "test", "depends_on": {"macros": ["macro.dbt.test_not_null"], "nodes": ["model.klaviyo_source.stg_klaviyo__metric"]}, "config": {"enabled": true, "materialized": "table", "persist_docs": {}, "vars": {}, "quoting": {}, "column_types": {}, "alias": null, "schema": "stg_klaviyo", "database": null, "tags": [], "full_refresh": null, "severity": "ERROR", "post-hook": [], "pre-hook": []}, "database": "FIVETRAN_STAGING", "schema": "DBT_FIVETRAN_stg_klaviyo", "fqn": ["klaviyo_source", "schema_test", "not_null_stg_klaviyo__metric_metric_id"], "unique_id": "test.klaviyo_source.not_null_stg_klaviyo__metric_metric_id", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "schema_test/not_null_stg_klaviyo__metric_metric_id.sql", "original_file_path": "models/stg_klaviyo.yml", "name": "not_null_stg_klaviyo__metric_metric_id", "alias": "not_null_stg_klaviyo__metric_metric_id", "checksum": {"name": "none", "checksum": ""}, "tags": ["schema"], "refs": [["stg_klaviyo__metric"]], "sources": [], "description": "", "columns": {}, "meta": {}, "docs": {"show": true}, "patch_path": null, "build_path": "target/compiled/klaviyo_source/models/stg_klaviyo.yml/schema_test/not_null_stg_klaviyo__metric_metric_id.sql", "deferred": false, "unrendered_config": {"materialized": "table", "schema": "stg_klaviyo", "severity": "ERROR"}, "compiled_sql": "\n \n \n\n\n\nselect count(*) as validation_errors\nfrom FIVETRAN_STAGING.DBT_FIVETRAN_stg_klaviyo.stg_klaviyo__metric\nwhere metric_id is null\n\n\n", "extra_ctes_injected": true, "extra_ctes": [], "relation_name": null, "column_name": "metric_id"}}, "sources": {"source.klaviyo_source.klaviyo.campaign": {"fqn": ["klaviyo_source", "klaviyo", "campaign"], "database": "FIVETRAN_STAGING", "schema": "klaviyo", "unique_id": "source.klaviyo_source.klaviyo.campaign", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "models/src_klaviyo.yml", "original_file_path": "models/src_klaviyo.yml", "name": "campaign", "source_name": "klaviyo", "source_description": "", "loader": "fivetran", "identifier": "campaign", "resource_type": "source", "quoting": {"database": null, "schema": null, "identifier": null, "column": null}, "loaded_at_field": "_fivetran_synced", "freshness": {"warn_after": {"count": 72, "period": "hour"}, "error_after": {"count": 96, "period": "hour"}, "filter": null}, "external": null, "description": "Table capturing email campaigns in Klaviyo. \n", "columns": {"_fivetran_deleted": {"name": "_fivetran_deleted", "description": "Boolean that is true if the campaign has been soft-deleted.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "campaign_type": {"name": "campaign_type", "description": "Type of campaign.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "created": {"name": "created", "description": "Timestamp of when the campaign was created, in UTC.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "email_template_id": {"name": "email_template_id", "description": "Foreign key referencing the ID of the `email_template` object that will be the content of this campaign. Note the Email Template is copied when creating this campaign, so future changes to that Email Template will not alter the content of this campaign.\n", "meta": {}, "data_type": null, "quote": null, "tags": []}, "from_email": {"name": "from_email", "description": "The email address your email will be sent from and will be used in the reply-to header.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "from_name": {"name": "from_name", "description": "The name or label associated with the email address you're sending from.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "id": {"name": "id", "description": "Unique ID of the campaign.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "is_segmented": {"name": "is_segmented", "description": "Boolean that is true if the campaign is directed at a Klaviyo segment (not a list).", "meta": {}, "data_type": null, "quote": null, "tags": []}, "name": {"name": "name", "description": "A name for this campaign. If not specified, this will default to the subject of the campaign.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "send_time": {"name": "send_time", "description": "Timestamp of when the campaign is scheduled to be sent in the future, if [\"smart send time\"](https://help.klaviyo.com/hc/en-us/articles/360029794371-Smart-Send-Time-in-Klaviyo#how-to-utilize-smart-send-time3) is used. \n", "meta": {}, "data_type": null, "quote": null, "tags": []}, "sent_at": {"name": "sent_at", "description": "Timestamp of when the campaign was first sent out to users.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "status": {"name": "status", "description": "Current status of the campaign. Either \"draft\", \"scheduled\", \"sent\", or \"cancelled\".", "meta": {}, "data_type": null, "quote": null, "tags": []}, "status_id": {"name": "status_id", "description": "Corresponding ID to the current status.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "status_label": {"name": "status_label", "description": "The label of the status as it appears in the UI (should be the same as `status`).", "meta": {}, "data_type": null, "quote": null, "tags": []}, "subject": {"name": "subject", "description": "The subject line of the campaign's email.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "updated": {"name": "updated", "description": "Timestamp of when the campaign was last updated.", "meta": {}, "data_type": null, "quote": null, "tags": []}}, "meta": {}, "source_meta": {}, "tags": [], "config": {"enabled": true}, "patch_path": null, "unrendered_config": {}, "relation_name": "FIVETRAN_STAGING.klaviyo.campaign"}, "source.klaviyo_source.klaviyo.event": {"fqn": ["klaviyo_source", "klaviyo", "event"], "database": "FIVETRAN_STAGING", "schema": "klaviyo", "unique_id": "source.klaviyo_source.klaviyo.event", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "models/src_klaviyo.yml", "original_file_path": "models/src_klaviyo.yml", "name": "event", "source_name": "klaviyo", "source_description": "", "loader": "fivetran", "identifier": "event", "resource_type": "source", "quoting": {"database": null, "schema": null, "identifier": null, "column": null}, "loaded_at_field": "_fivetran_synced", "freshness": {"warn_after": {"count": 72, "period": "hour"}, "error_after": {"count": 96, "period": "hour"}, "filter": null}, "external": null, "description": "Table of events (and metrics) triggered in Klaviyo or via its integrations. Custom columns can be passed through to downstream models via the `klaviyo__event_pass_through_columns` variable (see README for details).\n", "columns": {"_variation": {"name": "_variation", "description": "Unique ID of the attributed flow or campaign variation group. This does not map onto another table. \n", "meta": {}, "data_type": null, "quote": null, "tags": []}, "campaign_id": {"name": "campaign_id", "description": "Foreign key referencing the CAMPAIGN that the event is attributed to.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "datetime": {"name": "datetime", "description": "Timestamp of when the event was recorded in Klaviyo. Should be the same/nominally off from `timestamp`.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "timestamp": {"name": "timestamp", "description": "Timestamp of when the event was triggered. Should be the same/nominally off from `datetime`.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "flow_id": {"name": "flow_id", "description": "Foreign key referencing the FLOW that the event is attributed to.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "flow_message_id": {"name": "flow_message_id", "description": "Unique ID of the FLOW_MESSAGE that the event is attributed to. This does not map onto another table.\n", "meta": {}, "data_type": null, "quote": null, "tags": []}, "id": {"name": "id", "description": "Unique ID of the event.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "metric_id": {"name": "metric_id", "description": "Foreign key referencing the metric being captured.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "person_id": {"name": "person_id", "description": "Foreign key referencing the PERSON who triggered the event.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "type": {"name": "type", "description": "Type of event that was triggered. This is the same as the METRIC name.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "uuid": {"name": "uuid", "description": "Universally Unique Identifier of the event.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "property_value": {"name": "property_value", "description": "Numeric value associated with the event (ie the dollars associated with a purchase).", "meta": {}, "data_type": null, "quote": null, "tags": []}, "_fivetran_deleted": {"name": "_fivetran_deleted", "description": "Boolean that is true if the campaign has been soft-deleted.", "meta": {}, "data_type": null, "quote": null, "tags": []}}, "meta": {}, "source_meta": {}, "tags": [], "config": {"enabled": true}, "patch_path": null, "unrendered_config": {}, "relation_name": "FIVETRAN_STAGING.klaviyo.event"}, "source.klaviyo_source.klaviyo.flow": {"fqn": ["klaviyo_source", "klaviyo", "flow"], "database": "FIVETRAN_STAGING", "schema": "klaviyo", "unique_id": "source.klaviyo_source.klaviyo.flow", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "models/src_klaviyo.yml", "original_file_path": "models/src_klaviyo.yml", "name": "flow", "source_name": "klaviyo", "source_description": "", "loader": "fivetran", "identifier": "flow", "resource_type": "source", "quoting": {"database": null, "schema": null, "identifier": null, "column": null}, "loaded_at_field": "_fivetran_synced", "freshness": {"warn_after": {"count": 72, "period": "hour"}, "error_after": {"count": 96, "period": "hour"}, "filter": null}, "external": null, "description": "Table of automated, triggered flow sequences in Klaviyo.", "columns": {"created": {"name": "created", "description": "Timestamp of when the flow was first created.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "id": {"name": "id", "description": "Unique ID of the flow.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "name": {"name": "name", "description": "Name of the flow.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "status": {"name": "status", "description": "Current status of the flow. Either 'manual', 'live', or 'draft'. Read more [here](https://help.klaviyo.com/hc/en-us/articles/115002774932-Getting-Started-with-Flows#the-flow-action-status9).", "meta": {}, "data_type": null, "quote": null, "tags": []}, "trigger": {"name": "trigger", "description": "JSON of metric, segment, list, and/or date-property filters that will trigger this flow. These are applied to the **event level**.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "updated": {"name": "updated", "description": "Timestamp of when the flow was last updated.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "customer_filter": {"name": "customer_filter", "description": "JSON of flow filters placed on the **person level** that will trigger this flow.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "_fivetran_deleted": {"name": "_fivetran_deleted", "description": "Boolean that is true if the campaign has been soft-deleted.", "meta": {}, "data_type": null, "quote": null, "tags": []}}, "meta": {}, "source_meta": {}, "tags": [], "config": {"enabled": true}, "patch_path": null, "unrendered_config": {}, "relation_name": "FIVETRAN_STAGING.klaviyo.flow"}, "source.klaviyo_source.klaviyo.integration": {"fqn": ["klaviyo_source", "klaviyo", "integration"], "database": "FIVETRAN_STAGING", "schema": "klaviyo", "unique_id": "source.klaviyo_source.klaviyo.integration", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "models/src_klaviyo.yml", "original_file_path": "models/src_klaviyo.yml", "name": "integration", "source_name": "klaviyo", "source_description": "", "loader": "fivetran", "identifier": "integration", "resource_type": "source", "quoting": {"database": null, "schema": null, "identifier": null, "column": null}, "loaded_at_field": "_fivetran_synced", "freshness": {"warn_after": {"count": 72, "period": "hour"}, "error_after": {"count": 96, "period": "hour"}, "filter": null}, "external": null, "description": "Table storing third-party platforms integrated into Klaviyo.", "columns": {"category": {"name": "category", "description": "Use-case category of the integrated platform.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "id": {"name": "id", "description": "Unique ID of the integration.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "name": {"name": "name", "description": "Name of the integrated platform.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "_fivetran_deleted": {"name": "_fivetran_deleted", "description": "Boolean that is true if the campaign has been soft-deleted.", "meta": {}, "data_type": null, "quote": null, "tags": []}}, "meta": {}, "source_meta": {}, "tags": [], "config": {"enabled": true}, "patch_path": null, "unrendered_config": {}, "relation_name": "FIVETRAN_STAGING.klaviyo.integration"}, "source.klaviyo_source.klaviyo.person": {"fqn": ["klaviyo_source", "klaviyo", "person"], "database": "FIVETRAN_STAGING", "schema": "klaviyo", "unique_id": "source.klaviyo_source.klaviyo.person", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "models/src_klaviyo.yml", "original_file_path": "models/src_klaviyo.yml", "name": "person", "source_name": "klaviyo", "source_description": "", "loader": "fivetran", "identifier": "person", "resource_type": "source", "quoting": {"database": null, "schema": null, "identifier": null, "column": null}, "loaded_at_field": "_fivetran_synced", "freshness": {"warn_after": {"count": 72, "period": "hour"}, "error_after": {"count": 96, "period": "hour"}, "filter": null}, "external": null, "description": "Table storing the profiles of all people/users interacted with. Custom columns can be passed through to downstream models via the `klaviyo__person_pass_through_columns` variable (see README for details).\n", "columns": {"id": {"name": "id", "description": "Unique ID of the user if you use your own unique identifier. Otherwise, Klaviyo recommends using the email as the primary key. \n", "meta": {}, "data_type": null, "quote": null, "tags": []}, "address_1": {"name": "address_1", "description": "First line of the person's address.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "address_2": {"name": "address_2", "description": "Second line of the person's address.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "city": {"name": "city", "description": "City they live in.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "country": {"name": "country", "description": "Country they live in.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "zip": {"name": "zip", "description": "Postal code where they live.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "created": {"name": "created", "description": "Timestamp of when the person's profile was created.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "email": {"name": "email", "description": "The email address and the unique identifier for a profile.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "first_name": {"name": "first_name", "description": "Person's first name.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "last_name": {"name": "last_name", "description": "Person's surname.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "latitude": {"name": "latitude", "description": "Latitude of the person's location.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "longitude": {"name": "longitude", "description": "Longitude of the person's location.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "organization": {"name": "organization", "description": "Business organization they belong to.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "phone_number": {"name": "phone_number", "description": "Associated phone number.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "region": {"name": "region", "description": "Region or state they live in.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "timezone": {"name": "timezone", "description": "Timezone they are situated in.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "title": {"name": "title", "description": "Title at their business or organization.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "updated": {"name": "updated", "description": "Timestamp of when the person profile was last updated.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "_fivetran_deleted": {"name": "_fivetran_deleted", "description": "Boolean that is true if the campaign has been soft-deleted.", "meta": {}, "data_type": null, "quote": null, "tags": []}}, "meta": {}, "source_meta": {}, "tags": [], "config": {"enabled": true}, "patch_path": null, "unrendered_config": {}, "relation_name": "FIVETRAN_STAGING.klaviyo.person"}, "source.klaviyo_source.klaviyo.metric": {"fqn": ["klaviyo_source", "klaviyo", "metric"], "database": "FIVETRAN_STAGING", "schema": "klaviyo", "unique_id": "source.klaviyo_source.klaviyo.metric", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "models/src_klaviyo.yml", "original_file_path": "models/src_klaviyo.yml", "name": "metric", "source_name": "klaviyo", "source_description": "", "loader": "fivetran", "identifier": "metric", "resource_type": "source", "quoting": {"database": null, "schema": null, "identifier": null, "column": null}, "loaded_at_field": "_fivetran_synced", "freshness": {"warn_after": {"count": 72, "period": "hour"}, "error_after": {"count": 96, "period": "hour"}, "filter": null}, "external": null, "description": "Table of tracked metrics across integrations in Klaviyo.", "columns": {"created": {"name": "created", "description": "Timestamp of when the metric was created.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "id": {"name": "id", "description": "Unique ID of the metric being tracked.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "integration_id": {"name": "integration_id", "description": "Foreign key referencing the INTEGRATION that the metric is being pulled from.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "name": {"name": "name", "description": "Name of the metric (same as `EVENT.type`)", "meta": {}, "data_type": null, "quote": null, "tags": []}, "updated": {"name": "updated", "description": "Timestamp of when the metric was last updated.", "meta": {}, "data_type": null, "quote": null, "tags": []}, "_fivetran_deleted": {"name": "_fivetran_deleted", "description": "Boolean that is true if the campaign has been soft-deleted.", "meta": {}, "data_type": null, "quote": null, "tags": []}}, "meta": {}, "source_meta": {}, "tags": [], "config": {"enabled": true}, "patch_path": null, "unrendered_config": {}, "relation_name": "FIVETRAN_STAGING.klaviyo.metric"}}, "macros": {"macro.dbt_snowflake.snowflake__get_catalog": {"unique_id": "macro.dbt_snowflake.snowflake__get_catalog", "package_name": "dbt_snowflake", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/catalog.sql", "original_file_path": "macros/catalog.sql", "name": "snowflake__get_catalog", "macro_sql": "{% macro snowflake__get_catalog(information_schema, schemas) -%}\n {% set query %}\n with tables as (\n\n select\n table_catalog as \"table_database\",\n table_schema as \"table_schema\",\n table_name as \"table_name\",\n table_type as \"table_type\",\n comment as \"table_comment\",\n\n -- note: this is the _role_ that owns the table\n table_owner as \"table_owner\",\n\n 'Clustering Key' as \"stats:clustering_key:label\",\n clustering_key as \"stats:clustering_key:value\",\n 'The key used to cluster this table' as \"stats:clustering_key:description\",\n (clustering_key is not null) as \"stats:clustering_key:include\",\n\n 'Row Count' as \"stats:row_count:label\",\n row_count as \"stats:row_count:value\",\n 'An approximate count of rows in this table' as \"stats:row_count:description\",\n (row_count is not null) as \"stats:row_count:include\",\n\n 'Approximate Size' as \"stats:bytes:label\",\n bytes as \"stats:bytes:value\",\n 'Approximate size of the table as reported by Snowflake' as \"stats:bytes:description\",\n (bytes is not null) as \"stats:bytes:include\",\n\n 'Last Modified' as \"stats:last_modified:label\",\n to_varchar(convert_timezone('UTC', last_altered), 'yyyy-mm-dd HH24:MI'||'UTC') as \"stats:last_modified:value\",\n 'The timestamp for last update/change' as \"stats:last_modified:description\",\n (last_altered is not null and table_type='BASE TABLE') as \"stats:last_modified:include\"\n\n from {{ information_schema }}.tables\n\n ),\n\n columns as (\n\n select\n table_catalog as \"table_database\",\n table_schema as \"table_schema\",\n table_name as \"table_name\",\n\n column_name as \"column_name\",\n ordinal_position as \"column_index\",\n data_type as \"column_type\",\n comment as \"column_comment\"\n\n from {{ information_schema }}.columns\n )\n\n select *\n from tables\n join columns using (\"table_database\", \"table_schema\", \"table_name\")\n where (\n {%- for schema in schemas -%}\n upper(\"table_schema\") = upper('{{ schema }}'){%- if not loop.last %} or {% endif -%}\n {%- endfor -%}\n )\n order by \"column_index\"\n {%- endset -%}\n\n {{ return(run_query(query)) }}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_snowflake.snowflake__create_table_as": {"unique_id": "macro.dbt_snowflake.snowflake__create_table_as", "package_name": "dbt_snowflake", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__create_table_as", "macro_sql": "{% macro snowflake__create_table_as(temporary, relation, sql) -%}\n {%- set transient = config.get('transient', default=true) -%}\n {%- set cluster_by_keys = config.get('cluster_by', default=none) -%}\n {%- set enable_automatic_clustering = config.get('automatic_clustering', default=false) -%}\n {%- set copy_grants = config.get('copy_grants', default=false) -%}\n\n {%- if cluster_by_keys is not none and cluster_by_keys is string -%}\n {%- set cluster_by_keys = [cluster_by_keys] -%}\n {%- endif -%}\n {%- if cluster_by_keys is not none -%}\n {%- set cluster_by_string = cluster_by_keys|join(\", \")-%}\n {% else %}\n {%- set cluster_by_string = none -%}\n {%- endif -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n\n create or replace {% if temporary -%}\n temporary\n {%- elif transient -%}\n transient\n {%- endif %} table {{ relation }} {% if copy_grants and not temporary -%} copy grants {%- endif %} as\n (\n {%- if cluster_by_string is not none -%}\n select * from(\n {{ sql }}\n ) order by ({{ cluster_by_string }})\n {%- else -%}\n {{ sql }}\n {%- endif %}\n );\n {% if cluster_by_string is not none and not temporary -%}\n alter table {{relation}} cluster by ({{cluster_by_string}});\n {%- endif -%}\n {% if enable_automatic_clustering and cluster_by_string is not none and not temporary -%}\n alter table {{relation}} resume recluster;\n {%- endif -%}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_snowflake.snowflake__create_view_as": {"unique_id": "macro.dbt_snowflake.snowflake__create_view_as", "package_name": "dbt_snowflake", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__create_view_as", "macro_sql": "{% macro snowflake__create_view_as(relation, sql) -%}\n {%- set secure = config.get('secure', default=false) -%}\n {%- set copy_grants = config.get('copy_grants', default=false) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n create or replace {% if secure -%}\n secure\n {%- endif %} view {{ relation }} {% if copy_grants -%} copy grants {%- endif %} as (\n {{ sql }}\n );\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_snowflake.snowflake__get_columns_in_relation": {"unique_id": "macro.dbt_snowflake.snowflake__get_columns_in_relation", "package_name": "dbt_snowflake", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__get_columns_in_relation", "macro_sql": "{% macro snowflake__get_columns_in_relation(relation) -%}\n {%- set sql -%}\n describe table {{ relation }}\n {%- endset -%}\n {%- set result = run_query(sql) -%}\n\n {% set maximum = 10000 %}\n {% if (result | length) >= maximum %}\n {% set msg %}\n Too many columns in relation {{ relation }}! dbt can only get\n information about relations with fewer than {{ maximum }} columns.\n {% endset %}\n {% do exceptions.raise_compiler_error(msg) %}\n {% endif %}\n\n {% set columns = [] %}\n {% for row in result %}\n {% do columns.append(api.Column.from_description(row['name'], row['type'])) %}\n {% endfor %}\n {% do return(columns) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_snowflake.snowflake__list_schemas": {"unique_id": "macro.dbt_snowflake.snowflake__list_schemas", "package_name": "dbt_snowflake", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__list_schemas", "macro_sql": "{% macro snowflake__list_schemas(database) -%}\n {# 10k limit from here: https://docs.snowflake.net/manuals/sql-reference/sql/show-schemas.html#usage-notes #}\n {% set maximum = 10000 %}\n {% set sql -%}\n show terse schemas in database {{ database }}\n limit {{ maximum }}\n {%- endset %}\n {% set result = run_query(sql) %}\n {% if (result | length) >= maximum %}\n {% set msg %}\n Too many schemas in database {{ database }}! dbt can only get\n information about databases with fewer than {{ maximum }} schemas.\n {% endset %}\n {% do exceptions.raise_compiler_error(msg) %}\n {% endif %}\n {{ return(result) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_snowflake.snowflake__list_relations_without_caching": {"unique_id": "macro.dbt_snowflake.snowflake__list_relations_without_caching", "package_name": "dbt_snowflake", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__list_relations_without_caching", "macro_sql": "{% macro snowflake__list_relations_without_caching(schema_relation) %}\n {%- set sql -%}\n show terse objects in {{ schema_relation }}\n {%- endset -%}\n\n {%- set result = run_query(sql) -%}\n {% set maximum = 10000 %}\n {% if (result | length) >= maximum %}\n {% set msg %}\n Too many schemas in schema {{ schema_relation }}! dbt can only get\n information about schemas with fewer than {{ maximum }} objects.\n {% endset %}\n {% do exceptions.raise_compiler_error(msg) %}\n {% endif %}\n {%- do return(result) -%}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_snowflake.snowflake__check_schema_exists": {"unique_id": "macro.dbt_snowflake.snowflake__check_schema_exists", "package_name": "dbt_snowflake", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__check_schema_exists", "macro_sql": "{% macro snowflake__check_schema_exists(information_schema, schema) -%}\n {% call statement('check_schema_exists', fetch_result=True) -%}\n select count(*)\n from {{ information_schema }}.schemata\n where upper(schema_name) = upper('{{ schema }}')\n and upper(catalog_name) = upper('{{ information_schema.database }}')\n {%- endcall %}\n {{ return(load_result('check_schema_exists').table) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_snowflake.snowflake__current_timestamp": {"unique_id": "macro.dbt_snowflake.snowflake__current_timestamp", "package_name": "dbt_snowflake", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__current_timestamp", "macro_sql": "{% macro snowflake__current_timestamp() -%}\n convert_timezone('UTC', current_timestamp())\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_snowflake.snowflake__snapshot_string_as_time": {"unique_id": "macro.dbt_snowflake.snowflake__snapshot_string_as_time", "package_name": "dbt_snowflake", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__snapshot_string_as_time", "macro_sql": "{% macro snowflake__snapshot_string_as_time(timestamp) -%}\n {%- set result = \"to_timestamp_ntz('\" ~ timestamp ~ \"')\" -%}\n {{ return(result) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_snowflake.snowflake__snapshot_get_time": {"unique_id": "macro.dbt_snowflake.snowflake__snapshot_get_time", "package_name": "dbt_snowflake", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__snapshot_get_time", "macro_sql": "{% macro snowflake__snapshot_get_time() -%}\n to_timestamp_ntz({{ current_timestamp() }})\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_snowflake.snowflake__rename_relation": {"unique_id": "macro.dbt_snowflake.snowflake__rename_relation", "package_name": "dbt_snowflake", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__rename_relation", "macro_sql": "{% macro snowflake__rename_relation(from_relation, to_relation) -%}\n {% call statement('rename_relation') -%}\n alter table {{ from_relation }} rename to {{ to_relation }}\n {%- endcall %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_snowflake.snowflake__alter_column_type": {"unique_id": "macro.dbt_snowflake.snowflake__alter_column_type", "package_name": "dbt_snowflake", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__alter_column_type", "macro_sql": "{% macro snowflake__alter_column_type(relation, column_name, new_column_type) -%}\n {% call statement('alter_column_type') %}\n alter table {{ relation }} alter {{ adapter.quote(column_name) }} set data type {{ new_column_type }};\n {% endcall %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_snowflake.snowflake__alter_relation_comment": {"unique_id": "macro.dbt_snowflake.snowflake__alter_relation_comment", "package_name": "dbt_snowflake", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__alter_relation_comment", "macro_sql": "{% macro snowflake__alter_relation_comment(relation, relation_comment) -%}\n comment on {{ relation.type }} {{ relation }} IS $${{ relation_comment | replace('$', '[$]') }}$$;\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_snowflake.snowflake__alter_column_comment": {"unique_id": "macro.dbt_snowflake.snowflake__alter_column_comment", "package_name": "dbt_snowflake", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "snowflake__alter_column_comment", "macro_sql": "{% macro snowflake__alter_column_comment(relation, column_dict) -%}\n alter {{ relation.type }} {{ relation }} alter\n {% for column_name in column_dict %}\n {{ adapter.quote(column_name) if column_dict[column_name]['quote'] else column_name }} COMMENT $${{ column_dict[column_name]['description'] | replace('$', '[$]') }}$$ {{ ',' if not loop.last else ';' }}\n {% endfor %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_snowflake.get_current_query_tag": {"unique_id": "macro.dbt_snowflake.get_current_query_tag", "package_name": "dbt_snowflake", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "get_current_query_tag", "macro_sql": "{% macro get_current_query_tag() -%}\n {{ return(run_query(\"show parameters like 'query_tag' in session\").rows[0]['value']) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_snowflake.set_query_tag": {"unique_id": "macro.dbt_snowflake.set_query_tag", "package_name": "dbt_snowflake", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "set_query_tag", "macro_sql": "{% macro set_query_tag() -%}\n {% set new_query_tag = config.get('query_tag') %}\n {% if new_query_tag %}\n {% set original_query_tag = get_current_query_tag() %}\n {{ log(\"Setting query_tag to '\" ~ new_query_tag ~ \"'. Will reset to '\" ~ original_query_tag ~ \"' after materialization.\") }}\n {% do run_query(\"alter session set query_tag = '{}'\".format(new_query_tag)) %}\n {{ return(original_query_tag)}}\n {% endif %}\n {{ return(none)}}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_snowflake.unset_query_tag": {"unique_id": "macro.dbt_snowflake.unset_query_tag", "package_name": "dbt_snowflake", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/adapters.sql", "original_file_path": "macros/adapters.sql", "name": "unset_query_tag", "macro_sql": "{% macro unset_query_tag(original_query_tag) -%}\n {% set new_query_tag = config.get('query_tag') %}\n {% if new_query_tag %}\n {% if original_query_tag %}\n {{ log(\"Resetting query_tag to '\" ~ original_query_tag ~ \"'.\") }}\n {% do run_query(\"alter session set query_tag = '{}'\".format(original_query_tag)) %}\n {% else %}\n {{ log(\"No original query_tag, unsetting parameter.\") }}\n {% do run_query(\"alter session unset query_tag\") %}\n {% endif %}\n {% endif %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_snowflake.snowflake__get_merge_sql": {"unique_id": "macro.dbt_snowflake.snowflake__get_merge_sql", "package_name": "dbt_snowflake", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/materializations/merge.sql", "original_file_path": "macros/materializations/merge.sql", "name": "snowflake__get_merge_sql", "macro_sql": "{% macro snowflake__get_merge_sql(target, source_sql, unique_key, dest_columns, predicates) -%}\n\n {#\n Workaround for Snowflake not being happy with a merge on a constant-false predicate.\n When no unique_key is provided, this macro will do a regular insert. If a unique_key\n is provided, then this macro will do a proper merge instead.\n #}\n\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute='name')) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {%- if unique_key is none -%}\n\n {{ sql_header if sql_header is not none }}\n\n insert into {{ target }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ source_sql }}\n );\n\n {%- else -%}\n\n {{ default__get_merge_sql(target, source_sql, unique_key, dest_columns, predicates) }}\n\n {%- endif -%}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_snowflake.materialization_view_snowflake": {"unique_id": "macro.dbt_snowflake.materialization_view_snowflake", "package_name": "dbt_snowflake", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/materializations/view.sql", "original_file_path": "macros/materializations/view.sql", "name": "materialization_view_snowflake", "macro_sql": "{% materialization view, adapter='snowflake' -%}\n\n {% set original_query_tag = set_query_tag() %}\n {% set to_return = create_or_replace_view() %}\n\n {% set target_relation = this.incorporate(type='view') %}\n {% do persist_docs(target_relation, model, for_columns=false) %}\n\n {% do return(to_return) %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n{%- endmaterialization %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_snowflake.materialization_table_snowflake": {"unique_id": "macro.dbt_snowflake.materialization_table_snowflake", "package_name": "dbt_snowflake", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/materializations/table.sql", "original_file_path": "macros/materializations/table.sql", "name": "materialization_table_snowflake", "macro_sql": "{% materialization table, adapter='snowflake' %}\n\n {% set original_query_tag = set_query_tag() %}\n\n {%- set identifier = model['alias'] -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n {%- set target_relation = api.Relation.create(identifier=identifier,\n schema=schema,\n database=database, type='table') -%}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {#-- Drop the relation if it was a view to \"convert\" it in a table. This may lead to\n -- downtime, but it should be a relatively infrequent occurrence #}\n {% if old_relation is not none and not old_relation.is_table %}\n {{ log(\"Dropping relation \" ~ old_relation ~ \" because it is of type \" ~ old_relation.type) }}\n {{ drop_relation_if_exists(old_relation) }}\n {% endif %}\n\n --build model\n {% call statement('main') -%}\n {{ create_table_as(false, target_relation, sql) }}\n {%- endcall %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n -- `COMMIT` happens here\n {{ adapter.commit() }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {% do persist_docs(target_relation, model) %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_snowflake.dbt_snowflake_validate_get_incremental_strategy": {"unique_id": "macro.dbt_snowflake.dbt_snowflake_validate_get_incremental_strategy", "package_name": "dbt_snowflake", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/materializations/incremental.sql", "original_file_path": "macros/materializations/incremental.sql", "name": "dbt_snowflake_validate_get_incremental_strategy", "macro_sql": "{% macro dbt_snowflake_validate_get_incremental_strategy(config) %}\n {#-- Find and validate the incremental strategy #}\n {%- set strategy = config.get(\"incremental_strategy\", default=\"merge\") -%}\n\n {% set invalid_strategy_msg -%}\n Invalid incremental strategy provided: {{ strategy }}\n Expected one of: 'merge', 'delete+insert'\n {%- endset %}\n {% if strategy not in ['merge', 'delete+insert'] %}\n {% do exceptions.raise_compiler_error(invalid_strategy_msg) %}\n {% endif %}\n\n {% do return(strategy) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_snowflake.dbt_snowflake_get_incremental_sql": {"unique_id": "macro.dbt_snowflake.dbt_snowflake_get_incremental_sql", "package_name": "dbt_snowflake", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/materializations/incremental.sql", "original_file_path": "macros/materializations/incremental.sql", "name": "dbt_snowflake_get_incremental_sql", "macro_sql": "{% macro dbt_snowflake_get_incremental_sql(strategy, tmp_relation, target_relation, unique_key, dest_columns) %}\n {% if strategy == 'merge' %}\n {% do return(get_merge_sql(target_relation, tmp_relation, unique_key, dest_columns)) %}\n {% elif strategy == 'delete+insert' %}\n {% do return(get_delete_insert_merge_sql(target_relation, tmp_relation, unique_key, dest_columns)) %}\n {% else %}\n {% do exceptions.raise_compiler_error('invalid strategy: ' ~ strategy) %}\n {% endif %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_snowflake.materialization_incremental_snowflake": {"unique_id": "macro.dbt_snowflake.materialization_incremental_snowflake", "package_name": "dbt_snowflake", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/snowflake", "path": "macros/materializations/incremental.sql", "original_file_path": "macros/materializations/incremental.sql", "name": "materialization_incremental_snowflake", "macro_sql": "{% materialization incremental, adapter='snowflake' -%}\n\n {% set original_query_tag = set_query_tag() %}\n\n {%- set unique_key = config.get('unique_key') -%}\n {%- set full_refresh_mode = (should_full_refresh()) -%}\n\n {% set target_relation = this %}\n {% set existing_relation = load_relation(this) %}\n {% set tmp_relation = make_temp_relation(this) %}\n\n {#-- Validate early so we don't run SQL if the strategy is invalid --#}\n {% set strategy = dbt_snowflake_validate_get_incremental_strategy(config) -%}\n\n -- setup\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% if existing_relation is none %}\n {% set build_sql = create_table_as(False, target_relation, sql) %}\n {% elif existing_relation.is_view %}\n {#-- Can't overwrite a view with a table - we must drop --#}\n {{ log(\"Dropping relation \" ~ target_relation ~ \" because it is a view and this model is a table.\") }}\n {% do adapter.drop_relation(existing_relation) %}\n {% set build_sql = create_table_as(False, target_relation, sql) %}\n {% elif full_refresh_mode %}\n {% set build_sql = create_table_as(False, target_relation, sql) %}\n {% else %}\n {% do run_query(create_table_as(True, tmp_relation, sql)) %}\n {% do adapter.expand_target_column_types(\n from_relation=tmp_relation,\n to_relation=target_relation) %}\n {% set dest_columns = adapter.get_columns_in_relation(target_relation) %}\n {% set build_sql = dbt_snowflake_get_incremental_sql(strategy, tmp_relation, target_relation, unique_key, dest_columns) %}\n {% endif %}\n\n {%- call statement('main') -%}\n {{ build_sql }}\n {%- endcall -%}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n -- `COMMIT` happens here\n {{ adapter.commit() }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {% set target_relation = target_relation.incorporate(type='table') %}\n {% do persist_docs(target_relation, model) %}\n\n {% do unset_query_tag(original_query_tag) %}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.statement": {"unique_id": "macro.dbt.statement", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/core.sql", "original_file_path": "macros/core.sql", "name": "statement", "macro_sql": "{% macro statement(name=None, fetch_result=False, auto_begin=True) -%}\n {%- if execute: -%}\n {%- set sql = caller() -%}\n\n {%- if name == 'main' -%}\n {{ log('Writing runtime SQL for node \"{}\"'.format(model['unique_id'])) }}\n {{ write(sql) }}\n {%- endif -%}\n\n {%- set res, table = adapter.execute(sql, auto_begin=auto_begin, fetch=fetch_result) -%}\n {%- if name is not none -%}\n {{ store_result(name, response=res, agate_table=table) }}\n {%- endif -%}\n\n {%- endif -%}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.noop_statement": {"unique_id": "macro.dbt.noop_statement", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/core.sql", "original_file_path": "macros/core.sql", "name": "noop_statement", "macro_sql": "{% macro noop_statement(name=None, message=None, code=None, rows_affected=None, res=None) -%}\n {%- set sql = caller() -%}\n\n {%- if name == 'main' -%}\n {{ log('Writing runtime SQL for node \"{}\"'.format(model['unique_id'])) }}\n {{ write(sql) }}\n {%- endif -%}\n\n {%- if name is not none -%}\n {{ store_raw_result(name, message=message, code=code, rows_affected=rows_affected, agate_table=res) }}\n {%- endif -%}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.run_hooks": {"unique_id": "macro.dbt.run_hooks", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/helpers.sql", "original_file_path": "macros/materializations/helpers.sql", "name": "run_hooks", "macro_sql": "{% macro run_hooks(hooks, inside_transaction=True) %}\n {% for hook in hooks | selectattr('transaction', 'equalto', inside_transaction) %}\n {% if not inside_transaction and loop.first %}\n {% call statement(auto_begin=inside_transaction) %}\n commit;\n {% endcall %}\n {% endif %}\n {% set rendered = render(hook.get('sql')) | trim %}\n {% if (rendered | length) > 0 %}\n {% call statement(auto_begin=inside_transaction) %}\n {{ rendered }}\n {% endcall %}\n {% endif %}\n {% endfor %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.column_list": {"unique_id": "macro.dbt.column_list", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/helpers.sql", "original_file_path": "macros/materializations/helpers.sql", "name": "column_list", "macro_sql": "{% macro column_list(columns) %}\n {%- for col in columns %}\n {{ col.name }} {% if not loop.last %},{% endif %}\n {% endfor -%}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.column_list_for_create_table": {"unique_id": "macro.dbt.column_list_for_create_table", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/helpers.sql", "original_file_path": "macros/materializations/helpers.sql", "name": "column_list_for_create_table", "macro_sql": "{% macro column_list_for_create_table(columns) %}\n {%- for col in columns %}\n {{ col.name }} {{ col.data_type }} {%- if not loop.last %},{% endif %}\n {% endfor -%}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.make_hook_config": {"unique_id": "macro.dbt.make_hook_config", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/helpers.sql", "original_file_path": "macros/materializations/helpers.sql", "name": "make_hook_config", "macro_sql": "{% macro make_hook_config(sql, inside_transaction) %}\n {{ tojson({\"sql\": sql, \"transaction\": inside_transaction}) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.before_begin": {"unique_id": "macro.dbt.before_begin", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/helpers.sql", "original_file_path": "macros/materializations/helpers.sql", "name": "before_begin", "macro_sql": "{% macro before_begin(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.in_transaction": {"unique_id": "macro.dbt.in_transaction", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/helpers.sql", "original_file_path": "macros/materializations/helpers.sql", "name": "in_transaction", "macro_sql": "{% macro in_transaction(sql) %}\n {{ make_hook_config(sql, inside_transaction=True) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.after_commit": {"unique_id": "macro.dbt.after_commit", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/helpers.sql", "original_file_path": "macros/materializations/helpers.sql", "name": "after_commit", "macro_sql": "{% macro after_commit(sql) %}\n {{ make_hook_config(sql, inside_transaction=False) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.drop_relation_if_exists": {"unique_id": "macro.dbt.drop_relation_if_exists", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/helpers.sql", "original_file_path": "macros/materializations/helpers.sql", "name": "drop_relation_if_exists", "macro_sql": "{% macro drop_relation_if_exists(relation) %}\n {% if relation is not none %}\n {{ adapter.drop_relation(relation) }}\n {% endif %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.load_relation": {"unique_id": "macro.dbt.load_relation", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/helpers.sql", "original_file_path": "macros/materializations/helpers.sql", "name": "load_relation", "macro_sql": "{% macro load_relation(relation) %}\n {% do return(adapter.get_relation(\n database=relation.database,\n schema=relation.schema,\n identifier=relation.identifier\n )) -%}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.should_full_refresh": {"unique_id": "macro.dbt.should_full_refresh", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/helpers.sql", "original_file_path": "macros/materializations/helpers.sql", "name": "should_full_refresh", "macro_sql": "{% macro should_full_refresh() %}\n {% set config_full_refresh = config.get('full_refresh') %}\n {% if config_full_refresh is none %}\n {% set config_full_refresh = flags.FULL_REFRESH %}\n {% endif %}\n {% do return(config_full_refresh) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.snapshot_merge_sql": {"unique_id": "macro.dbt.snapshot_merge_sql", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshot/snapshot_merge.sql", "original_file_path": "macros/materializations/snapshot/snapshot_merge.sql", "name": "snapshot_merge_sql", "macro_sql": "{% macro snapshot_merge_sql(target, source, insert_cols) -%}\n {{ adapter.dispatch('snapshot_merge_sql')(target, source, insert_cols) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__snapshot_merge_sql": {"unique_id": "macro.dbt.default__snapshot_merge_sql", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshot/snapshot_merge.sql", "original_file_path": "macros/materializations/snapshot/snapshot_merge.sql", "name": "default__snapshot_merge_sql", "macro_sql": "{% macro default__snapshot_merge_sql(target, source, insert_cols) -%}\n {%- set insert_cols_csv = insert_cols | join(', ') -%}\n\n merge into {{ target }} as DBT_INTERNAL_DEST\n using {{ source }} as DBT_INTERNAL_SOURCE\n on DBT_INTERNAL_SOURCE.dbt_scd_id = DBT_INTERNAL_DEST.dbt_scd_id\n\n when matched\n and DBT_INTERNAL_DEST.dbt_valid_to is null\n and DBT_INTERNAL_SOURCE.dbt_change_type in ('update', 'delete')\n then update\n set dbt_valid_to = DBT_INTERNAL_SOURCE.dbt_valid_to\n\n when not matched\n and DBT_INTERNAL_SOURCE.dbt_change_type = 'insert'\n then insert ({{ insert_cols_csv }})\n values ({{ insert_cols_csv }})\n ;\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.strategy_dispatch": {"unique_id": "macro.dbt.strategy_dispatch", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshot/strategies.sql", "original_file_path": "macros/materializations/snapshot/strategies.sql", "name": "strategy_dispatch", "macro_sql": "{% macro strategy_dispatch(name) -%}\n{% set original_name = name %}\n {% if '.' in name %}\n {% set package_name, name = name.split(\".\", 1) %}\n {% else %}\n {% set package_name = none %}\n {% endif %}\n\n {% if package_name is none %}\n {% set package_context = context %}\n {% elif package_name in context %}\n {% set package_context = context[package_name] %}\n {% else %}\n {% set error_msg %}\n Could not find package '{{package_name}}', called with '{{original_name}}'\n {% endset %}\n {{ exceptions.raise_compiler_error(error_msg | trim) }}\n {% endif %}\n\n {%- set search_name = 'snapshot_' ~ name ~ '_strategy' -%}\n\n {% if search_name not in package_context %}\n {% set error_msg %}\n The specified strategy macro '{{name}}' was not found in package '{{ package_name }}'\n {% endset %}\n {{ exceptions.raise_compiler_error(error_msg | trim) }}\n {% endif %}\n {{ return(package_context[search_name]) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.snapshot_hash_arguments": {"unique_id": "macro.dbt.snapshot_hash_arguments", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshot/strategies.sql", "original_file_path": "macros/materializations/snapshot/strategies.sql", "name": "snapshot_hash_arguments", "macro_sql": "{% macro snapshot_hash_arguments(args) -%}\n {{ adapter.dispatch('snapshot_hash_arguments')(args) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__snapshot_hash_arguments": {"unique_id": "macro.dbt.default__snapshot_hash_arguments", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshot/strategies.sql", "original_file_path": "macros/materializations/snapshot/strategies.sql", "name": "default__snapshot_hash_arguments", "macro_sql": "{% macro default__snapshot_hash_arguments(args) -%}\n md5({%- for arg in args -%}\n coalesce(cast({{ arg }} as varchar ), '')\n {% if not loop.last %} || '|' || {% endif %}\n {%- endfor -%})\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.snapshot_get_time": {"unique_id": "macro.dbt.snapshot_get_time", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshot/strategies.sql", "original_file_path": "macros/materializations/snapshot/strategies.sql", "name": "snapshot_get_time", "macro_sql": "{% macro snapshot_get_time() -%}\n {{ adapter.dispatch('snapshot_get_time')() }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__snapshot_get_time": {"unique_id": "macro.dbt.default__snapshot_get_time", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshot/strategies.sql", "original_file_path": "macros/materializations/snapshot/strategies.sql", "name": "default__snapshot_get_time", "macro_sql": "{% macro default__snapshot_get_time() -%}\n {{ current_timestamp() }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.snapshot_timestamp_strategy": {"unique_id": "macro.dbt.snapshot_timestamp_strategy", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshot/strategies.sql", "original_file_path": "macros/materializations/snapshot/strategies.sql", "name": "snapshot_timestamp_strategy", "macro_sql": "{% macro snapshot_timestamp_strategy(node, snapshotted_rel, current_rel, config, target_exists) %}\n {% set primary_key = config['unique_key'] %}\n {% set updated_at = config['updated_at'] %}\n {% set invalidate_hard_deletes = config.get('invalidate_hard_deletes', false) %}\n\n {#/*\n The snapshot relation might not have an {{ updated_at }} value if the\n snapshot strategy is changed from `check` to `timestamp`. We\n should use a dbt-created column for the comparison in the snapshot\n table instead of assuming that the user-supplied {{ updated_at }}\n will be present in the historical data.\n\n See https://github.com/fishtown-analytics/dbt/issues/2350\n */ #}\n {% set row_changed_expr -%}\n ({{ snapshotted_rel }}.dbt_valid_from < {{ current_rel }}.{{ updated_at }})\n {%- endset %}\n\n {% set scd_id_expr = snapshot_hash_arguments([primary_key, updated_at]) %}\n\n {% do return({\n \"unique_key\": primary_key,\n \"updated_at\": updated_at,\n \"row_changed\": row_changed_expr,\n \"scd_id\": scd_id_expr,\n \"invalidate_hard_deletes\": invalidate_hard_deletes\n }) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.snapshot_string_as_time": {"unique_id": "macro.dbt.snapshot_string_as_time", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshot/strategies.sql", "original_file_path": "macros/materializations/snapshot/strategies.sql", "name": "snapshot_string_as_time", "macro_sql": "{% macro snapshot_string_as_time(timestamp) -%}\n {{ adapter.dispatch('snapshot_string_as_time')(timestamp) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__snapshot_string_as_time": {"unique_id": "macro.dbt.default__snapshot_string_as_time", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshot/strategies.sql", "original_file_path": "macros/materializations/snapshot/strategies.sql", "name": "default__snapshot_string_as_time", "macro_sql": "{% macro default__snapshot_string_as_time(timestamp) %}\n {% do exceptions.raise_not_implemented(\n 'snapshot_string_as_time macro not implemented for adapter '+adapter.type()\n ) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.snapshot_check_all_get_existing_columns": {"unique_id": "macro.dbt.snapshot_check_all_get_existing_columns", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshot/strategies.sql", "original_file_path": "macros/materializations/snapshot/strategies.sql", "name": "snapshot_check_all_get_existing_columns", "macro_sql": "{% macro snapshot_check_all_get_existing_columns(node, target_exists) -%}\n {%- set query_columns = get_columns_in_query(node['compiled_sql']) -%}\n {%- if not target_exists -%}\n {# no table yet -> return whatever the query does #}\n {{ return([false, query_columns]) }}\n {%- endif -%}\n {# handle any schema changes #}\n {%- set target_table = node.get('alias', node.get('name')) -%}\n {%- set target_relation = adapter.get_relation(database=node.database, schema=node.schema, identifier=target_table) -%}\n {%- set existing_cols = get_columns_in_query('select * from ' ~ target_relation) -%}\n {%- set ns = namespace() -%} {# handle for-loop scoping with a namespace #}\n {%- set ns.column_added = false -%}\n\n {%- set intersection = [] -%}\n {%- for col in query_columns -%}\n {%- if col in existing_cols -%}\n {%- do intersection.append(col) -%}\n {%- else -%}\n {% set ns.column_added = true %}\n {%- endif -%}\n {%- endfor -%}\n {{ return([ns.column_added, intersection]) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.snapshot_check_strategy": {"unique_id": "macro.dbt.snapshot_check_strategy", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshot/strategies.sql", "original_file_path": "macros/materializations/snapshot/strategies.sql", "name": "snapshot_check_strategy", "macro_sql": "{% macro snapshot_check_strategy(node, snapshotted_rel, current_rel, config, target_exists) %}\n {% set check_cols_config = config['check_cols'] %}\n {% set primary_key = config['unique_key'] %}\n {% set invalidate_hard_deletes = config.get('invalidate_hard_deletes', false) %}\n \n {% set select_current_time -%}\n select {{ snapshot_get_time() }} as snapshot_start\n {%- endset %}\n\n {#-- don't access the column by name, to avoid dealing with casing issues on snowflake #}\n {%- set now = run_query(select_current_time)[0][0] -%}\n {% if now is none or now is undefined -%}\n {%- do exceptions.raise_compiler_error('Could not get a snapshot start time from the database') -%}\n {%- endif %}\n {% set updated_at = snapshot_string_as_time(now) %}\n\n {% set column_added = false %}\n\n {% if check_cols_config == 'all' %}\n {% set column_added, check_cols = snapshot_check_all_get_existing_columns(node, target_exists) %}\n {% elif check_cols_config is iterable and (check_cols_config | length) > 0 %}\n {% set check_cols = check_cols_config %}\n {% else %}\n {% do exceptions.raise_compiler_error(\"Invalid value for 'check_cols': \" ~ check_cols_config) %}\n {% endif %}\n\n {%- set row_changed_expr -%}\n (\n {%- if column_added -%}\n TRUE\n {%- else -%}\n {%- for col in check_cols -%}\n {{ snapshotted_rel }}.{{ col }} != {{ current_rel }}.{{ col }}\n or\n (\n (({{ snapshotted_rel }}.{{ col }} is null) and not ({{ current_rel }}.{{ col }} is null))\n or\n ((not {{ snapshotted_rel }}.{{ col }} is null) and ({{ current_rel }}.{{ col }} is null))\n )\n {%- if not loop.last %} or {% endif -%}\n {%- endfor -%}\n {%- endif -%}\n )\n {%- endset %}\n\n {% set scd_id_expr = snapshot_hash_arguments([primary_key, updated_at]) %}\n\n {% do return({\n \"unique_key\": primary_key,\n \"updated_at\": updated_at,\n \"row_changed\": row_changed_expr,\n \"scd_id\": scd_id_expr,\n \"invalidate_hard_deletes\": invalidate_hard_deletes\n }) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.create_columns": {"unique_id": "macro.dbt.create_columns", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshot/snapshot.sql", "original_file_path": "macros/materializations/snapshot/snapshot.sql", "name": "create_columns", "macro_sql": "{% macro create_columns(relation, columns) %}\n {{ adapter.dispatch('create_columns')(relation, columns) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__create_columns": {"unique_id": "macro.dbt.default__create_columns", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshot/snapshot.sql", "original_file_path": "macros/materializations/snapshot/snapshot.sql", "name": "default__create_columns", "macro_sql": "{% macro default__create_columns(relation, columns) %}\n {% for column in columns %}\n {% call statement() %}\n alter table {{ relation }} add column \"{{ column.name }}\" {{ column.data_type }};\n {% endcall %}\n {% endfor %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.post_snapshot": {"unique_id": "macro.dbt.post_snapshot", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshot/snapshot.sql", "original_file_path": "macros/materializations/snapshot/snapshot.sql", "name": "post_snapshot", "macro_sql": "{% macro post_snapshot(staging_relation) %}\n {{ adapter.dispatch('post_snapshot')(staging_relation) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__post_snapshot": {"unique_id": "macro.dbt.default__post_snapshot", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshot/snapshot.sql", "original_file_path": "macros/materializations/snapshot/snapshot.sql", "name": "default__post_snapshot", "macro_sql": "{% macro default__post_snapshot(staging_relation) %}\n {# no-op #}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.snapshot_staging_table": {"unique_id": "macro.dbt.snapshot_staging_table", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshot/snapshot.sql", "original_file_path": "macros/materializations/snapshot/snapshot.sql", "name": "snapshot_staging_table", "macro_sql": "{% macro snapshot_staging_table(strategy, source_sql, target_relation) -%}\n\n with snapshot_query as (\n\n {{ source_sql }}\n\n ),\n\n snapshotted_data as (\n\n select *,\n {{ strategy.unique_key }} as dbt_unique_key\n\n from {{ target_relation }}\n where dbt_valid_to is null\n\n ),\n\n insertions_source_data as (\n\n select\n *,\n {{ strategy.unique_key }} as dbt_unique_key,\n {{ strategy.updated_at }} as dbt_updated_at,\n {{ strategy.updated_at }} as dbt_valid_from,\n nullif({{ strategy.updated_at }}, {{ strategy.updated_at }}) as dbt_valid_to,\n {{ strategy.scd_id }} as dbt_scd_id\n\n from snapshot_query\n ),\n\n updates_source_data as (\n\n select\n *,\n {{ strategy.unique_key }} as dbt_unique_key,\n {{ strategy.updated_at }} as dbt_updated_at,\n {{ strategy.updated_at }} as dbt_valid_from,\n {{ strategy.updated_at }} as dbt_valid_to\n\n from snapshot_query\n ),\n\n {%- if strategy.invalidate_hard_deletes %}\n\n deletes_source_data as (\n\n select \n *,\n {{ strategy.unique_key }} as dbt_unique_key\n from snapshot_query\n ),\n {% endif %}\n\n insertions as (\n\n select\n 'insert' as dbt_change_type,\n source_data.*\n\n from insertions_source_data as source_data\n left outer join snapshotted_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where snapshotted_data.dbt_unique_key is null\n or (\n snapshotted_data.dbt_unique_key is not null\n and (\n {{ strategy.row_changed }}\n )\n )\n\n ),\n\n updates as (\n\n select\n 'update' as dbt_change_type,\n source_data.*,\n snapshotted_data.dbt_scd_id\n\n from updates_source_data as source_data\n join snapshotted_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where (\n {{ strategy.row_changed }}\n )\n )\n\n {%- if strategy.invalidate_hard_deletes -%}\n ,\n\n deletes as (\n \n select\n 'delete' as dbt_change_type,\n source_data.*,\n {{ snapshot_get_time() }} as dbt_valid_from,\n {{ snapshot_get_time() }} as dbt_updated_at,\n {{ snapshot_get_time() }} as dbt_valid_to,\n snapshotted_data.dbt_scd_id\n \n from snapshotted_data\n left join deletes_source_data as source_data on snapshotted_data.dbt_unique_key = source_data.dbt_unique_key\n where source_data.dbt_unique_key is null\n )\n {%- endif %}\n\n select * from insertions\n union all\n select * from updates\n {%- if strategy.invalidate_hard_deletes %}\n union all\n select * from deletes\n {%- endif %}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.build_snapshot_table": {"unique_id": "macro.dbt.build_snapshot_table", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshot/snapshot.sql", "original_file_path": "macros/materializations/snapshot/snapshot.sql", "name": "build_snapshot_table", "macro_sql": "{% macro build_snapshot_table(strategy, sql) %}\n\n select *,\n {{ strategy.scd_id }} as dbt_scd_id,\n {{ strategy.updated_at }} as dbt_updated_at,\n {{ strategy.updated_at }} as dbt_valid_from,\n nullif({{ strategy.updated_at }}, {{ strategy.updated_at }}) as dbt_valid_to\n from (\n {{ sql }}\n ) sbq\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.get_or_create_relation": {"unique_id": "macro.dbt.get_or_create_relation", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshot/snapshot.sql", "original_file_path": "macros/materializations/snapshot/snapshot.sql", "name": "get_or_create_relation", "macro_sql": "{% macro get_or_create_relation(database, schema, identifier, type) %}\n {%- set target_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) %}\n\n {% if target_relation %}\n {% do return([true, target_relation]) %}\n {% endif %}\n\n {%- set new_relation = api.Relation.create(\n database=database,\n schema=schema,\n identifier=identifier,\n type=type\n ) -%}\n {% do return([false, new_relation]) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.build_snapshot_staging_table": {"unique_id": "macro.dbt.build_snapshot_staging_table", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshot/snapshot.sql", "original_file_path": "macros/materializations/snapshot/snapshot.sql", "name": "build_snapshot_staging_table", "macro_sql": "{% macro build_snapshot_staging_table(strategy, sql, target_relation) %}\n {% set tmp_relation = make_temp_relation(target_relation) %}\n\n {% set select = snapshot_staging_table(strategy, sql, target_relation) %}\n\n {% call statement('build_snapshot_staging_relation') %}\n {{ create_table_as(True, tmp_relation, select) }}\n {% endcall %}\n\n {% do return(tmp_relation) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.materialization_snapshot_default": {"unique_id": "macro.dbt.materialization_snapshot_default", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/snapshot/snapshot.sql", "original_file_path": "macros/materializations/snapshot/snapshot.sql", "name": "materialization_snapshot_default", "macro_sql": "{% materialization snapshot, default %}\n {%- set config = model['config'] -%}\n\n {%- set target_table = model.get('alias', model.get('name')) -%}\n\n {%- set strategy_name = config.get('strategy') -%}\n {%- set unique_key = config.get('unique_key') %}\n\n {% if not adapter.check_schema_exists(model.database, model.schema) %}\n {% do create_schema(model.database, model.schema) %}\n {% endif %}\n\n {% set target_relation_exists, target_relation = get_or_create_relation(\n database=model.database,\n schema=model.schema,\n identifier=target_table,\n type='table') -%}\n\n {%- if not target_relation.is_table -%}\n {% do exceptions.relation_wrong_type(target_relation, 'table') %}\n {%- endif -%}\n\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% set strategy_macro = strategy_dispatch(strategy_name) %}\n {% set strategy = strategy_macro(model, \"snapshotted_data\", \"source_data\", config, target_relation_exists) %}\n\n {% if not target_relation_exists %}\n\n {% set build_sql = build_snapshot_table(strategy, model['compiled_sql']) %}\n {% set final_sql = create_table_as(False, target_relation, build_sql) %}\n\n {% else %}\n\n {{ adapter.valid_snapshot_target(target_relation) }}\n\n {% set staging_table = build_snapshot_staging_table(strategy, sql, target_relation) %}\n\n -- this may no-op if the database does not require column expansion\n {% do adapter.expand_target_column_types(from_relation=staging_table,\n to_relation=target_relation) %}\n\n {% set missing_columns = adapter.get_missing_columns(staging_table, target_relation)\n | rejectattr('name', 'equalto', 'dbt_change_type')\n | rejectattr('name', 'equalto', 'DBT_CHANGE_TYPE')\n | rejectattr('name', 'equalto', 'dbt_unique_key')\n | rejectattr('name', 'equalto', 'DBT_UNIQUE_KEY')\n | list %}\n\n {% do create_columns(target_relation, missing_columns) %}\n\n {% set source_columns = adapter.get_columns_in_relation(staging_table)\n | rejectattr('name', 'equalto', 'dbt_change_type')\n | rejectattr('name', 'equalto', 'DBT_CHANGE_TYPE')\n | rejectattr('name', 'equalto', 'dbt_unique_key')\n | rejectattr('name', 'equalto', 'DBT_UNIQUE_KEY')\n | list %}\n\n {% set quoted_source_columns = [] %}\n {% for column in source_columns %}\n {% do quoted_source_columns.append(adapter.quote(column.name)) %}\n {% endfor %}\n\n {% set final_sql = snapshot_merge_sql(\n target = target_relation,\n source = staging_table,\n insert_cols = quoted_source_columns\n )\n %}\n\n {% endif %}\n\n {% call statement('main') %}\n {{ final_sql }}\n {% endcall %}\n\n {% do persist_docs(target_relation, model) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n {% if staging_table is defined %}\n {% do post_snapshot(staging_table) %}\n {% endif %}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.create_csv_table": {"unique_id": "macro.dbt.create_csv_table", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/seed/seed.sql", "original_file_path": "macros/materializations/seed/seed.sql", "name": "create_csv_table", "macro_sql": "{% macro create_csv_table(model, agate_table) -%}\n {{ adapter.dispatch('create_csv_table')(model, agate_table) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.reset_csv_table": {"unique_id": "macro.dbt.reset_csv_table", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/seed/seed.sql", "original_file_path": "macros/materializations/seed/seed.sql", "name": "reset_csv_table", "macro_sql": "{% macro reset_csv_table(model, full_refresh, old_relation, agate_table) -%}\n {{ adapter.dispatch('reset_csv_table')(model, full_refresh, old_relation, agate_table) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.load_csv_rows": {"unique_id": "macro.dbt.load_csv_rows", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/seed/seed.sql", "original_file_path": "macros/materializations/seed/seed.sql", "name": "load_csv_rows", "macro_sql": "{% macro load_csv_rows(model, agate_table) -%}\n {{ adapter.dispatch('load_csv_rows')(model, agate_table) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__create_csv_table": {"unique_id": "macro.dbt.default__create_csv_table", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/seed/seed.sql", "original_file_path": "macros/materializations/seed/seed.sql", "name": "default__create_csv_table", "macro_sql": "{% macro default__create_csv_table(model, agate_table) %}\n {%- set column_override = model['config'].get('column_types', {}) -%}\n {%- set quote_seed_column = model['config'].get('quote_columns', None) -%}\n\n {% set sql %}\n create table {{ this.render() }} (\n {%- for col_name in agate_table.column_names -%}\n {%- set inferred_type = adapter.convert_type(agate_table, loop.index0) -%}\n {%- set type = column_override.get(col_name, inferred_type) -%}\n {%- set column_name = (col_name | string) -%}\n {{ adapter.quote_seed_column(column_name, quote_seed_column) }} {{ type }} {%- if not loop.last -%}, {%- endif -%}\n {%- endfor -%}\n )\n {% endset %}\n\n {% call statement('_') -%}\n {{ sql }}\n {%- endcall %}\n\n {{ return(sql) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__reset_csv_table": {"unique_id": "macro.dbt.default__reset_csv_table", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/seed/seed.sql", "original_file_path": "macros/materializations/seed/seed.sql", "name": "default__reset_csv_table", "macro_sql": "{% macro default__reset_csv_table(model, full_refresh, old_relation, agate_table) %}\n {% set sql = \"\" %}\n {% if full_refresh %}\n {{ adapter.drop_relation(old_relation) }}\n {% set sql = create_csv_table(model, agate_table) %}\n {% else %}\n {{ adapter.truncate_relation(old_relation) }}\n {% set sql = \"truncate table \" ~ old_relation %}\n {% endif %}\n\n {{ return(sql) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.get_seed_column_quoted_csv": {"unique_id": "macro.dbt.get_seed_column_quoted_csv", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/seed/seed.sql", "original_file_path": "macros/materializations/seed/seed.sql", "name": "get_seed_column_quoted_csv", "macro_sql": "{% macro get_seed_column_quoted_csv(model, column_names) %}\n {%- set quote_seed_column = model['config'].get('quote_columns', None) -%}\n {% set quoted = [] %}\n {% for col in column_names -%}\n {%- do quoted.append(adapter.quote_seed_column(col, quote_seed_column)) -%}\n {%- endfor %}\n\n {%- set dest_cols_csv = quoted | join(', ') -%}\n {{ return(dest_cols_csv) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.basic_load_csv_rows": {"unique_id": "macro.dbt.basic_load_csv_rows", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/seed/seed.sql", "original_file_path": "macros/materializations/seed/seed.sql", "name": "basic_load_csv_rows", "macro_sql": "{% macro basic_load_csv_rows(model, batch_size, agate_table) %}\n {% set cols_sql = get_seed_column_quoted_csv(model, agate_table.column_names) %}\n {% set bindings = [] %}\n\n {% set statements = [] %}\n\n {% for chunk in agate_table.rows | batch(batch_size) %}\n {% set bindings = [] %}\n\n {% for row in chunk %}\n {% do bindings.extend(row) %}\n {% endfor %}\n\n {% set sql %}\n insert into {{ this.render() }} ({{ cols_sql }}) values\n {% for row in chunk -%}\n ({%- for column in agate_table.column_names -%}\n %s\n {%- if not loop.last%},{%- endif %}\n {%- endfor -%})\n {%- if not loop.last%},{%- endif %}\n {%- endfor %}\n {% endset %}\n\n {% do adapter.add_query(sql, bindings=bindings, abridge_sql_log=True) %}\n\n {% if loop.index0 == 0 %}\n {% do statements.append(sql) %}\n {% endif %}\n {% endfor %}\n\n {# Return SQL so we can render it out into the compiled files #}\n {{ return(statements[0]) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__load_csv_rows": {"unique_id": "macro.dbt.default__load_csv_rows", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/seed/seed.sql", "original_file_path": "macros/materializations/seed/seed.sql", "name": "default__load_csv_rows", "macro_sql": "{% macro default__load_csv_rows(model, agate_table) %}\n {{ return(basic_load_csv_rows(model, 10000, agate_table) )}}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.materialization_seed_default": {"unique_id": "macro.dbt.materialization_seed_default", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/seed/seed.sql", "original_file_path": "macros/materializations/seed/seed.sql", "name": "materialization_seed_default", "macro_sql": "{% materialization seed, default %}\n\n {%- set identifier = model['alias'] -%}\n {%- set full_refresh_mode = (should_full_refresh()) -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n\n {%- set exists_as_table = (old_relation is not none and old_relation.is_table) -%}\n {%- set exists_as_view = (old_relation is not none and old_relation.is_view) -%}\n\n {%- set agate_table = load_agate_table() -%}\n {%- do store_result('agate_table', response='OK', agate_table=agate_table) -%}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n -- build model\n {% set create_table_sql = \"\" %}\n {% if exists_as_view %}\n {{ exceptions.raise_compiler_error(\"Cannot seed to '{}', it is a view\".format(old_relation)) }}\n {% elif exists_as_table %}\n {% set create_table_sql = reset_csv_table(model, full_refresh_mode, old_relation, agate_table) %}\n {% else %}\n {% set create_table_sql = create_csv_table(model, agate_table) %}\n {% endif %}\n\n {% set code = 'CREATE' if full_refresh_mode else 'INSERT' %}\n {% set rows_affected = (agate_table.rows | length) %}\n {% set sql = load_csv_rows(model, agate_table) %}\n\n {% call noop_statement('main', code ~ ' ' ~ rows_affected, code, rows_affected) %}\n {{ create_table_sql }};\n -- dbt seed --\n {{ sql }}\n {% endcall %}\n\n {% set target_relation = this.incorporate(type='table') %}\n {% do persist_docs(target_relation, model) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n -- `COMMIT` happens here\n {{ adapter.commit() }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmaterialization %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.incremental_upsert": {"unique_id": "macro.dbt.incremental_upsert", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/incremental/helpers.sql", "original_file_path": "macros/materializations/incremental/helpers.sql", "name": "incremental_upsert", "macro_sql": "{% macro incremental_upsert(tmp_relation, target_relation, unique_key=none, statement_name=\"main\") %}\n {%- set dest_columns = adapter.get_columns_in_relation(target_relation) -%}\n {%- set dest_cols_csv = dest_columns | map(attribute='quoted') | join(', ') -%}\n\n {%- if unique_key is not none -%}\n delete\n from {{ target_relation }}\n where ({{ unique_key }}) in (\n select ({{ unique_key }})\n from {{ tmp_relation }}\n );\n {%- endif %}\n\n insert into {{ target_relation }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ tmp_relation }}\n );\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.materialization_incremental_default": {"unique_id": "macro.dbt.materialization_incremental_default", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/incremental/incremental.sql", "original_file_path": "macros/materializations/incremental/incremental.sql", "name": "materialization_incremental_default", "macro_sql": "{% materialization incremental, default -%}\n\n {% set unique_key = config.get('unique_key') %}\n\n {% set target_relation = this.incorporate(type='table') %}\n {% set existing_relation = load_relation(this) %}\n {% set tmp_relation = make_temp_relation(this) %}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n {% set to_drop = [] %}\n {% if existing_relation is none %}\n {% set build_sql = create_table_as(False, target_relation, sql) %}\n {% elif existing_relation.is_view or should_full_refresh() %}\n {#-- Make sure the backup doesn't exist so we don't encounter issues with the rename below #}\n {% set backup_identifier = existing_relation.identifier ~ \"__dbt_backup\" %}\n {% set backup_relation = existing_relation.incorporate(path={\"identifier\": backup_identifier}) %}\n {% do adapter.drop_relation(backup_relation) %}\n\n {% do adapter.rename_relation(target_relation, backup_relation) %}\n {% set build_sql = create_table_as(False, target_relation, sql) %}\n {% do to_drop.append(backup_relation) %}\n {% else %}\n {% set tmp_relation = make_temp_relation(target_relation) %}\n {% do run_query(create_table_as(True, tmp_relation, sql)) %}\n {% do adapter.expand_target_column_types(\n from_relation=tmp_relation,\n to_relation=target_relation) %}\n {% set build_sql = incremental_upsert(tmp_relation, target_relation, unique_key=unique_key) %}\n {% endif %}\n\n {% call statement(\"main\") %}\n {{ build_sql }}\n {% endcall %}\n\n {% do persist_docs(target_relation, model) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n -- `COMMIT` happens here\n {% do adapter.commit() %}\n\n {% for rel in to_drop %}\n {% do adapter.drop_relation(rel) %}\n {% endfor %}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.get_merge_sql": {"unique_id": "macro.dbt.get_merge_sql", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/common/merge.sql", "original_file_path": "macros/materializations/common/merge.sql", "name": "get_merge_sql", "macro_sql": "{% macro get_merge_sql(target, source, unique_key, dest_columns, predicates=none) -%}\n {{ adapter.dispatch('get_merge_sql')(target, source, unique_key, dest_columns, predicates) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.get_delete_insert_merge_sql": {"unique_id": "macro.dbt.get_delete_insert_merge_sql", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/common/merge.sql", "original_file_path": "macros/materializations/common/merge.sql", "name": "get_delete_insert_merge_sql", "macro_sql": "{% macro get_delete_insert_merge_sql(target, source, unique_key, dest_columns) -%}\n {{ adapter.dispatch('get_delete_insert_merge_sql')(target, source, unique_key, dest_columns) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.get_insert_overwrite_merge_sql": {"unique_id": "macro.dbt.get_insert_overwrite_merge_sql", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/common/merge.sql", "original_file_path": "macros/materializations/common/merge.sql", "name": "get_insert_overwrite_merge_sql", "macro_sql": "{% macro get_insert_overwrite_merge_sql(target, source, dest_columns, predicates, include_sql_header=false) -%}\n {{ adapter.dispatch('get_insert_overwrite_merge_sql')(target, source, dest_columns, predicates, include_sql_header) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__get_merge_sql": {"unique_id": "macro.dbt.default__get_merge_sql", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/common/merge.sql", "original_file_path": "macros/materializations/common/merge.sql", "name": "default__get_merge_sql", "macro_sql": "{% macro default__get_merge_sql(target, source, unique_key, dest_columns, predicates) -%}\n {%- set predicates = [] if predicates is none else [] + predicates -%}\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {% if unique_key %}\n {% set unique_key_match %}\n DBT_INTERNAL_SOURCE.{{ unique_key }} = DBT_INTERNAL_DEST.{{ unique_key }}\n {% endset %}\n {% do predicates.append(unique_key_match) %}\n {% else %}\n {% do predicates.append('FALSE') %}\n {% endif %}\n\n {{ sql_header if sql_header is not none }}\n\n merge into {{ target }} as DBT_INTERNAL_DEST\n using {{ source }} as DBT_INTERNAL_SOURCE\n on {{ predicates | join(' and ') }}\n\n {% if unique_key %}\n when matched then update set\n {% for column in dest_columns -%}\n {{ adapter.quote(column.name) }} = DBT_INTERNAL_SOURCE.{{ adapter.quote(column.name) }}\n {%- if not loop.last %}, {%- endif %}\n {%- endfor %}\n {% endif %}\n\n when not matched then insert\n ({{ dest_cols_csv }})\n values\n ({{ dest_cols_csv }})\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.get_quoted_csv": {"unique_id": "macro.dbt.get_quoted_csv", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/common/merge.sql", "original_file_path": "macros/materializations/common/merge.sql", "name": "get_quoted_csv", "macro_sql": "{% macro get_quoted_csv(column_names) %}\n {% set quoted = [] %}\n {% for col in column_names -%}\n {%- do quoted.append(adapter.quote(col)) -%}\n {%- endfor %}\n\n {%- set dest_cols_csv = quoted | join(', ') -%}\n {{ return(dest_cols_csv) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.common_get_delete_insert_merge_sql": {"unique_id": "macro.dbt.common_get_delete_insert_merge_sql", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/common/merge.sql", "original_file_path": "macros/materializations/common/merge.sql", "name": "common_get_delete_insert_merge_sql", "macro_sql": "{% macro common_get_delete_insert_merge_sql(target, source, unique_key, dest_columns) -%}\n\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n\n {% if unique_key is not none %}\n delete from {{ target }}\n where ({{ unique_key }}) in (\n select ({{ unique_key }})\n from {{ source }}\n );\n {% endif %}\n\n insert into {{ target }} ({{ dest_cols_csv }})\n (\n select {{ dest_cols_csv }}\n from {{ source }}\n );\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__get_delete_insert_merge_sql": {"unique_id": "macro.dbt.default__get_delete_insert_merge_sql", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/common/merge.sql", "original_file_path": "macros/materializations/common/merge.sql", "name": "default__get_delete_insert_merge_sql", "macro_sql": "{% macro default__get_delete_insert_merge_sql(target, source, unique_key, dest_columns) -%}\n {{ common_get_delete_insert_merge_sql(target, source, unique_key, dest_columns) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__get_insert_overwrite_merge_sql": {"unique_id": "macro.dbt.default__get_insert_overwrite_merge_sql", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/common/merge.sql", "original_file_path": "macros/materializations/common/merge.sql", "name": "default__get_insert_overwrite_merge_sql", "macro_sql": "{% macro default__get_insert_overwrite_merge_sql(target, source, dest_columns, predicates, include_sql_header) -%}\n {%- set predicates = [] if predicates is none else [] + predicates -%}\n {%- set dest_cols_csv = get_quoted_csv(dest_columns | map(attribute=\"name\")) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none and include_sql_header }}\n\n merge into {{ target }} as DBT_INTERNAL_DEST\n using {{ source }} as DBT_INTERNAL_SOURCE\n on FALSE\n\n when not matched by source\n {% if predicates %} and {{ predicates | join(' and ') }} {% endif %}\n then delete\n\n when not matched then insert\n ({{ dest_cols_csv }})\n values\n ({{ dest_cols_csv }})\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.materialization_table_default": {"unique_id": "macro.dbt.materialization_table_default", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/table/table.sql", "original_file_path": "macros/materializations/table/table.sql", "name": "materialization_table_default", "macro_sql": "{% materialization table, default %}\n {%- set identifier = model['alias'] -%}\n {%- set tmp_identifier = model['name'] + '__dbt_tmp' -%}\n {%- set backup_identifier = model['name'] + '__dbt_backup' -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n {%- set target_relation = api.Relation.create(identifier=identifier,\n schema=schema,\n database=database,\n type='table') -%}\n {%- set intermediate_relation = api.Relation.create(identifier=tmp_identifier,\n schema=schema,\n database=database,\n type='table') -%}\n\n /*\n See ../view/view.sql for more information about this relation.\n */\n {%- set backup_relation_type = 'table' if old_relation is none else old_relation.type -%}\n {%- set backup_relation = api.Relation.create(identifier=backup_identifier,\n schema=schema,\n database=database,\n type=backup_relation_type) -%}\n\n {%- set exists_as_table = (old_relation is not none and old_relation.is_table) -%}\n {%- set exists_as_view = (old_relation is not none and old_relation.is_view) -%}\n\n\n -- drop the temp relations if they exists for some reason\n {{ adapter.drop_relation(intermediate_relation) }}\n {{ adapter.drop_relation(backup_relation) }}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n -- build model\n {% call statement('main') -%}\n {{ create_table_as(False, intermediate_relation, sql) }}\n {%- endcall %}\n\n -- cleanup\n {% if old_relation is not none %}\n {{ adapter.rename_relation(target_relation, backup_relation) }}\n {% endif %}\n\n {{ adapter.rename_relation(intermediate_relation, target_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {% do persist_docs(target_relation, model) %}\n\n -- `COMMIT` happens here\n {{ adapter.commit() }}\n\n -- finally, drop the existing/backup relation after the commit\n {{ drop_relation_if_exists(backup_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n{% endmaterialization %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.materialization_view_default": {"unique_id": "macro.dbt.materialization_view_default", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/view/view.sql", "original_file_path": "macros/materializations/view/view.sql", "name": "materialization_view_default", "macro_sql": "{%- materialization view, default -%}\n\n {%- set identifier = model['alias'] -%}\n {%- set tmp_identifier = model['name'] + '__dbt_tmp' -%}\n {%- set backup_identifier = model['name'] + '__dbt_backup' -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n {%- set target_relation = api.Relation.create(identifier=identifier, schema=schema, database=database,\n type='view') -%}\n {%- set intermediate_relation = api.Relation.create(identifier=tmp_identifier,\n schema=schema, database=database, type='view') -%}\n\n /*\n This relation (probably) doesn't exist yet. If it does exist, it's a leftover from\n a previous run, and we're going to try to drop it immediately. At the end of this\n materialization, we're going to rename the \"old_relation\" to this identifier,\n and then we're going to drop it. In order to make sure we run the correct one of:\n - drop view ...\n - drop table ...\n\n We need to set the type of this relation to be the type of the old_relation, if it exists,\n or else \"view\" as a sane default if it does not. Note that if the old_relation does not\n exist, then there is nothing to move out of the way and subsequentally drop. In that case,\n this relation will be effectively unused.\n */\n {%- set backup_relation_type = 'view' if old_relation is none else old_relation.type -%}\n {%- set backup_relation = api.Relation.create(identifier=backup_identifier,\n schema=schema, database=database,\n type=backup_relation_type) -%}\n\n {%- set exists_as_view = (old_relation is not none and old_relation.is_view) -%}\n\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n\n -- drop the temp relations if they exists for some reason\n {{ adapter.drop_relation(intermediate_relation) }}\n {{ adapter.drop_relation(backup_relation) }}\n\n -- `BEGIN` happens here:\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n -- build model\n {% call statement('main') -%}\n {{ create_view_as(intermediate_relation, sql) }}\n {%- endcall %}\n\n -- cleanup\n -- move the existing view out of the way\n {% if old_relation is not none %}\n {{ adapter.rename_relation(target_relation, backup_relation) }}\n {% endif %}\n {{ adapter.rename_relation(intermediate_relation, target_relation) }}\n\n {% do persist_docs(target_relation, model) %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n {{ drop_relation_if_exists(backup_relation) }}\n\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n\n {{ return({'relations': [target_relation]}) }}\n\n{%- endmaterialization -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.handle_existing_table": {"unique_id": "macro.dbt.handle_existing_table", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/view/create_or_replace_view.sql", "original_file_path": "macros/materializations/view/create_or_replace_view.sql", "name": "handle_existing_table", "macro_sql": "{% macro handle_existing_table(full_refresh, old_relation) %}\n {{ adapter.dispatch(\"handle_existing_table\", packages=['dbt'])(full_refresh, old_relation) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__handle_existing_table": {"unique_id": "macro.dbt.default__handle_existing_table", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/view/create_or_replace_view.sql", "original_file_path": "macros/materializations/view/create_or_replace_view.sql", "name": "default__handle_existing_table", "macro_sql": "{% macro default__handle_existing_table(full_refresh, old_relation) %}\n {{ adapter.drop_relation(old_relation) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.create_or_replace_view": {"unique_id": "macro.dbt.create_or_replace_view", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/materializations/view/create_or_replace_view.sql", "original_file_path": "macros/materializations/view/create_or_replace_view.sql", "name": "create_or_replace_view", "macro_sql": "{% macro create_or_replace_view(run_outside_transaction_hooks=True) %}\n {%- set identifier = model['alias'] -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n\n {%- set exists_as_view = (old_relation is not none and old_relation.is_view) -%}\n\n {%- set target_relation = api.Relation.create(\n identifier=identifier, schema=schema, database=database,\n type='view') -%}\n\n {% if run_outside_transaction_hooks %}\n -- no transactions on BigQuery\n {{ run_hooks(pre_hooks, inside_transaction=False) }}\n {% endif %}\n\n -- `BEGIN` happens here on Snowflake\n {{ run_hooks(pre_hooks, inside_transaction=True) }}\n\n -- If there's a table with the same name and we weren't told to full refresh,\n -- that's an error. If we were told to full refresh, drop it. This behavior differs\n -- for Snowflake and BigQuery, so multiple dispatch is used.\n {%- if old_relation is not none and old_relation.is_table -%}\n {{ handle_existing_table(should_full_refresh(), old_relation) }}\n {%- endif -%}\n\n -- build model\n {% call statement('main') -%}\n {{ create_view_as(target_relation, sql) }}\n {%- endcall %}\n\n {{ run_hooks(post_hooks, inside_transaction=True) }}\n\n {{ adapter.commit() }}\n\n {% if run_outside_transaction_hooks %}\n -- No transactions on BigQuery\n {{ run_hooks(post_hooks, inside_transaction=False) }}\n {% endif %}\n\n {{ return({'relations': [target_relation]}) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.generate_alias_name": {"unique_id": "macro.dbt.generate_alias_name", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/etc/get_custom_alias.sql", "original_file_path": "macros/etc/get_custom_alias.sql", "name": "generate_alias_name", "macro_sql": "{% macro generate_alias_name(custom_alias_name=none, node=none) -%}\n\n {%- if custom_alias_name is none -%}\n\n {{ node.name }}\n\n {%- else -%}\n\n {{ custom_alias_name | trim }}\n\n {%- endif -%}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.run_query": {"unique_id": "macro.dbt.run_query", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/etc/query.sql", "original_file_path": "macros/etc/query.sql", "name": "run_query", "macro_sql": "{% macro run_query(sql) %}\n {% call statement(\"run_query_statement\", fetch_result=true, auto_begin=false) %}\n {{ sql }}\n {% endcall %}\n\n {% do return(load_result(\"run_query_statement\").table) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.is_incremental": {"unique_id": "macro.dbt.is_incremental", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/etc/is_incremental.sql", "original_file_path": "macros/etc/is_incremental.sql", "name": "is_incremental", "macro_sql": "{% macro is_incremental() %}\n {#-- do not run introspective queries in parsing #}\n {% if not execute %}\n {{ return(False) }}\n {% else %}\n {% set relation = adapter.get_relation(this.database, this.schema, this.table) %}\n {{ return(relation is not none\n and relation.type == 'table'\n and model.config.materialized == 'incremental'\n and not should_full_refresh()) }}\n {% endif %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.convert_datetime": {"unique_id": "macro.dbt.convert_datetime", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/etc/datetime.sql", "original_file_path": "macros/etc/datetime.sql", "name": "convert_datetime", "macro_sql": "{% macro convert_datetime(date_str, date_fmt) %}\n\n {% set error_msg -%}\n The provided partition date '{{ date_str }}' does not match the expected format '{{ date_fmt }}'\n {%- endset %}\n\n {% set res = try_or_compiler_error(error_msg, modules.datetime.datetime.strptime, date_str.strip(), date_fmt) %}\n {{ return(res) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.dates_in_range": {"unique_id": "macro.dbt.dates_in_range", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/etc/datetime.sql", "original_file_path": "macros/etc/datetime.sql", "name": "dates_in_range", "macro_sql": "{% macro dates_in_range(start_date_str, end_date_str=none, in_fmt=\"%Y%m%d\", out_fmt=\"%Y%m%d\") %}\n {% set end_date_str = start_date_str if end_date_str is none else end_date_str %}\n\n {% set start_date = convert_datetime(start_date_str, in_fmt) %}\n {% set end_date = convert_datetime(end_date_str, in_fmt) %}\n\n {% set day_count = (end_date - start_date).days %}\n {% if day_count < 0 %}\n {% set msg -%}\n Partiton start date is after the end date ({{ start_date }}, {{ end_date }})\n {%- endset %}\n\n {{ exceptions.raise_compiler_error(msg, model) }}\n {% endif %}\n\n {% set date_list = [] %}\n {% for i in range(0, day_count + 1) %}\n {% set the_date = (modules.datetime.timedelta(days=i) + start_date) %}\n {% if not out_fmt %}\n {% set _ = date_list.append(the_date) %}\n {% else %}\n {% set _ = date_list.append(the_date.strftime(out_fmt)) %}\n {% endif %}\n {% endfor %}\n\n {{ return(date_list) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.partition_range": {"unique_id": "macro.dbt.partition_range", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/etc/datetime.sql", "original_file_path": "macros/etc/datetime.sql", "name": "partition_range", "macro_sql": "{% macro partition_range(raw_partition_date, date_fmt='%Y%m%d') %}\n {% set partition_range = (raw_partition_date | string).split(\",\") %}\n\n {% if (partition_range | length) == 1 %}\n {% set start_date = partition_range[0] %}\n {% set end_date = none %}\n {% elif (partition_range | length) == 2 %}\n {% set start_date = partition_range[0] %}\n {% set end_date = partition_range[1] %}\n {% else %}\n {{ exceptions.raise_compiler_error(\"Invalid partition time. Expected format: {Start Date}[,{End Date}]. Got: \" ~ raw_partition_date) }}\n {% endif %}\n\n {{ return(dates_in_range(start_date, end_date, in_fmt=date_fmt)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.py_current_timestring": {"unique_id": "macro.dbt.py_current_timestring", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/etc/datetime.sql", "original_file_path": "macros/etc/datetime.sql", "name": "py_current_timestring", "macro_sql": "{% macro py_current_timestring() %}\n {% set dt = modules.datetime.datetime.now() %}\n {% do return(dt.strftime(\"%Y%m%d%H%M%S%f\")) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.generate_schema_name": {"unique_id": "macro.dbt.generate_schema_name", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/etc/get_custom_schema.sql", "original_file_path": "macros/etc/get_custom_schema.sql", "name": "generate_schema_name", "macro_sql": "{% macro generate_schema_name(custom_schema_name, node) -%}\n\n {%- set default_schema = target.schema -%}\n {%- if custom_schema_name is none -%}\n\n {{ default_schema }}\n\n {%- else -%}\n\n {{ default_schema }}_{{ custom_schema_name | trim }}\n\n {%- endif -%}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.generate_schema_name_for_env": {"unique_id": "macro.dbt.generate_schema_name_for_env", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/etc/get_custom_schema.sql", "original_file_path": "macros/etc/get_custom_schema.sql", "name": "generate_schema_name_for_env", "macro_sql": "{% macro generate_schema_name_for_env(custom_schema_name, node) -%}\n\n {%- set default_schema = target.schema -%}\n {%- if target.name == 'prod' and custom_schema_name is not none -%}\n\n {{ custom_schema_name | trim }}\n\n {%- else -%}\n\n {{ default_schema }}\n\n {%- endif -%}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.generate_database_name": {"unique_id": "macro.dbt.generate_database_name", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/etc/get_custom_database.sql", "original_file_path": "macros/etc/get_custom_database.sql", "name": "generate_database_name", "macro_sql": "{% macro generate_database_name(custom_database_name=none, node=none) -%}\n {% do return(adapter.dispatch('generate_database_name')(custom_database_name, node)) %}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt.default__generate_database_name"]}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__generate_database_name": {"unique_id": "macro.dbt.default__generate_database_name", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/etc/get_custom_database.sql", "original_file_path": "macros/etc/get_custom_database.sql", "name": "default__generate_database_name", "macro_sql": "{% macro default__generate_database_name(custom_database_name=none, node=none) -%}\n {%- set default_database = target.database -%}\n {%- if custom_database_name is none -%}\n\n {{ default_database }}\n\n {%- else -%}\n\n {{ custom_database_name }}\n\n {%- endif -%}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.get_columns_in_query": {"unique_id": "macro.dbt.get_columns_in_query", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "get_columns_in_query", "macro_sql": "{% macro get_columns_in_query(select_sql) -%}\n {{ return(adapter.dispatch('get_columns_in_query')(select_sql)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__get_columns_in_query": {"unique_id": "macro.dbt.default__get_columns_in_query", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "default__get_columns_in_query", "macro_sql": "{% macro default__get_columns_in_query(select_sql) %}\n {% call statement('get_columns_in_query', fetch_result=True, auto_begin=False) -%}\n select * from (\n {{ select_sql }}\n ) as __dbt_sbq\n where false\n limit 0\n {% endcall %}\n\n {{ return(load_result('get_columns_in_query').table.columns | map(attribute='name') | list) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.create_schema": {"unique_id": "macro.dbt.create_schema", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "create_schema", "macro_sql": "{% macro create_schema(relation) -%}\n {{ adapter.dispatch('create_schema')(relation) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__create_schema": {"unique_id": "macro.dbt.default__create_schema", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "default__create_schema", "macro_sql": "{% macro default__create_schema(relation) -%}\n {%- call statement('create_schema') -%}\n create schema if not exists {{ relation.without_identifier() }}\n {% endcall %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.drop_schema": {"unique_id": "macro.dbt.drop_schema", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "drop_schema", "macro_sql": "{% macro drop_schema(relation) -%}\n {{ adapter.dispatch('drop_schema')(relation) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__drop_schema": {"unique_id": "macro.dbt.default__drop_schema", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "default__drop_schema", "macro_sql": "{% macro default__drop_schema(relation) -%}\n {%- call statement('drop_schema') -%}\n drop schema if exists {{ relation.without_identifier() }} cascade\n {% endcall %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.create_table_as": {"unique_id": "macro.dbt.create_table_as", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "create_table_as", "macro_sql": "{% macro create_table_as(temporary, relation, sql) -%}\n {{ adapter.dispatch('create_table_as')(temporary, relation, sql) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__create_table_as": {"unique_id": "macro.dbt.default__create_table_as", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "default__create_table_as", "macro_sql": "{% macro default__create_table_as(temporary, relation, sql) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n\n create {% if temporary: -%}temporary{%- endif %} table\n {{ relation.include(database=(not temporary), schema=(not temporary)) }}\n as (\n {{ sql }}\n );\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.create_view_as": {"unique_id": "macro.dbt.create_view_as", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "create_view_as", "macro_sql": "{% macro create_view_as(relation, sql) -%}\n {{ adapter.dispatch('create_view_as')(relation, sql) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__create_view_as": {"unique_id": "macro.dbt.default__create_view_as", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "default__create_view_as", "macro_sql": "{% macro default__create_view_as(relation, sql) -%}\n {%- set sql_header = config.get('sql_header', none) -%}\n\n {{ sql_header if sql_header is not none }}\n create view {{ relation }} as (\n {{ sql }}\n );\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.get_catalog": {"unique_id": "macro.dbt.get_catalog", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "get_catalog", "macro_sql": "{% macro get_catalog(information_schema, schemas) -%}\n {{ return(adapter.dispatch('get_catalog')(information_schema, schemas)) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_catalog"]}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__get_catalog": {"unique_id": "macro.dbt.default__get_catalog", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "default__get_catalog", "macro_sql": "{% macro default__get_catalog(information_schema, schemas) -%}\n\n {% set typename = adapter.type() %}\n {% set msg -%}\n get_catalog not implemented for {{ typename }}\n {%- endset %}\n\n {{ exceptions.raise_compiler_error(msg) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.get_columns_in_relation": {"unique_id": "macro.dbt.get_columns_in_relation", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "get_columns_in_relation", "macro_sql": "{% macro get_columns_in_relation(relation) -%}\n {{ return(adapter.dispatch('get_columns_in_relation')(relation)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__get_columns_in_relation"]}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.sql_convert_columns_in_relation": {"unique_id": "macro.dbt.sql_convert_columns_in_relation", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "sql_convert_columns_in_relation", "macro_sql": "{% macro sql_convert_columns_in_relation(table) -%}\n {% set columns = [] %}\n {% for row in table %}\n {% do columns.append(api.Column(*row)) %}\n {% endfor %}\n {{ return(columns) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__get_columns_in_relation": {"unique_id": "macro.dbt.default__get_columns_in_relation", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "default__get_columns_in_relation", "macro_sql": "{% macro default__get_columns_in_relation(relation) -%}\n {{ exceptions.raise_not_implemented(\n 'get_columns_in_relation macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.alter_column_type": {"unique_id": "macro.dbt.alter_column_type", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "alter_column_type", "macro_sql": "{% macro alter_column_type(relation, column_name, new_column_type) -%}\n {{ return(adapter.dispatch('alter_column_type')(relation, column_name, new_column_type)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.alter_column_comment": {"unique_id": "macro.dbt.alter_column_comment", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "alter_column_comment", "macro_sql": "{% macro alter_column_comment(relation, column_dict) -%}\n {{ return(adapter.dispatch('alter_column_comment')(relation, column_dict)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__alter_column_comment": {"unique_id": "macro.dbt.default__alter_column_comment", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "default__alter_column_comment", "macro_sql": "{% macro default__alter_column_comment(relation, column_dict) -%}\n {{ exceptions.raise_not_implemented(\n 'alter_column_comment macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.alter_relation_comment": {"unique_id": "macro.dbt.alter_relation_comment", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "alter_relation_comment", "macro_sql": "{% macro alter_relation_comment(relation, relation_comment) -%}\n {{ return(adapter.dispatch('alter_relation_comment')(relation, relation_comment)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__alter_relation_comment": {"unique_id": "macro.dbt.default__alter_relation_comment", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "default__alter_relation_comment", "macro_sql": "{% macro default__alter_relation_comment(relation, relation_comment) -%}\n {{ exceptions.raise_not_implemented(\n 'alter_relation_comment macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.persist_docs": {"unique_id": "macro.dbt.persist_docs", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "persist_docs", "macro_sql": "{% macro persist_docs(relation, model, for_relation=true, for_columns=true) -%}\n {{ return(adapter.dispatch('persist_docs')(relation, model, for_relation, for_columns)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__persist_docs": {"unique_id": "macro.dbt.default__persist_docs", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "default__persist_docs", "macro_sql": "{% macro default__persist_docs(relation, model, for_relation, for_columns) -%}\n {% if for_relation and config.persist_relation_docs() and model.description %}\n {% do run_query(alter_relation_comment(relation, model.description)) %}\n {% endif %}\n\n {% if for_columns and config.persist_column_docs() and model.columns %}\n {% do run_query(alter_column_comment(relation, model.columns)) %}\n {% endif %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__alter_column_type": {"unique_id": "macro.dbt.default__alter_column_type", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "default__alter_column_type", "macro_sql": "{% macro default__alter_column_type(relation, column_name, new_column_type) -%}\n {#\n 1. Create a new column (w/ temp name and correct type)\n 2. Copy data over to it\n 3. Drop the existing column (cascade!)\n 4. Rename the new column to existing column\n #}\n {%- set tmp_column = column_name + \"__dbt_alter\" -%}\n\n {% call statement('alter_column_type') %}\n alter table {{ relation }} add column {{ adapter.quote(tmp_column) }} {{ new_column_type }};\n update {{ relation }} set {{ adapter.quote(tmp_column) }} = {{ adapter.quote(column_name) }};\n alter table {{ relation }} drop column {{ adapter.quote(column_name) }} cascade;\n alter table {{ relation }} rename column {{ adapter.quote(tmp_column) }} to {{ adapter.quote(column_name) }}\n {% endcall %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.drop_relation": {"unique_id": "macro.dbt.drop_relation", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "drop_relation", "macro_sql": "{% macro drop_relation(relation) -%}\n {{ return(adapter.dispatch('drop_relation')(relation)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__drop_relation": {"unique_id": "macro.dbt.default__drop_relation", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "default__drop_relation", "macro_sql": "{% macro default__drop_relation(relation) -%}\n {% call statement('drop_relation', auto_begin=False) -%}\n drop {{ relation.type }} if exists {{ relation }} cascade\n {%- endcall %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.truncate_relation": {"unique_id": "macro.dbt.truncate_relation", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "truncate_relation", "macro_sql": "{% macro truncate_relation(relation) -%}\n {{ return(adapter.dispatch('truncate_relation')(relation)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__truncate_relation": {"unique_id": "macro.dbt.default__truncate_relation", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "default__truncate_relation", "macro_sql": "{% macro default__truncate_relation(relation) -%}\n {% call statement('truncate_relation') -%}\n truncate table {{ relation }}\n {%- endcall %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.rename_relation": {"unique_id": "macro.dbt.rename_relation", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "rename_relation", "macro_sql": "{% macro rename_relation(from_relation, to_relation) -%}\n {{ return(adapter.dispatch('rename_relation')(from_relation, to_relation)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__rename_relation": {"unique_id": "macro.dbt.default__rename_relation", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "default__rename_relation", "macro_sql": "{% macro default__rename_relation(from_relation, to_relation) -%}\n {% set target_name = adapter.quote_as_configured(to_relation.identifier, 'identifier') %}\n {% call statement('rename_relation') -%}\n alter table {{ from_relation }} rename to {{ target_name }}\n {%- endcall %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.information_schema_name": {"unique_id": "macro.dbt.information_schema_name", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "information_schema_name", "macro_sql": "{% macro information_schema_name(database) %}\n {{ return(adapter.dispatch('information_schema_name')(database)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__information_schema_name": {"unique_id": "macro.dbt.default__information_schema_name", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "default__information_schema_name", "macro_sql": "{% macro default__information_schema_name(database) -%}\n {%- if database -%}\n {{ database }}.INFORMATION_SCHEMA\n {%- else -%}\n INFORMATION_SCHEMA\n {%- endif -%}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.list_schemas": {"unique_id": "macro.dbt.list_schemas", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "list_schemas", "macro_sql": "{% macro list_schemas(database) -%}\n {{ return(adapter.dispatch('list_schemas')(database)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__list_schemas": {"unique_id": "macro.dbt.default__list_schemas", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "default__list_schemas", "macro_sql": "{% macro default__list_schemas(database) -%}\n {% set sql %}\n select distinct schema_name\n from {{ information_schema_name(database) }}.SCHEMATA\n where catalog_name ilike '{{ database }}'\n {% endset %}\n {{ return(run_query(sql)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.check_schema_exists": {"unique_id": "macro.dbt.check_schema_exists", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "check_schema_exists", "macro_sql": "{% macro check_schema_exists(information_schema, schema) -%}\n {{ return(adapter.dispatch('check_schema_exists')(information_schema, schema)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__check_schema_exists": {"unique_id": "macro.dbt.default__check_schema_exists", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "default__check_schema_exists", "macro_sql": "{% macro default__check_schema_exists(information_schema, schema) -%}\n {% set sql -%}\n select count(*)\n from {{ information_schema.replace(information_schema_view='SCHEMATA') }}\n where catalog_name='{{ information_schema.database }}'\n and schema_name='{{ schema }}'\n {%- endset %}\n {{ return(run_query(sql)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.list_relations_without_caching": {"unique_id": "macro.dbt.list_relations_without_caching", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "list_relations_without_caching", "macro_sql": "{% macro list_relations_without_caching(schema_relation) %}\n {{ return(adapter.dispatch('list_relations_without_caching')(schema_relation)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": ["macro.dbt_snowflake.snowflake__list_relations_without_caching"]}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__list_relations_without_caching": {"unique_id": "macro.dbt.default__list_relations_without_caching", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "default__list_relations_without_caching", "macro_sql": "{% macro default__list_relations_without_caching(schema_relation) %}\n {{ exceptions.raise_not_implemented(\n 'list_relations_without_caching macro not implemented for adapter '+adapter.type()) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.current_timestamp": {"unique_id": "macro.dbt.current_timestamp", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "current_timestamp", "macro_sql": "{% macro current_timestamp() -%}\n {{ adapter.dispatch('current_timestamp')() }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__current_timestamp": {"unique_id": "macro.dbt.default__current_timestamp", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "default__current_timestamp", "macro_sql": "{% macro default__current_timestamp() -%}\n {{ exceptions.raise_not_implemented(\n 'current_timestamp macro not implemented for adapter '+adapter.type()) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.collect_freshness": {"unique_id": "macro.dbt.collect_freshness", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "collect_freshness", "macro_sql": "{% macro collect_freshness(source, loaded_at_field, filter) %}\n {{ return(adapter.dispatch('collect_freshness')(source, loaded_at_field, filter))}}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__collect_freshness": {"unique_id": "macro.dbt.default__collect_freshness", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "default__collect_freshness", "macro_sql": "{% macro default__collect_freshness(source, loaded_at_field, filter) %}\n {% call statement('collect_freshness', fetch_result=True, auto_begin=False) -%}\n select\n max({{ loaded_at_field }}) as max_loaded_at,\n {{ current_timestamp() }} as snapshotted_at\n from {{ source }}\n {% if filter %}\n where {{ filter }}\n {% endif %}\n {% endcall %}\n {{ return(load_result('collect_freshness').table) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.make_temp_relation": {"unique_id": "macro.dbt.make_temp_relation", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "make_temp_relation", "macro_sql": "{% macro make_temp_relation(base_relation, suffix='__dbt_tmp') %}\n {{ return(adapter.dispatch('make_temp_relation')(base_relation, suffix))}}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__make_temp_relation": {"unique_id": "macro.dbt.default__make_temp_relation", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "default__make_temp_relation", "macro_sql": "{% macro default__make_temp_relation(base_relation, suffix) %}\n {% set tmp_identifier = base_relation.identifier ~ suffix %}\n {% set tmp_relation = base_relation.incorporate(\n path={\"identifier\": tmp_identifier}) -%}\n\n {% do return(tmp_relation) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.set_sql_header": {"unique_id": "macro.dbt.set_sql_header", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/adapters/common.sql", "original_file_path": "macros/adapters/common.sql", "name": "set_sql_header", "macro_sql": "{% macro set_sql_header(config) -%}\n {{ config.set('sql_header', caller()) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__test_relationships": {"unique_id": "macro.dbt.default__test_relationships", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/schema_tests/relationships.sql", "original_file_path": "macros/schema_tests/relationships.sql", "name": "default__test_relationships", "macro_sql": "{% macro default__test_relationships(model, to, field) %}\n\n{% set column_name = kwargs.get('column_name', kwargs.get('from')) %}\n\n\nselect count(*) as validation_errors\nfrom (\n select {{ column_name }} as id from {{ model }}\n) as child\nleft join (\n select {{ field }} as id from {{ to }}\n) as parent on parent.id = child.id\nwhere child.id is not null\n and parent.id is null\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.test_relationships": {"unique_id": "macro.dbt.test_relationships", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/schema_tests/relationships.sql", "original_file_path": "macros/schema_tests/relationships.sql", "name": "test_relationships", "macro_sql": "{% macro test_relationships(model, to, field) %}\n {% set macro = adapter.dispatch('test_relationships') %}\n {{ macro(model, to, field, **kwargs) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__test_not_null": {"unique_id": "macro.dbt.default__test_not_null", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/schema_tests/not_null.sql", "original_file_path": "macros/schema_tests/not_null.sql", "name": "default__test_not_null", "macro_sql": "{% macro default__test_not_null(model) %}\n\n{% set column_name = kwargs.get('column_name', kwargs.get('arg')) %}\n\nselect count(*) as validation_errors\nfrom {{ model }}\nwhere {{ column_name }} is null\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.test_not_null": {"unique_id": "macro.dbt.test_not_null", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/schema_tests/not_null.sql", "original_file_path": "macros/schema_tests/not_null.sql", "name": "test_not_null", "macro_sql": "{% macro test_not_null(model) %}\n {% set macro = adapter.dispatch('test_not_null') %}\n {{ macro(model, **kwargs) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__test_unique": {"unique_id": "macro.dbt.default__test_unique", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/schema_tests/unique.sql", "original_file_path": "macros/schema_tests/unique.sql", "name": "default__test_unique", "macro_sql": "{% macro default__test_unique(model) %}\n\n{% set column_name = kwargs.get('column_name', kwargs.get('arg')) %}\n\nselect count(*) as validation_errors\nfrom (\n\n select\n {{ column_name }}\n\n from {{ model }}\n where {{ column_name }} is not null\n group by {{ column_name }}\n having count(*) > 1\n\n) validation_errors\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.test_unique": {"unique_id": "macro.dbt.test_unique", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/schema_tests/unique.sql", "original_file_path": "macros/schema_tests/unique.sql", "name": "test_unique", "macro_sql": "{% macro test_unique(model) %}\n {% set macro = adapter.dispatch('test_unique') %}\n {{ macro(model, **kwargs) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.default__test_accepted_values": {"unique_id": "macro.dbt.default__test_accepted_values", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/schema_tests/accepted_values.sql", "original_file_path": "macros/schema_tests/accepted_values.sql", "name": "default__test_accepted_values", "macro_sql": "{% macro default__test_accepted_values(model, values) %}\n\n{% set column_name = kwargs.get('column_name', kwargs.get('field')) %}\n{% set quote_values = kwargs.get('quote', True) %}\n\nwith all_values as (\n\n select distinct\n {{ column_name }} as value_field\n\n from {{ model }}\n\n),\n\nvalidation_errors as (\n\n select\n value_field\n\n from all_values\n where value_field not in (\n {% for value in values -%}\n {% if quote_values -%}\n '{{ value }}'\n {%- else -%}\n {{ value }}\n {%- endif -%}\n {%- if not loop.last -%},{%- endif %}\n {%- endfor %}\n )\n)\n\nselect count(*) as validation_errors\nfrom validation_errors\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt.test_accepted_values": {"unique_id": "macro.dbt.test_accepted_values", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "macros/schema_tests/accepted_values.sql", "original_file_path": "macros/schema_tests/accepted_values.sql", "name": "test_accepted_values", "macro_sql": "{% macro test_accepted_values(model, values) %}\n {% set macro = adapter.dispatch('test_accepted_values') %}\n {{ macro(model, values, **kwargs) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.except": {"unique_id": "macro.dbt_utils.except", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/except.sql", "original_file_path": "macros/cross_db_utils/except.sql", "name": "except", "macro_sql": "{% macro except() %}\n {{ return(adapter.dispatch('except', packages = dbt_utils._get_utils_namespaces())()) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__except": {"unique_id": "macro.dbt_utils.default__except", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/except.sql", "original_file_path": "macros/cross_db_utils/except.sql", "name": "default__except", "macro_sql": "{% macro default__except() %}\n\n except\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.bigquery__except": {"unique_id": "macro.dbt_utils.bigquery__except", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/except.sql", "original_file_path": "macros/cross_db_utils/except.sql", "name": "bigquery__except", "macro_sql": "{% macro bigquery__except() %}\n\n except distinct\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.replace": {"unique_id": "macro.dbt_utils.replace", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/replace.sql", "original_file_path": "macros/cross_db_utils/replace.sql", "name": "replace", "macro_sql": "{% macro replace(field, old_chars, new_chars) -%}\n {{ return(adapter.dispatch('replace', packages = dbt_utils._get_utils_namespaces()) (field, old_chars, new_chars)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__replace": {"unique_id": "macro.dbt_utils.default__replace", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/replace.sql", "original_file_path": "macros/cross_db_utils/replace.sql", "name": "default__replace", "macro_sql": "{% macro default__replace(field, old_chars, new_chars) %}\n\n replace(\n {{ field }},\n {{ old_chars }},\n {{ new_chars }}\n )\n \n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.concat": {"unique_id": "macro.dbt_utils.concat", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/concat.sql", "original_file_path": "macros/cross_db_utils/concat.sql", "name": "concat", "macro_sql": "{% macro concat(fields) -%}\n {{ return(adapter.dispatch('concat', packages = dbt_utils._get_utils_namespaces())(fields)) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__concat": {"unique_id": "macro.dbt_utils.default__concat", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/concat.sql", "original_file_path": "macros/cross_db_utils/concat.sql", "name": "default__concat", "macro_sql": "{% macro default__concat(fields) -%}\n concat({{ fields|join(', ') }})\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.alternative_concat": {"unique_id": "macro.dbt_utils.alternative_concat", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/concat.sql", "original_file_path": "macros/cross_db_utils/concat.sql", "name": "alternative_concat", "macro_sql": "{% macro alternative_concat(fields) %}\n {{ fields|join(' || ') }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.redshift__concat": {"unique_id": "macro.dbt_utils.redshift__concat", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/concat.sql", "original_file_path": "macros/cross_db_utils/concat.sql", "name": "redshift__concat", "macro_sql": "{% macro redshift__concat(fields) %}\n {{ dbt_utils.alternative_concat(fields) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.snowflake__concat": {"unique_id": "macro.dbt_utils.snowflake__concat", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/concat.sql", "original_file_path": "macros/cross_db_utils/concat.sql", "name": "snowflake__concat", "macro_sql": "{% macro snowflake__concat(fields) %}\n {{ dbt_utils.alternative_concat(fields) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.type_string": {"unique_id": "macro.dbt_utils.type_string", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/datatypes.sql", "original_file_path": "macros/cross_db_utils/datatypes.sql", "name": "type_string", "macro_sql": "\n\n{%- macro type_string() -%}\n {{ return(adapter.dispatch('type_string', packages = dbt_utils._get_utils_namespaces())()) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__type_string": {"unique_id": "macro.dbt_utils.default__type_string", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/datatypes.sql", "original_file_path": "macros/cross_db_utils/datatypes.sql", "name": "default__type_string", "macro_sql": "{% macro default__type_string() %}\n string\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.redshift__type_string": {"unique_id": "macro.dbt_utils.redshift__type_string", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/datatypes.sql", "original_file_path": "macros/cross_db_utils/datatypes.sql", "name": "redshift__type_string", "macro_sql": "\n\n{%- macro redshift__type_string() -%}\n varchar\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.postgres__type_string": {"unique_id": "macro.dbt_utils.postgres__type_string", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/datatypes.sql", "original_file_path": "macros/cross_db_utils/datatypes.sql", "name": "postgres__type_string", "macro_sql": "{% macro postgres__type_string() %}\n varchar\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.snowflake__type_string": {"unique_id": "macro.dbt_utils.snowflake__type_string", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/datatypes.sql", "original_file_path": "macros/cross_db_utils/datatypes.sql", "name": "snowflake__type_string", "macro_sql": "{% macro snowflake__type_string() %}\n varchar\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.type_timestamp": {"unique_id": "macro.dbt_utils.type_timestamp", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/datatypes.sql", "original_file_path": "macros/cross_db_utils/datatypes.sql", "name": "type_timestamp", "macro_sql": "\n\n{%- macro type_timestamp() -%}\n {{ return(adapter.dispatch('type_timestamp', packages = dbt_utils._get_utils_namespaces())()) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__type_timestamp": {"unique_id": "macro.dbt_utils.default__type_timestamp", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/datatypes.sql", "original_file_path": "macros/cross_db_utils/datatypes.sql", "name": "default__type_timestamp", "macro_sql": "{% macro default__type_timestamp() %}\n timestamp\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.snowflake__type_timestamp": {"unique_id": "macro.dbt_utils.snowflake__type_timestamp", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/datatypes.sql", "original_file_path": "macros/cross_db_utils/datatypes.sql", "name": "snowflake__type_timestamp", "macro_sql": "{% macro snowflake__type_timestamp() %}\n timestamp_ntz\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.type_float": {"unique_id": "macro.dbt_utils.type_float", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/datatypes.sql", "original_file_path": "macros/cross_db_utils/datatypes.sql", "name": "type_float", "macro_sql": "\n\n{%- macro type_float() -%}\n {{ return(adapter.dispatch('type_float', packages = dbt_utils._get_utils_namespaces())()) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__type_float": {"unique_id": "macro.dbt_utils.default__type_float", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/datatypes.sql", "original_file_path": "macros/cross_db_utils/datatypes.sql", "name": "default__type_float", "macro_sql": "{% macro default__type_float() %}\n float\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.bigquery__type_float": {"unique_id": "macro.dbt_utils.bigquery__type_float", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/datatypes.sql", "original_file_path": "macros/cross_db_utils/datatypes.sql", "name": "bigquery__type_float", "macro_sql": "{% macro bigquery__type_float() %}\n float64\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.type_numeric": {"unique_id": "macro.dbt_utils.type_numeric", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/datatypes.sql", "original_file_path": "macros/cross_db_utils/datatypes.sql", "name": "type_numeric", "macro_sql": "\n\n{%- macro type_numeric() -%}\n {{ return(adapter.dispatch('type_numeric', packages = dbt_utils._get_utils_namespaces())()) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__type_numeric": {"unique_id": "macro.dbt_utils.default__type_numeric", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/datatypes.sql", "original_file_path": "macros/cross_db_utils/datatypes.sql", "name": "default__type_numeric", "macro_sql": "{% macro default__type_numeric() %}\n numeric(28, 6)\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.bigquery__type_numeric": {"unique_id": "macro.dbt_utils.bigquery__type_numeric", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/datatypes.sql", "original_file_path": "macros/cross_db_utils/datatypes.sql", "name": "bigquery__type_numeric", "macro_sql": "{% macro bigquery__type_numeric() %}\n numeric\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.type_bigint": {"unique_id": "macro.dbt_utils.type_bigint", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/datatypes.sql", "original_file_path": "macros/cross_db_utils/datatypes.sql", "name": "type_bigint", "macro_sql": "\n\n{%- macro type_bigint() -%}\n {{ return(adapter.dispatch('type_bigint', packages = dbt_utils._get_utils_namespaces())()) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__type_bigint": {"unique_id": "macro.dbt_utils.default__type_bigint", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/datatypes.sql", "original_file_path": "macros/cross_db_utils/datatypes.sql", "name": "default__type_bigint", "macro_sql": "{% macro default__type_bigint() %}\n bigint\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.bigquery__type_bigint": {"unique_id": "macro.dbt_utils.bigquery__type_bigint", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/datatypes.sql", "original_file_path": "macros/cross_db_utils/datatypes.sql", "name": "bigquery__type_bigint", "macro_sql": "{% macro bigquery__type_bigint() %}\n int64\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.type_int": {"unique_id": "macro.dbt_utils.type_int", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/datatypes.sql", "original_file_path": "macros/cross_db_utils/datatypes.sql", "name": "type_int", "macro_sql": "\n\n{%- macro type_int() -%}\n {{ return(adapter.dispatch('type_int', packages = dbt_utils._get_utils_namespaces())()) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__type_int": {"unique_id": "macro.dbt_utils.default__type_int", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/datatypes.sql", "original_file_path": "macros/cross_db_utils/datatypes.sql", "name": "default__type_int", "macro_sql": "{% macro default__type_int() %}\n int\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.bigquery__type_int": {"unique_id": "macro.dbt_utils.bigquery__type_int", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/datatypes.sql", "original_file_path": "macros/cross_db_utils/datatypes.sql", "name": "bigquery__type_int", "macro_sql": "{% macro bigquery__type_int() %}\n int64\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils._is_relation": {"unique_id": "macro.dbt_utils._is_relation", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/_is_relation.sql", "original_file_path": "macros/cross_db_utils/_is_relation.sql", "name": "_is_relation", "macro_sql": "{% macro _is_relation(obj, macro) %}\n {%- if not (obj is mapping and obj.get('metadata', {}).get('type', '').endswith('Relation')) -%}\n {%- do exceptions.raise_compiler_error(\"Macro \" ~ macro ~ \" expected a Relation but received the value: \" ~ obj) -%}\n {%- endif -%}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.length": {"unique_id": "macro.dbt_utils.length", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/length.sql", "original_file_path": "macros/cross_db_utils/length.sql", "name": "length", "macro_sql": "{% macro length(expression) -%}\n {{ return(adapter.dispatch('length', packages = dbt_utils._get_utils_namespaces()) (expression)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__length": {"unique_id": "macro.dbt_utils.default__length", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/length.sql", "original_file_path": "macros/cross_db_utils/length.sql", "name": "default__length", "macro_sql": "{% macro default__length(expression) %}\n \n length(\n {{ expression }}\n )\n \n{%- endmacro -%}\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.redshift__length": {"unique_id": "macro.dbt_utils.redshift__length", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/length.sql", "original_file_path": "macros/cross_db_utils/length.sql", "name": "redshift__length", "macro_sql": "{% macro redshift__length(expression) %}\n\n len(\n {{ expression }}\n )\n \n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.dateadd": {"unique_id": "macro.dbt_utils.dateadd", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/dateadd.sql", "original_file_path": "macros/cross_db_utils/dateadd.sql", "name": "dateadd", "macro_sql": "{% macro dateadd(datepart, interval, from_date_or_timestamp) %}\n {{ return(adapter.dispatch('dateadd', packages = dbt_utils._get_utils_namespaces())(datepart, interval, from_date_or_timestamp)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__dateadd": {"unique_id": "macro.dbt_utils.default__dateadd", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/dateadd.sql", "original_file_path": "macros/cross_db_utils/dateadd.sql", "name": "default__dateadd", "macro_sql": "{% macro default__dateadd(datepart, interval, from_date_or_timestamp) %}\n\n dateadd(\n {{ datepart }},\n {{ interval }},\n {{ from_date_or_timestamp }}\n )\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.bigquery__dateadd": {"unique_id": "macro.dbt_utils.bigquery__dateadd", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/dateadd.sql", "original_file_path": "macros/cross_db_utils/dateadd.sql", "name": "bigquery__dateadd", "macro_sql": "{% macro bigquery__dateadd(datepart, interval, from_date_or_timestamp) %}\n\n datetime_add(\n cast( {{ from_date_or_timestamp }} as datetime),\n interval {{ interval }} {{ datepart }}\n )\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.postgres__dateadd": {"unique_id": "macro.dbt_utils.postgres__dateadd", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/dateadd.sql", "original_file_path": "macros/cross_db_utils/dateadd.sql", "name": "postgres__dateadd", "macro_sql": "{% macro postgres__dateadd(datepart, interval, from_date_or_timestamp) %}\n\n {{ from_date_or_timestamp }} + ((interval '1 {{ datepart }}') * ({{ interval }}))\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.intersect": {"unique_id": "macro.dbt_utils.intersect", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/intersect.sql", "original_file_path": "macros/cross_db_utils/intersect.sql", "name": "intersect", "macro_sql": "{% macro intersect() %}\n {{ return(adapter.dispatch('intersect', packages = dbt_utils._get_utils_namespaces())()) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__intersect": {"unique_id": "macro.dbt_utils.default__intersect", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/intersect.sql", "original_file_path": "macros/cross_db_utils/intersect.sql", "name": "default__intersect", "macro_sql": "{% macro default__intersect() %}\n\n intersect\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.bigquery__intersect": {"unique_id": "macro.dbt_utils.bigquery__intersect", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/intersect.sql", "original_file_path": "macros/cross_db_utils/intersect.sql", "name": "bigquery__intersect", "macro_sql": "{% macro bigquery__intersect() %}\n\n intersect distinct\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.right": {"unique_id": "macro.dbt_utils.right", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/right.sql", "original_file_path": "macros/cross_db_utils/right.sql", "name": "right", "macro_sql": "{% macro right(string_text, length_expression) -%}\n {{ return(adapter.dispatch('right', packages = dbt_utils._get_utils_namespaces()) (string_text, length_expression)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__right": {"unique_id": "macro.dbt_utils.default__right", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/right.sql", "original_file_path": "macros/cross_db_utils/right.sql", "name": "default__right", "macro_sql": "{% macro default__right(string_text, length_expression) %}\n\n right(\n {{ string_text }},\n {{ length_expression }}\n )\n \n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.bigquery__right": {"unique_id": "macro.dbt_utils.bigquery__right", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/right.sql", "original_file_path": "macros/cross_db_utils/right.sql", "name": "bigquery__right", "macro_sql": "{% macro bigquery__right(string_text, length_expression) %}\n\n case when {{ length_expression }} = 0 \n then ''\n else \n substr(\n {{ string_text }},\n -1 * ({{ length_expression }})\n )\n end\n\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.snowflake__right": {"unique_id": "macro.dbt_utils.snowflake__right", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/right.sql", "original_file_path": "macros/cross_db_utils/right.sql", "name": "snowflake__right", "macro_sql": "{% macro snowflake__right(string_text, length_expression) %}\n\n case when {{ length_expression }} = 0 \n then ''\n else \n right(\n {{ string_text }},\n {{ length_expression }}\n )\n end\n\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.datediff": {"unique_id": "macro.dbt_utils.datediff", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/datediff.sql", "original_file_path": "macros/cross_db_utils/datediff.sql", "name": "datediff", "macro_sql": "{% macro datediff(first_date, second_date, datepart) %}\n {{ return(adapter.dispatch('datediff', packages = dbt_utils._get_utils_namespaces())(first_date, second_date, datepart)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__datediff": {"unique_id": "macro.dbt_utils.default__datediff", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/datediff.sql", "original_file_path": "macros/cross_db_utils/datediff.sql", "name": "default__datediff", "macro_sql": "{% macro default__datediff(first_date, second_date, datepart) %}\n\n datediff(\n {{ datepart }},\n {{ first_date }},\n {{ second_date }}\n )\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.bigquery__datediff": {"unique_id": "macro.dbt_utils.bigquery__datediff", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/datediff.sql", "original_file_path": "macros/cross_db_utils/datediff.sql", "name": "bigquery__datediff", "macro_sql": "{% macro bigquery__datediff(first_date, second_date, datepart) %}\n\n datetime_diff(\n cast({{second_date}} as datetime),\n cast({{first_date}} as datetime),\n {{datepart}}\n )\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.postgres__datediff": {"unique_id": "macro.dbt_utils.postgres__datediff", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/datediff.sql", "original_file_path": "macros/cross_db_utils/datediff.sql", "name": "postgres__datediff", "macro_sql": "{% macro postgres__datediff(first_date, second_date, datepart) %}\n\n {% if datepart == 'year' %}\n (date_part('year', ({{second_date}})::date) - date_part('year', ({{first_date}})::date))\n {% elif datepart == 'quarter' %}\n ({{ dbt_utils.datediff(first_date, second_date, 'year') }} * 4 + date_part('quarter', ({{second_date}})::date) - date_part('quarter', ({{first_date}})::date))\n {% elif datepart == 'month' %}\n ({{ dbt_utils.datediff(first_date, second_date, 'year') }} * 12 + date_part('month', ({{second_date}})::date) - date_part('month', ({{first_date}})::date))\n {% elif datepart == 'day' %}\n (({{second_date}})::date - ({{first_date}})::date)\n {% elif datepart == 'week' %}\n ({{ dbt_utils.datediff(first_date, second_date, 'day') }} / 7 + case\n when date_part('dow', ({{first_date}})::timestamp) <= date_part('dow', ({{second_date}})::timestamp) then\n case when {{first_date}} <= {{second_date}} then 0 else -1 end\n else\n case when {{first_date}} <= {{second_date}} then 1 else 0 end\n end)\n {% elif datepart == 'hour' %}\n ({{ dbt_utils.datediff(first_date, second_date, 'day') }} * 24 + date_part('hour', ({{second_date}})::timestamp) - date_part('hour', ({{first_date}})::timestamp))\n {% elif datepart == 'minute' %}\n ({{ dbt_utils.datediff(first_date, second_date, 'hour') }} * 60 + date_part('minute', ({{second_date}})::timestamp) - date_part('minute', ({{first_date}})::timestamp))\n {% elif datepart == 'second' %}\n ({{ dbt_utils.datediff(first_date, second_date, 'minute') }} * 60 + floor(date_part('second', ({{second_date}})::timestamp)) - floor(date_part('second', ({{first_date}})::timestamp)))\n {% elif datepart == 'millisecond' %}\n ({{ dbt_utils.datediff(first_date, second_date, 'minute') }} * 60000 + floor(date_part('millisecond', ({{second_date}})::timestamp)) - floor(date_part('millisecond', ({{first_date}})::timestamp)))\n {% elif datepart == 'microsecond' %}\n ({{ dbt_utils.datediff(first_date, second_date, 'minute') }} * 60000000 + floor(date_part('microsecond', ({{second_date}})::timestamp)) - floor(date_part('microsecond', ({{first_date}})::timestamp)))\n {% else %}\n {{ exceptions.raise_compiler_error(\"Unsupported datepart for macro datediff in postgres: {!r}\".format(datepart)) }}\n {% endif %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.safe_cast": {"unique_id": "macro.dbt_utils.safe_cast", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/safe_cast.sql", "original_file_path": "macros/cross_db_utils/safe_cast.sql", "name": "safe_cast", "macro_sql": "{% macro safe_cast(field, type) %}\n {{ return(adapter.dispatch('safe_cast', packages = dbt_utils._get_utils_namespaces()) (field, type)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__safe_cast": {"unique_id": "macro.dbt_utils.default__safe_cast", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/safe_cast.sql", "original_file_path": "macros/cross_db_utils/safe_cast.sql", "name": "default__safe_cast", "macro_sql": "{% macro default__safe_cast(field, type) %}\n {# most databases don't support this function yet\n so we just need to use cast #}\n cast({{field}} as {{type}})\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.snowflake__safe_cast": {"unique_id": "macro.dbt_utils.snowflake__safe_cast", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/safe_cast.sql", "original_file_path": "macros/cross_db_utils/safe_cast.sql", "name": "snowflake__safe_cast", "macro_sql": "{% macro snowflake__safe_cast(field, type) %}\n try_cast({{field}} as {{type}})\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.bigquery__safe_cast": {"unique_id": "macro.dbt_utils.bigquery__safe_cast", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/safe_cast.sql", "original_file_path": "macros/cross_db_utils/safe_cast.sql", "name": "bigquery__safe_cast", "macro_sql": "{% macro bigquery__safe_cast(field, type) %}\n safe_cast({{field}} as {{type}})\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.hash": {"unique_id": "macro.dbt_utils.hash", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/hash.sql", "original_file_path": "macros/cross_db_utils/hash.sql", "name": "hash", "macro_sql": "{% macro hash(field) -%}\n {{ return(adapter.dispatch('hash', packages = dbt_utils._get_utils_namespaces()) (field)) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__hash": {"unique_id": "macro.dbt_utils.default__hash", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/hash.sql", "original_file_path": "macros/cross_db_utils/hash.sql", "name": "default__hash", "macro_sql": "{% macro default__hash(field) -%}\n md5(cast({{field}} as {{dbt_utils.type_string()}}))\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.bigquery__hash": {"unique_id": "macro.dbt_utils.bigquery__hash", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/hash.sql", "original_file_path": "macros/cross_db_utils/hash.sql", "name": "bigquery__hash", "macro_sql": "{% macro bigquery__hash(field) -%}\n to_hex({{dbt_utils.default__hash(field)}})\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.identifier": {"unique_id": "macro.dbt_utils.identifier", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/identifier.sql", "original_file_path": "macros/cross_db_utils/identifier.sql", "name": "identifier", "macro_sql": "{% macro identifier(value) %}\t\n {%- set error_message = '\n Warning: the `identifier` macro is no longer supported and will be deprecated in a future release of dbt-utils. \\\n Use `adapter.quote` instead. The {}.{} model triggered this warning. \\\n '.format(model.package_name, model.name) -%}\n {%- do exceptions.warn(error_message) -%}\n {{ return(adapter.dispatch('identifier', packages = dbt_utils._get_utils_namespaces()) (value)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__identifier": {"unique_id": "macro.dbt_utils.default__identifier", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/identifier.sql", "original_file_path": "macros/cross_db_utils/identifier.sql", "name": "default__identifier", "macro_sql": "{% macro default__identifier(value) -%}\t\n \"{{ value }}\"\t\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.bigquery__identifier": {"unique_id": "macro.dbt_utils.bigquery__identifier", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/identifier.sql", "original_file_path": "macros/cross_db_utils/identifier.sql", "name": "bigquery__identifier", "macro_sql": "{% macro bigquery__identifier(value) -%}\t\n `{{ value }}`\t\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.position": {"unique_id": "macro.dbt_utils.position", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/position.sql", "original_file_path": "macros/cross_db_utils/position.sql", "name": "position", "macro_sql": "{% macro position(substring_text, string_text) -%}\n {{ return(adapter.dispatch('position', packages = dbt_utils._get_utils_namespaces()) (substring_text, string_text)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__position": {"unique_id": "macro.dbt_utils.default__position", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/position.sql", "original_file_path": "macros/cross_db_utils/position.sql", "name": "default__position", "macro_sql": "{% macro default__position(substring_text, string_text) %}\n\n position(\n {{ substring_text }} in {{ string_text }}\n )\n \n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.bigquery__position": {"unique_id": "macro.dbt_utils.bigquery__position", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/position.sql", "original_file_path": "macros/cross_db_utils/position.sql", "name": "bigquery__position", "macro_sql": "{% macro bigquery__position(substring_text, string_text) %}\n\n strpos(\n {{ string_text }},\n {{ substring_text }}\n \n )\n \n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.string_literal": {"unique_id": "macro.dbt_utils.string_literal", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/literal.sql", "original_file_path": "macros/cross_db_utils/literal.sql", "name": "string_literal", "macro_sql": "{%- macro string_literal(value) -%}\n {{ return(adapter.dispatch('string_literal', packages = dbt_utils._get_utils_namespaces()) (value)) }}\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__string_literal": {"unique_id": "macro.dbt_utils.default__string_literal", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/literal.sql", "original_file_path": "macros/cross_db_utils/literal.sql", "name": "default__string_literal", "macro_sql": "{% macro default__string_literal(value) -%}\n '{{ value }}'\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.current_timestamp": {"unique_id": "macro.dbt_utils.current_timestamp", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/current_timestamp.sql", "original_file_path": "macros/cross_db_utils/current_timestamp.sql", "name": "current_timestamp", "macro_sql": "{% macro current_timestamp() -%}\n {{ return(adapter.dispatch('current_timestamp', packages = dbt_utils._get_utils_namespaces())()) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__current_timestamp": {"unique_id": "macro.dbt_utils.default__current_timestamp", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/current_timestamp.sql", "original_file_path": "macros/cross_db_utils/current_timestamp.sql", "name": "default__current_timestamp", "macro_sql": "{% macro default__current_timestamp() %}\n current_timestamp::{{dbt_utils.type_timestamp()}}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.redshift__current_timestamp": {"unique_id": "macro.dbt_utils.redshift__current_timestamp", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/current_timestamp.sql", "original_file_path": "macros/cross_db_utils/current_timestamp.sql", "name": "redshift__current_timestamp", "macro_sql": "{% macro redshift__current_timestamp() %}\n getdate()\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.bigquery__current_timestamp": {"unique_id": "macro.dbt_utils.bigquery__current_timestamp", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/current_timestamp.sql", "original_file_path": "macros/cross_db_utils/current_timestamp.sql", "name": "bigquery__current_timestamp", "macro_sql": "{% macro bigquery__current_timestamp() %}\n current_timestamp\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.current_timestamp_in_utc": {"unique_id": "macro.dbt_utils.current_timestamp_in_utc", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/current_timestamp.sql", "original_file_path": "macros/cross_db_utils/current_timestamp.sql", "name": "current_timestamp_in_utc", "macro_sql": "{% macro current_timestamp_in_utc() -%}\n {{ return(adapter.dispatch('current_timestamp_in_utc', packages = dbt_utils._get_utils_namespaces())()) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__current_timestamp_in_utc": {"unique_id": "macro.dbt_utils.default__current_timestamp_in_utc", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/current_timestamp.sql", "original_file_path": "macros/cross_db_utils/current_timestamp.sql", "name": "default__current_timestamp_in_utc", "macro_sql": "{% macro default__current_timestamp_in_utc() %}\n {{dbt_utils.current_timestamp()}}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.snowflake__current_timestamp_in_utc": {"unique_id": "macro.dbt_utils.snowflake__current_timestamp_in_utc", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/current_timestamp.sql", "original_file_path": "macros/cross_db_utils/current_timestamp.sql", "name": "snowflake__current_timestamp_in_utc", "macro_sql": "{% macro snowflake__current_timestamp_in_utc() %}\n convert_timezone('UTC', {{dbt_utils.current_timestamp()}})::{{dbt_utils.type_timestamp()}}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.postgres__current_timestamp_in_utc": {"unique_id": "macro.dbt_utils.postgres__current_timestamp_in_utc", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/current_timestamp.sql", "original_file_path": "macros/cross_db_utils/current_timestamp.sql", "name": "postgres__current_timestamp_in_utc", "macro_sql": "{% macro postgres__current_timestamp_in_utc() %}\n (current_timestamp at time zone 'utc')::{{dbt_utils.type_timestamp()}}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.width_bucket": {"unique_id": "macro.dbt_utils.width_bucket", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/width_bucket.sql", "original_file_path": "macros/cross_db_utils/width_bucket.sql", "name": "width_bucket", "macro_sql": "{% macro width_bucket(expr, min_value, max_value, num_buckets) %}\n {{ return(adapter.dispatch('width_bucket', packages = dbt_utils._get_utils_namespaces()) (expr, min_value, max_value, num_buckets)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__width_bucket": {"unique_id": "macro.dbt_utils.default__width_bucket", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/width_bucket.sql", "original_file_path": "macros/cross_db_utils/width_bucket.sql", "name": "default__width_bucket", "macro_sql": "{% macro default__width_bucket(expr, min_value, max_value, num_buckets) -%}\n\n {% set bin_size -%}\n (( {{ max_value }} - {{ min_value }} ) / {{ num_buckets }} )\n {%- endset %}\n (\n -- to break ties when the amount is eaxtly at the bucket egde\n case\n when\n mod(\n {{ dbt_utils.safe_cast(expr, dbt_utils.type_numeric() ) }},\n {{ dbt_utils.safe_cast(bin_size, dbt_utils.type_numeric() ) }}\n ) = 0\n then 1\n else 0\n end\n ) +\n -- Anything over max_value goes the N+1 bucket\n least(\n ceil(\n ({{ expr }} - {{ min_value }})/{{ bin_size }}\n ),\n {{ num_buckets }} + 1\n )\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.redshift__width_bucket": {"unique_id": "macro.dbt_utils.redshift__width_bucket", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/width_bucket.sql", "original_file_path": "macros/cross_db_utils/width_bucket.sql", "name": "redshift__width_bucket", "macro_sql": "{% macro redshift__width_bucket(expr, min_value, max_value, num_buckets) -%}\n\n {% set bin_size -%}\n (( {{ max_value }} - {{ min_value }} ) / {{ num_buckets }} )\n {%- endset %}\n (\n -- to break ties when the amount is exactly at the bucket edge\n case\n when\n {{ dbt_utils.safe_cast(expr, dbt_utils.type_numeric() ) }} %\n {{ dbt_utils.safe_cast(bin_size, dbt_utils.type_numeric() ) }}\n = 0\n then 1\n else 0\n end\n ) +\n -- Anything over max_value goes the N+1 bucket\n least(\n ceil(\n ({{ expr }} - {{ min_value }})/{{ bin_size }}\n ),\n {{ num_buckets }} + 1\n )\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.snowflake__width_bucket": {"unique_id": "macro.dbt_utils.snowflake__width_bucket", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/width_bucket.sql", "original_file_path": "macros/cross_db_utils/width_bucket.sql", "name": "snowflake__width_bucket", "macro_sql": "{% macro snowflake__width_bucket(expr, min_value, max_value, num_buckets) %}\n width_bucket({{ expr }}, {{ min_value }}, {{ max_value }}, {{ num_buckets }} )\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils._get_utils_namespaces": {"unique_id": "macro.dbt_utils._get_utils_namespaces", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/_get_utils_namespaces.sql", "original_file_path": "macros/cross_db_utils/_get_utils_namespaces.sql", "name": "_get_utils_namespaces", "macro_sql": "{% macro _get_utils_namespaces() %}\n {% set override_namespaces = var('dbt_utils_dispatch_list', []) %}\n {% do return(override_namespaces + ['dbt_utils']) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.last_day": {"unique_id": "macro.dbt_utils.last_day", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/last_day.sql", "original_file_path": "macros/cross_db_utils/last_day.sql", "name": "last_day", "macro_sql": "{% macro last_day(date, datepart) %}\n {{ return(adapter.dispatch('last_day', packages = dbt_utils._get_utils_namespaces()) (date, datepart)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default_last_day": {"unique_id": "macro.dbt_utils.default_last_day", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/last_day.sql", "original_file_path": "macros/cross_db_utils/last_day.sql", "name": "default_last_day", "macro_sql": "\n\n\n{%- macro default_last_day(date, datepart) -%}\n cast(\n {{dbt_utils.dateadd('day', '-1',\n dbt_utils.dateadd(datepart, '1', dbt_utils.date_trunc(datepart, date))\n )}}\n as date)\n{%- endmacro -%}\n\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__last_day": {"unique_id": "macro.dbt_utils.default__last_day", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/last_day.sql", "original_file_path": "macros/cross_db_utils/last_day.sql", "name": "default__last_day", "macro_sql": "{% macro default__last_day(date, datepart) -%}\n {{dbt_utils.default_last_day(date, datepart)}}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.postgres__last_day": {"unique_id": "macro.dbt_utils.postgres__last_day", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/last_day.sql", "original_file_path": "macros/cross_db_utils/last_day.sql", "name": "postgres__last_day", "macro_sql": "{% macro postgres__last_day(date, datepart) -%}\n\n {%- if datepart == 'quarter' -%}\n {{ exceptions.raise_compiler_error(\n \"dbt_utils.last_day is not supported for datepart 'quarter' on this adapter\") }}\n {%- else -%}\n {{dbt_utils.default_last_day(date, datepart)}}\n {%- endif -%}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.split_part": {"unique_id": "macro.dbt_utils.split_part", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/split_part.sql", "original_file_path": "macros/cross_db_utils/split_part.sql", "name": "split_part", "macro_sql": "{% macro split_part(string_text, delimiter_text, part_number) %}\n {{ return(adapter.dispatch('split_part', packages = dbt_utils._get_utils_namespaces()) (string_text, delimiter_text, part_number)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__split_part": {"unique_id": "macro.dbt_utils.default__split_part", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/split_part.sql", "original_file_path": "macros/cross_db_utils/split_part.sql", "name": "default__split_part", "macro_sql": "{% macro default__split_part(string_text, delimiter_text, part_number) %}\n\n split_part(\n {{ string_text }},\n {{ delimiter_text }},\n {{ part_number }}\n )\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.bigquery__split_part": {"unique_id": "macro.dbt_utils.bigquery__split_part", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/split_part.sql", "original_file_path": "macros/cross_db_utils/split_part.sql", "name": "bigquery__split_part", "macro_sql": "{% macro bigquery__split_part(string_text, delimiter_text, part_number) %}\n\n split(\n {{ string_text }},\n {{ delimiter_text }}\n )[safe_offset({{ part_number - 1 }})]\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.date_trunc": {"unique_id": "macro.dbt_utils.date_trunc", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/date_trunc.sql", "original_file_path": "macros/cross_db_utils/date_trunc.sql", "name": "date_trunc", "macro_sql": "{% macro date_trunc(datepart, date) -%}\n {{ return(adapter.dispatch('date_trunc', packages = dbt_utils._get_utils_namespaces()) (datepart, date)) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__date_trunc": {"unique_id": "macro.dbt_utils.default__date_trunc", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/date_trunc.sql", "original_file_path": "macros/cross_db_utils/date_trunc.sql", "name": "default__date_trunc", "macro_sql": "{% macro default__date_trunc(datepart, date) %}\n date_trunc('{{datepart}}', {{date}})\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.bigquery__date_trunc": {"unique_id": "macro.dbt_utils.bigquery__date_trunc", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/date_trunc.sql", "original_file_path": "macros/cross_db_utils/date_trunc.sql", "name": "bigquery__date_trunc", "macro_sql": "{% macro bigquery__date_trunc(datepart, date) %}\n timestamp_trunc(\n cast({{date}} as timestamp),\n {{datepart}}\n )\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils._is_ephemeral": {"unique_id": "macro.dbt_utils._is_ephemeral", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/cross_db_utils/_is_ephemeral.sql", "original_file_path": "macros/cross_db_utils/_is_ephemeral.sql", "name": "_is_ephemeral", "macro_sql": "{% macro _is_ephemeral(obj, macro) %}\n {%- if obj.is_cte -%}\n {% set ephemeral_prefix = api.Relation.add_ephemeral_prefix('') %}\n {% if obj.name.startswith(ephemeral_prefix) %}\n {% set model_name = obj.name[(ephemeral_prefix|length):] %}\n {% else %}\n {% set model_name = obj.name %}\n {%- endif -%}\n {% set error_message %}\nThe `{{ macro }}` macro cannot be used with ephemeral models, as it relies on the information schema.\n\n`{{ model_name }}` is an ephemeral model. Consider making it a view or table instead.\n {% endset %}\n {%- do exceptions.raise_compiler_error(error_message) -%}\n {%- endif -%}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.get_period_boundaries": {"unique_id": "macro.dbt_utils.get_period_boundaries", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/materializations/insert_by_period_materialization.sql", "original_file_path": "macros/materializations/insert_by_period_materialization.sql", "name": "get_period_boundaries", "macro_sql": "{% macro get_period_boundaries(target_schema, target_table, timestamp_field, start_date, stop_date, period) -%}\n {{ return(adapter.dispatch('get_period_boundaries', packages = dbt_utils._get_utils_namespaces())(target_schema, target_table, timestamp_field, start_date, stop_date, period)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__get_period_boundaries": {"unique_id": "macro.dbt_utils.default__get_period_boundaries", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/materializations/insert_by_period_materialization.sql", "original_file_path": "macros/materializations/insert_by_period_materialization.sql", "name": "default__get_period_boundaries", "macro_sql": "{% macro default__get_period_boundaries(target_schema, target_table, timestamp_field, start_date, stop_date, period) -%}\n\n {% call statement('period_boundaries', fetch_result=True) -%}\n with data as (\n select\n coalesce(max(\"{{timestamp_field}}\"), '{{start_date}}')::timestamp as start_timestamp,\n coalesce(\n {{dbt_utils.dateadd('millisecond',\n -1,\n \"nullif('\" ~ stop_date ~ \"','')::timestamp\")}},\n {{dbt_utils.current_timestamp()}}\n ) as stop_timestamp\n from \"{{target_schema}}\".\"{{target_table}}\"\n )\n\n select\n start_timestamp,\n stop_timestamp,\n {{dbt_utils.datediff('start_timestamp',\n 'stop_timestamp',\n period)}} + 1 as num_periods\n from data\n {%- endcall %}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.get_period_sql": {"unique_id": "macro.dbt_utils.get_period_sql", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/materializations/insert_by_period_materialization.sql", "original_file_path": "macros/materializations/insert_by_period_materialization.sql", "name": "get_period_sql", "macro_sql": "{% macro get_period_sql(target_cols_csv, sql, timestamp_field, period, start_timestamp, stop_timestamp, offset) -%}\n {{ return(adapter.dispatch('get_period_sql', packages = dbt_utils._get_utils_namespaces())(target_cols_csv, sql, timestamp_field, period, start_timestamp, stop_timestamp, offset)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__get_period_sql": {"unique_id": "macro.dbt_utils.default__get_period_sql", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/materializations/insert_by_period_materialization.sql", "original_file_path": "macros/materializations/insert_by_period_materialization.sql", "name": "default__get_period_sql", "macro_sql": "{% macro default__get_period_sql(target_cols_csv, sql, timestamp_field, period, start_timestamp, stop_timestamp, offset) -%}\n\n {%- set period_filter -%}\n (\"{{timestamp_field}}\" > '{{start_timestamp}}'::timestamp + interval '{{offset}} {{period}}' and\n \"{{timestamp_field}}\" <= '{{start_timestamp}}'::timestamp + interval '{{offset}} {{period}}' + interval '1 {{period}}' and\n \"{{timestamp_field}}\" < '{{stop_timestamp}}'::timestamp)\n {%- endset -%}\n\n {%- set filtered_sql = sql | replace(\"__PERIOD_FILTER__\", period_filter) -%}\n\n select\n {{target_cols_csv}}\n from (\n {{filtered_sql}}\n )\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.materialization_insert_by_period_default": {"unique_id": "macro.dbt_utils.materialization_insert_by_period_default", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/materializations/insert_by_period_materialization.sql", "original_file_path": "macros/materializations/insert_by_period_materialization.sql", "name": "materialization_insert_by_period_default", "macro_sql": "{% materialization insert_by_period, default -%}\n {%- set timestamp_field = config.require('timestamp_field') -%}\n {%- set start_date = config.require('start_date') -%}\n {%- set stop_date = config.get('stop_date') or '' -%}}\n {%- set period = config.get('period') or 'week' -%}\n\n {%- if sql.find('__PERIOD_FILTER__') == -1 -%}\n {%- set error_message -%}\n Model '{{ model.unique_id }}' does not include the required string '__PERIOD_FILTER__' in its sql\n {%- endset -%}\n {{ exceptions.raise_compiler_error(error_message) }}\n {%- endif -%}\n\n {%- set identifier = model['name'] -%}\n\n {%- set old_relation = adapter.get_relation(database=database, schema=schema, identifier=identifier) -%}\n {%- set target_relation = api.Relation.create(identifier=identifier, schema=schema, type='table') -%}\n\n {%- set non_destructive_mode = (flags.NON_DESTRUCTIVE == True) -%}\n {%- set full_refresh_mode = (flags.FULL_REFRESH == True) -%}\n\n {%- set exists_as_table = (old_relation is not none and old_relation.is_table) -%}\n {%- set exists_not_as_table = (old_relation is not none and not old_relation.is_table) -%}\n\n {%- set should_truncate = (non_destructive_mode and full_refresh_mode and exists_as_table) -%}\n {%- set should_drop = (not should_truncate and (full_refresh_mode or exists_not_as_table)) -%}\n {%- set force_create = (flags.FULL_REFRESH and not flags.NON_DESTRUCTIVE) -%}\n\n -- setup\n {% if old_relation is none -%}\n -- noop\n {%- elif should_truncate -%}\n {{adapter.truncate_relation(old_relation)}}\n {%- elif should_drop -%}\n {{adapter.drop_relation(old_relation)}}\n {%- set old_relation = none -%}\n {%- endif %}\n\n {{run_hooks(pre_hooks, inside_transaction=False)}}\n\n -- `begin` happens here, so `commit` after it to finish the transaction\n {{run_hooks(pre_hooks, inside_transaction=True)}}\n {% call statement() -%}\n begin; -- make extra sure we've closed out the transaction\n commit;\n {%- endcall %}\n\n -- build model\n {% if force_create or old_relation is none -%}\n {# Create an empty target table -#}\n {% call statement('main') -%}\n {%- set empty_sql = sql | replace(\"__PERIOD_FILTER__\", 'false') -%}\n {{create_table_as(False, target_relation, empty_sql)}};\n {%- endcall %}\n {%- endif %}\n\n {% set _ = dbt_utils.get_period_boundaries(schema,\n identifier,\n timestamp_field,\n start_date,\n stop_date,\n period) %}\n {%- set start_timestamp = load_result('period_boundaries')['data'][0][0] | string -%}\n {%- set stop_timestamp = load_result('period_boundaries')['data'][0][1] | string -%}\n {%- set num_periods = load_result('period_boundaries')['data'][0][2] | int -%}\n\n {% set target_columns = adapter.get_columns_in_relation(target_relation) %}\n {%- set target_cols_csv = target_columns | map(attribute='quoted') | join(', ') -%}\n {%- set loop_vars = {'sum_rows_inserted': 0} -%}\n\n -- commit each period as a separate transaction\n {% for i in range(num_periods) -%}\n {%- set msg = \"Running for \" ~ period ~ \" \" ~ (i + 1) ~ \" of \" ~ (num_periods) -%}\n {{ dbt_utils.log_info(msg) }}\n\n {%- set tmp_identifier = model['name'] ~ '__dbt_incremental_period' ~ i ~ '_tmp' -%}\n {%- set tmp_relation = api.Relation.create(identifier=tmp_identifier,\n schema=schema, type='table') -%}\n {% call statement() -%}\n {% set tmp_table_sql = dbt_utils.get_period_sql(target_cols_csv,\n sql,\n timestamp_field,\n period,\n start_timestamp,\n stop_timestamp,\n i) %}\n {{dbt.create_table_as(True, tmp_relation, tmp_table_sql)}}\n {%- endcall %}\n\n {{adapter.expand_target_column_types(from_relation=tmp_relation,\n to_relation=target_relation)}}\n {%- set name = 'main-' ~ i -%}\n {% call statement(name, fetch_result=True) -%}\n insert into {{target_relation}} ({{target_cols_csv}})\n (\n select\n {{target_cols_csv}}\n from {{tmp_relation.include(schema=False)}}\n );\n {%- endcall %}\n {% set result = load_result('main-' ~ i) %}\n {% if 'response' in result.keys() %} {# added in v0.19.0 #}\n {% set rows_inserted = result['response']['rows_affected'] %}\n {% else %} {# older versions #}\n {% set rows_inserted = result['status'].split(\" \")[2] | int %}\n {% endif %}\n \n {%- set sum_rows_inserted = loop_vars['sum_rows_inserted'] + rows_inserted -%}\n {%- if loop_vars.update({'sum_rows_inserted': sum_rows_inserted}) %} {% endif -%}\n\n {%- set msg = \"Ran for \" ~ period ~ \" \" ~ (i + 1) ~ \" of \" ~ (num_periods) ~ \"; \" ~ rows_inserted ~ \" records inserted\" -%}\n {{ dbt_utils.log_info(msg) }}\n\n {%- endfor %}\n\n {% call statement() -%}\n begin;\n {%- endcall %}\n\n {{run_hooks(post_hooks, inside_transaction=True)}}\n\n {% call statement() -%}\n commit;\n {%- endcall %}\n\n {{run_hooks(post_hooks, inside_transaction=False)}}\n\n {%- set status_string = \"INSERT \" ~ loop_vars['sum_rows_inserted'] -%}\n\n {% call noop_statement('main', status_string) -%}\n -- no-op\n {%- endcall %}\n\n -- Return the relations created in this materialization\n {{ return({'relations': [target_relation]}) }} \n\n{%- endmaterialization %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.pretty_log_format": {"unique_id": "macro.dbt_utils.pretty_log_format", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/logger/pretty_log_format.sql", "original_file_path": "macros/logger/pretty_log_format.sql", "name": "pretty_log_format", "macro_sql": "{% macro pretty_log_format(message) %}\n {{ return(adapter.dispatch('pretty_log_format', packages = dbt_utils._get_utils_namespaces())(message)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__pretty_log_format": {"unique_id": "macro.dbt_utils.default__pretty_log_format", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/logger/pretty_log_format.sql", "original_file_path": "macros/logger/pretty_log_format.sql", "name": "default__pretty_log_format", "macro_sql": "{% macro default__pretty_log_format(message) %}\n {{ return( dbt_utils.pretty_time() ~ ' + ' ~ message) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.pretty_time": {"unique_id": "macro.dbt_utils.pretty_time", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/logger/pretty_time.sql", "original_file_path": "macros/logger/pretty_time.sql", "name": "pretty_time", "macro_sql": "{% macro pretty_time(format='%H:%M:%S') %}\n {{ return(adapter.dispatch('pretty_time', packages = dbt_utils._get_utils_namespaces())(format)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__pretty_time": {"unique_id": "macro.dbt_utils.default__pretty_time", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/logger/pretty_time.sql", "original_file_path": "macros/logger/pretty_time.sql", "name": "default__pretty_time", "macro_sql": "{% macro default__pretty_time(format='%H:%M:%S') %}\n {{ return(modules.datetime.datetime.now().strftime(format)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.log_info": {"unique_id": "macro.dbt_utils.log_info", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/logger/log_info.sql", "original_file_path": "macros/logger/log_info.sql", "name": "log_info", "macro_sql": "{% macro log_info(message) %}\n {{ return(adapter.dispatch('log_info', packages = dbt_utils._get_utils_namespaces())(message)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__log_info": {"unique_id": "macro.dbt_utils.default__log_info", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/logger/log_info.sql", "original_file_path": "macros/logger/log_info.sql", "name": "default__log_info", "macro_sql": "{% macro default__log_info(message) %}\n {{ log(dbt_utils.pretty_log_format(message), info=True) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.get_intervals_between": {"unique_id": "macro.dbt_utils.get_intervals_between", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/datetime/date_spine.sql", "original_file_path": "macros/datetime/date_spine.sql", "name": "get_intervals_between", "macro_sql": "{% macro get_intervals_between(start_date, end_date, datepart) -%}\n {{ return(adapter.dispatch('get_intervals_between', packages = dbt_utils._get_utils_namespaces())(start_date, end_date, datepart)) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__get_intervals_between": {"unique_id": "macro.dbt_utils.default__get_intervals_between", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/datetime/date_spine.sql", "original_file_path": "macros/datetime/date_spine.sql", "name": "default__get_intervals_between", "macro_sql": "{% macro default__get_intervals_between(start_date, end_date, datepart) -%}\n {%- call statement('get_intervals_between', fetch_result=True) %}\n\n select {{dbt_utils.datediff(start_date, end_date, datepart)}}\n\n {%- endcall -%}\n\n {%- set value_list = load_result('get_intervals_between') -%}\n\n {%- if value_list and value_list['data'] -%}\n {%- set values = value_list['data'] | map(attribute=0) | list %}\n {{ return(values[0]) }}\n {%- else -%}\n {{ return(1) }}\n {%- endif -%}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.date_spine": {"unique_id": "macro.dbt_utils.date_spine", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/datetime/date_spine.sql", "original_file_path": "macros/datetime/date_spine.sql", "name": "date_spine", "macro_sql": "{% macro date_spine(datepart, start_date, end_date) %}\n {{ return(adapter.dispatch('date_spine', packages = dbt_utils._get_utils_namespaces())(datepart, start_date, end_date)) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__date_spine": {"unique_id": "macro.dbt_utils.default__date_spine", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/datetime/date_spine.sql", "original_file_path": "macros/datetime/date_spine.sql", "name": "default__date_spine", "macro_sql": "{% macro default__date_spine(datepart, start_date, end_date) %}\n\n/*\ncall as follows:\n\ndate_spine(\n \"day\",\n \"to_date('01/01/2016', 'mm/dd/yyyy')\",\n \"dateadd(week, 1, current_date)\"\n)\n\n*/\n\nwith rawdata as (\n\n {{dbt_utils.generate_series(\n dbt_utils.get_intervals_between(start_date, end_date, datepart)\n )}}\n\n),\n\nall_periods as (\n\n select (\n {{\n dbt_utils.dateadd(\n datepart,\n \"row_number() over (order by 1) - 1\",\n start_date\n )\n }}\n ) as date_{{datepart}}\n from rawdata\n\n),\n\nfiltered as (\n\n select *\n from all_periods\n where date_{{datepart}} <= {{ end_date }}\n\n)\n\nselect * from filtered\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.get_url_host": {"unique_id": "macro.dbt_utils.get_url_host", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/web/get_url_host.sql", "original_file_path": "macros/web/get_url_host.sql", "name": "get_url_host", "macro_sql": "{% macro get_url_host(field) -%}\n {{ return(adapter.dispatch('get_url_host', packages = dbt_utils._get_utils_namespaces())(field)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__get_url_host": {"unique_id": "macro.dbt_utils.default__get_url_host", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/web/get_url_host.sql", "original_file_path": "macros/web/get_url_host.sql", "name": "default__get_url_host", "macro_sql": "{% macro default__get_url_host(field) -%}\n\n{%- set parsed = \n dbt_utils.split_part(\n dbt_utils.split_part(\n dbt_utils.replace(\n dbt_utils.replace(field, \"'http://'\", \"''\"\n ), \"'https://'\", \"''\"\n ), \"'/'\", 1\n ), \"'?'\", 1\n )\n \n-%}\n\n \n {{ dbt_utils.safe_cast(\n parsed,\n dbt_utils.type_string()\n )}}\n \n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.get_url_path": {"unique_id": "macro.dbt_utils.get_url_path", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/web/get_url_path.sql", "original_file_path": "macros/web/get_url_path.sql", "name": "get_url_path", "macro_sql": "{% macro get_url_path(field) -%}\n {{ return(adapter.dispatch('get_url_path', packages = dbt_utils._get_utils_namespaces())(field)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__get_url_path": {"unique_id": "macro.dbt_utils.default__get_url_path", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/web/get_url_path.sql", "original_file_path": "macros/web/get_url_path.sql", "name": "default__get_url_path", "macro_sql": "{% macro default__get_url_path(field) -%}\n\n {%- set stripped_url = \n dbt_utils.replace(\n dbt_utils.replace(field, \"'http://'\", \"''\"), \"'https://'\", \"''\")\n -%}\n\n {%- set first_slash_pos -%}\n coalesce(\n nullif({{dbt_utils.position(\"'/'\", stripped_url)}}, 0),\n {{dbt_utils.position(\"'?'\", stripped_url)}} - 1\n )\n {%- endset -%}\n\n {%- set parsed_path =\n dbt_utils.split_part(\n dbt_utils.right(\n stripped_url, \n dbt_utils.length(stripped_url) ~ \"-\" ~ first_slash_pos\n ), \n \"'?'\", 1\n )\n -%}\n\n {{ dbt_utils.safe_cast(\n parsed_path,\n dbt_utils.type_string()\n )}}\n \n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.get_url_parameter": {"unique_id": "macro.dbt_utils.get_url_parameter", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/web/get_url_parameter.sql", "original_file_path": "macros/web/get_url_parameter.sql", "name": "get_url_parameter", "macro_sql": "{% macro get_url_parameter(field, url_parameter) -%}\n {{ return(adapter.dispatch('get_url_parameter', packages = dbt_utils._get_utils_namespaces())(field, url_parameter)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__get_url_parameter": {"unique_id": "macro.dbt_utils.default__get_url_parameter", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/web/get_url_parameter.sql", "original_file_path": "macros/web/get_url_parameter.sql", "name": "default__get_url_parameter", "macro_sql": "{% macro default__get_url_parameter(field, url_parameter) -%}\n\n{%- set formatted_url_parameter = \"'\" + url_parameter + \"='\" -%}\n\n{%- set split = dbt_utils.split_part(dbt_utils.split_part(field, formatted_url_parameter, 2), \"'&'\", 1) -%}\n\nnullif({{ split }},'')\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.haversine_distance": {"unique_id": "macro.dbt_utils.haversine_distance", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/geo/haversine_distance.sql", "original_file_path": "macros/geo/haversine_distance.sql", "name": "haversine_distance", "macro_sql": "{% macro haversine_distance(lat1,lon1,lat2,lon2) -%}\n {{ return(adapter.dispatch('haversine_distance', packages = dbt_utils._get_utils_namespaces())(lat1,lon1,lat2,lon2)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__haversine_distance": {"unique_id": "macro.dbt_utils.default__haversine_distance", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/geo/haversine_distance.sql", "original_file_path": "macros/geo/haversine_distance.sql", "name": "default__haversine_distance", "macro_sql": "{% macro default__haversine_distance(lat1,lon1,lat2,lon2) -%}\n\n 2 * 3961 * asin(sqrt((sin(radians(({{lat2}} - {{lat1}}) / 2))) ^ 2 +\n cos(radians({{lat1}})) * cos(radians({{lat2}})) *\n (sin(radians(({{lon2}} - {{lon1}}) / 2))) ^ 2))\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.test_equal_rowcount": {"unique_id": "macro.dbt_utils.test_equal_rowcount", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/schema_tests/equal_rowcount.sql", "original_file_path": "macros/schema_tests/equal_rowcount.sql", "name": "test_equal_rowcount", "macro_sql": "{% macro test_equal_rowcount(model) %}\n {{ return(adapter.dispatch('test_equal_rowcount', packages = dbt_utils._get_utils_namespaces())(model, **kwargs)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__test_equal_rowcount": {"unique_id": "macro.dbt_utils.default__test_equal_rowcount", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/schema_tests/equal_rowcount.sql", "original_file_path": "macros/schema_tests/equal_rowcount.sql", "name": "default__test_equal_rowcount", "macro_sql": "{% macro default__test_equal_rowcount(model) %}\n\n{% set compare_model = kwargs.get('compare_model', kwargs.get('arg')) %}\n\n{#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\n{%- if not execute -%}\n {{ return('') }}\n{% endif %}\n\nwith a as (\n\n select count(*) as count_a from {{ model }}\n\n),\nb as (\n\n select count(*) as count_b from {{ compare_model }}\n\n),\nfinal as (\n\n select abs(\n (select count_a from a) -\n (select count_b from b)\n )\n as diff_count\n\n)\n\nselect diff_count from final\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.test_relationships_where": {"unique_id": "macro.dbt_utils.test_relationships_where", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/schema_tests/relationships_where.sql", "original_file_path": "macros/schema_tests/relationships_where.sql", "name": "test_relationships_where", "macro_sql": "{% macro test_relationships_where(model, to, field) %}\n {{ return(adapter.dispatch('test_relationships_where', packages = dbt_utils._get_utils_namespaces())(model, to, field, **kwargs)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__test_relationships_where": {"unique_id": "macro.dbt_utils.default__test_relationships_where", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/schema_tests/relationships_where.sql", "original_file_path": "macros/schema_tests/relationships_where.sql", "name": "default__test_relationships_where", "macro_sql": "{% macro default__test_relationships_where(model, to, field) %}\n\n{% set column_name = kwargs.get('column_name', kwargs.get('from')) %}\n{# T-SQL has no boolean data type so we use 1=1 which returns TRUE #}\n{# ref https://stackoverflow.com/a/7170753/3842610 #}\n{% set from_condition = kwargs.get('from_condition', \"1=1\") %}\n{% set to_condition = kwargs.get('to_condition', \"1=1\") %}\n\nwith left_table as (\n\n select\n {{column_name}} as id\n\n from {{model}}\n\n where {{column_name}} is not null\n and {{from_condition}}\n\n),\n\nright_table as (\n\n select\n {{field}} as id\n\n from {{to}}\n\n where {{field}} is not null\n and {{to_condition}}\n\n),\n\nexceptions as (\n\n select\n left_table.id,\n right_table.id as right_id\n\n from left_table\n\n left join right_table\n on left_table.id = right_table.id\n\n where right_table.id is null\n\n)\n\nselect count(*) from exceptions\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.test_recency": {"unique_id": "macro.dbt_utils.test_recency", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/schema_tests/recency.sql", "original_file_path": "macros/schema_tests/recency.sql", "name": "test_recency", "macro_sql": "{% macro test_recency(model, datepart, interval) %}\n {{ return(adapter.dispatch('test_recency', packages = dbt_utils._get_utils_namespaces())(model, datepart, interval, **kwargs)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__test_recency": {"unique_id": "macro.dbt_utils.default__test_recency", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/schema_tests/recency.sql", "original_file_path": "macros/schema_tests/recency.sql", "name": "default__test_recency", "macro_sql": "{% macro default__test_recency(model, datepart, interval) %}\n\n{% set column_name = kwargs.get('column_name', kwargs.get('field')) %}\n\nselect\n case when count(*) > 0 then 0\n else 1\n end as error_result\nfrom {{model}}\nwhere {{column_name}} >=\n {{dbt_utils.dateadd(datepart, interval * -1, dbt_utils.current_timestamp())}}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.test_not_constant": {"unique_id": "macro.dbt_utils.test_not_constant", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/schema_tests/not_constant.sql", "original_file_path": "macros/schema_tests/not_constant.sql", "name": "test_not_constant", "macro_sql": "{% macro test_not_constant(model) %}\n {{ return(adapter.dispatch('test_not_constant', packages = dbt_utils._get_utils_namespaces())(model, **kwargs)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__test_not_constant": {"unique_id": "macro.dbt_utils.default__test_not_constant", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/schema_tests/not_constant.sql", "original_file_path": "macros/schema_tests/not_constant.sql", "name": "default__test_not_constant", "macro_sql": "{% macro default__test_not_constant(model) %}\n\n{% set column_name = kwargs.get('column_name', kwargs.get('arg')) %}\n\nselect count(*)\n\nfrom (\n\n select\n {# In TSQL, subquery aggregate columns need aliases #}\n {# thus: a filler col name, 'filler_column' #}\n count(distinct {{ column_name }}) as filler_column\n\n from {{ model }}\n\n having count(distinct {{ column_name }}) = 1\n\n ) validation_errors\n\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.test_unique_where": {"unique_id": "macro.dbt_utils.test_unique_where", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/schema_tests/test_unique_where.sql", "original_file_path": "macros/schema_tests/test_unique_where.sql", "name": "test_unique_where", "macro_sql": "{% macro test_unique_where(model) %}\r\n {{ return(adapter.dispatch('test_unique_where', packages = dbt_utils._get_utils_namespaces())(model, **kwargs)) }}\r\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__test_unique_where": {"unique_id": "macro.dbt_utils.default__test_unique_where", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/schema_tests/test_unique_where.sql", "original_file_path": "macros/schema_tests/test_unique_where.sql", "name": "default__test_unique_where", "macro_sql": "{% macro default__test_unique_where(model) %}\r\n\r\n{% set column_name = kwargs.get('column_name', kwargs.get('arg')) %}\r\n{% set where = kwargs.get('where', kwargs.get('arg')) %}\r\n\r\nselect count(*)\r\nfrom (\r\n\r\n select\r\n {{ column_name }}\r\n\r\n from {{ model }}\r\n where {{ column_name }} is not null\r\n {% if where %} and {{ where }} {% endif %}\r\n group by {{ column_name }}\r\n having count(*) > 1\r\n\r\n) validation_errors\r\n\r\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.test_at_least_one": {"unique_id": "macro.dbt_utils.test_at_least_one", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/schema_tests/at_least_one.sql", "original_file_path": "macros/schema_tests/at_least_one.sql", "name": "test_at_least_one", "macro_sql": "{% macro test_at_least_one(model) %}\n {{ return(adapter.dispatch('test_at_least_one', packages = dbt_utils._get_utils_namespaces())(model, **kwargs)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__test_at_least_one": {"unique_id": "macro.dbt_utils.default__test_at_least_one", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/schema_tests/at_least_one.sql", "original_file_path": "macros/schema_tests/at_least_one.sql", "name": "default__test_at_least_one", "macro_sql": "{% macro default__test_at_least_one(model) %}\n\n{% set column_name = kwargs.get('column_name', kwargs.get('arg')) %}\n\nselect count(*)\nfrom (\n select\n {# In TSQL, subquery aggregate columns need aliases #}\n {# thus: a filler col name, 'filler_column' #}\n count({{ column_name }}) as filler_column\n\n from {{ model }}\n\n having count({{ column_name }}) = 0\n\n) validation_errors\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.test_unique_combination_of_columns": {"unique_id": "macro.dbt_utils.test_unique_combination_of_columns", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/schema_tests/unique_combination_of_columns.sql", "original_file_path": "macros/schema_tests/unique_combination_of_columns.sql", "name": "test_unique_combination_of_columns", "macro_sql": "{% macro test_unique_combination_of_columns(model, quote_columns = false) %}\n {{ return(adapter.dispatch('test_unique_combination_of_columns', packages = dbt_utils._get_utils_namespaces())(model, quote_columns, **kwargs)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__test_unique_combination_of_columns": {"unique_id": "macro.dbt_utils.default__test_unique_combination_of_columns", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/schema_tests/unique_combination_of_columns.sql", "original_file_path": "macros/schema_tests/unique_combination_of_columns.sql", "name": "default__test_unique_combination_of_columns", "macro_sql": "{% macro default__test_unique_combination_of_columns(model, quote_columns = false) %}\n\n{%- set columns = kwargs.get('combination_of_columns', kwargs.get('arg')) %}\n\n{% if not quote_columns %}\n {%- set column_list=columns %}\n{% elif quote_columns %}\n {%- set column_list=[] %}\n {% for column in columns -%}\n {% set column_list = column_list.append( adapter.quote(column) ) %}\n {%- endfor %}\n{% else %}\n {{ exceptions.raise_compiler_error(\n \"`quote_columns` argument for unique_combination_of_columns test must be one of [True, False] Got: '\" ~ quote ~\"'.'\"\n ) }}\n{% endif %}\n\n{%- set columns_csv=column_list | join(', ') %}\n\n\nwith validation_errors as (\n\n select\n {{ columns_csv }}\n from {{ model }}\n\n group by {{ columns_csv }}\n having count(*) > 1\n\n)\n\nselect count(*)\nfrom validation_errors\n\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.test_cardinality_equality": {"unique_id": "macro.dbt_utils.test_cardinality_equality", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/schema_tests/cardinality_equality.sql", "original_file_path": "macros/schema_tests/cardinality_equality.sql", "name": "test_cardinality_equality", "macro_sql": "{% macro test_cardinality_equality(model, to, field) %}\n\n {{ return(adapter.dispatch('test_cardinality_equality', packages = dbt_utils._get_utils_namespaces())(model, to, field, **kwargs)) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__test_cardinality_equality": {"unique_id": "macro.dbt_utils.default__test_cardinality_equality", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/schema_tests/cardinality_equality.sql", "original_file_path": "macros/schema_tests/cardinality_equality.sql", "name": "default__test_cardinality_equality", "macro_sql": "{% macro default__test_cardinality_equality(model, to, field) %}\n\n{# T-SQL doesn't let you use numbers as aliases for columns #}\n{# Thus, no \"GROUP BY 1\" #}\n\n{% set column_name = kwargs.get('column_name', kwargs.get('from')) %}\n\n\nwith table_a as (\nselect\n {{ column_name }},\n count(*) as num_rows\nfrom {{ model }}\ngroup by {{ column_name }}\n),\n\ntable_b as (\nselect\n {{ field }},\n count(*) as num_rows\nfrom {{ to }}\ngroup by {{ column_name }}\n),\n\nexcept_a as (\n select *\n from table_a\n {{ dbt_utils.except() }}\n select *\n from table_b\n),\n\nexcept_b as (\n select *\n from table_b\n {{ dbt_utils.except() }}\n select *\n from table_a\n),\n\nunioned as (\n select *\n from except_a\n union all\n select *\n from except_b\n)\n\nselect count(*)\nfrom unioned\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.test_expression_is_true": {"unique_id": "macro.dbt_utils.test_expression_is_true", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/schema_tests/expression_is_true.sql", "original_file_path": "macros/schema_tests/expression_is_true.sql", "name": "test_expression_is_true", "macro_sql": "{% macro test_expression_is_true(model, condition='1=1') %}\n{# T-SQL has no boolean data type so we use 1=1 which returns TRUE #}\n{# ref https://stackoverflow.com/a/7170753/3842610 #}\n {{ return(adapter.dispatch('test_expression_is_true', packages = dbt_utils._get_utils_namespaces())(model, condition, **kwargs)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__test_expression_is_true": {"unique_id": "macro.dbt_utils.default__test_expression_is_true", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/schema_tests/expression_is_true.sql", "original_file_path": "macros/schema_tests/expression_is_true.sql", "name": "default__test_expression_is_true", "macro_sql": "{% macro default__test_expression_is_true(model, condition) %}\n\n{% set expression = kwargs.get('expression', kwargs.get('arg')) %}\n\nwith meet_condition as (\n\n select * from {{ model }} where {{ condition }}\n\n),\nvalidation_errors as (\n\n select\n *\n from meet_condition\n where not({{expression}})\n\n)\n\nselect count(*)\nfrom validation_errors\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.test_not_null_where": {"unique_id": "macro.dbt_utils.test_not_null_where", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/schema_tests/test_not_null_where.sql", "original_file_path": "macros/schema_tests/test_not_null_where.sql", "name": "test_not_null_where", "macro_sql": "{% macro test_not_null_where(model) %}\r\n {{ return(adapter.dispatch('test_not_null_where', packages = dbt_utils._get_utils_namespaces())(model, **kwargs)) }}\r\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__test_not_null_where": {"unique_id": "macro.dbt_utils.default__test_not_null_where", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/schema_tests/test_not_null_where.sql", "original_file_path": "macros/schema_tests/test_not_null_where.sql", "name": "default__test_not_null_where", "macro_sql": "{% macro default__test_not_null_where(model) %}\r\n\r\n{% set column_name = kwargs.get('column_name', kwargs.get('arg')) %}\r\n{% set where = kwargs.get('where', kwargs.get('arg')) %}\r\n\r\nselect count(*)\r\nfrom {{ model }}\r\nwhere {{ column_name }} is null\r\n{% if where %} and {{ where }} {% endif %}\r\n\r\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.test_equality": {"unique_id": "macro.dbt_utils.test_equality", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/schema_tests/equality.sql", "original_file_path": "macros/schema_tests/equality.sql", "name": "test_equality", "macro_sql": "{% macro test_equality(model) %}\n {{ return(adapter.dispatch('test_equality', packages = dbt_utils._get_utils_namespaces())(model, **kwargs)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__test_equality": {"unique_id": "macro.dbt_utils.default__test_equality", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/schema_tests/equality.sql", "original_file_path": "macros/schema_tests/equality.sql", "name": "default__test_equality", "macro_sql": "{% macro default__test_equality(model) %}\n\n\n{#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\n{%- if not execute -%}\n {{ return('') }}\n{% endif %}\n\n-- setup\n{%- do dbt_utils._is_relation(model, 'test_equality') -%}\n\n{#-\nIf the compare_cols arg is provided, we can run this test without querying the\ninformation schema\u00a0\u2014 this allows the model to be an ephemeral model\n-#}\n{%- set compare_columns = kwargs.get('compare_columns', None) -%}\n\n{%- if not compare_columns -%}\n {%- do dbt_utils._is_ephemeral(model, 'test_equality') -%}\n {%- set compare_columns = adapter.get_columns_in_relation(model) | map(attribute='quoted') -%}\n{%- endif -%}\n\n{% set compare_model = kwargs.get('compare_model', kwargs.get('arg')) %}\n{% set compare_cols_csv = compare_columns | join(', ') %}\n\nwith a as (\n\n select * from {{ model }}\n\n),\n\nb as (\n\n select * from {{ compare_model }}\n\n),\n\na_minus_b as (\n\n select {{compare_cols_csv}} from a\n {{ dbt_utils.except() }}\n select {{compare_cols_csv}} from b\n\n),\n\nb_minus_a as (\n\n select {{compare_cols_csv}} from b\n {{ dbt_utils.except() }}\n select {{compare_cols_csv}} from a\n\n),\n\nunioned as (\n\n select * from a_minus_b\n union all\n select * from b_minus_a\n\n),\n\nfinal as (\n\n select (select count(*) from unioned) +\n (select abs(\n (select count(*) from a_minus_b) -\n (select count(*) from b_minus_a)\n ))\n as count\n\n)\n\nselect count from final\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.test_mutually_exclusive_ranges": {"unique_id": "macro.dbt_utils.test_mutually_exclusive_ranges", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/schema_tests/mutually_exclusive_ranges.sql", "original_file_path": "macros/schema_tests/mutually_exclusive_ranges.sql", "name": "test_mutually_exclusive_ranges", "macro_sql": "{% macro test_mutually_exclusive_ranges(model, lower_bound_column, upper_bound_column, partition_by=None, gaps='allowed') %}\n {{ return(adapter.dispatch('test_mutually_exclusive_ranges', packages = dbt_utils._get_utils_namespaces())(model, lower_bound_column, upper_bound_column, partition_by, gaps)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__test_mutually_exclusive_ranges": {"unique_id": "macro.dbt_utils.default__test_mutually_exclusive_ranges", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/schema_tests/mutually_exclusive_ranges.sql", "original_file_path": "macros/schema_tests/mutually_exclusive_ranges.sql", "name": "default__test_mutually_exclusive_ranges", "macro_sql": "{% macro default__test_mutually_exclusive_ranges(model, lower_bound_column, upper_bound_column, partition_by=None, gaps='allowed') %}\n\n{% if gaps == 'not_allowed' %}\n {% set allow_gaps_operator='=' %}\n {% set allow_gaps_operator_in_words='equal_to' %}\n{% elif gaps == 'allowed' %}\n {% set allow_gaps_operator='<=' %}\n {% set allow_gaps_operator_in_words='less_than_or_equal_to' %}\n{% elif gaps == 'required' %}\n {% set allow_gaps_operator='<' %}\n {% set allow_gaps_operator_in_words='less_than' %}\n{% else %}\n {{ exceptions.raise_compiler_error(\n \"`gaps` argument for mutually_exclusive_ranges test must be one of ['not_allowed', 'allowed', 'required'] Got: '\" ~ gaps ~\"'.'\"\n ) }}\n\n{% endif %}\n\n{% set partition_clause=\"partition by \" ~ partition_by if partition_by else '' %}\n\nwith window_functions as (\n\n select\n {% if partition_by %}\n {{ partition_by }},\n {% endif %}\n {{ lower_bound_column }} as lower_bound,\n {{ upper_bound_column }} as upper_bound,\n\n lead({{ lower_bound_column }}) over (\n {{ partition_clause }}\n order by {{ lower_bound_column }}\n ) as next_lower_bound,\n\n row_number() over (\n {{ partition_clause }}\n order by {{ lower_bound_column }} desc\n ) = 1 as is_last_record\n\n from {{ model }}\n\n),\n\ncalc as (\n -- We want to return records where one of our assumptions fails, so we'll use\n -- the `not` function with `and` statements so we can write our assumptions nore cleanly\n select\n *,\n\n -- For each record: lower_bound should be < upper_bound.\n -- Coalesce it to return an error on the null case (implicit assumption\n -- these columns are not_null)\n coalesce(\n lower_bound < upper_bound,\n false\n ) as lower_bound_less_than_upper_bound,\n\n -- For each record: upper_bound {{ allow_gaps_operator }} the next lower_bound.\n -- Coalesce it to handle null cases for the last record.\n coalesce(\n upper_bound {{ allow_gaps_operator }} next_lower_bound,\n is_last_record,\n false\n ) as upper_bound_{{ allow_gaps_operator_in_words }}_next_lower_bound\n\n from window_functions\n\n),\n\nvalidation_errors as (\n\n select\n *\n from calc\n\n where not(\n -- THE FOLLOWING SHOULD BE TRUE --\n lower_bound_less_than_upper_bound\n and upper_bound_{{ allow_gaps_operator_in_words }}_next_lower_bound\n )\n)\n\nselect count(*) from validation_errors\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.nullcheck_table": {"unique_id": "macro.dbt_utils.nullcheck_table", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/nullcheck_table.sql", "original_file_path": "macros/sql/nullcheck_table.sql", "name": "nullcheck_table", "macro_sql": "{% macro nullcheck_table(relation) %}\n {{ return(adapter.dispatch('nullcheck_table', packages = dbt_utils._get_utils_namespaces())(relation)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__nullcheck_table": {"unique_id": "macro.dbt_utils.default__nullcheck_table", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/nullcheck_table.sql", "original_file_path": "macros/sql/nullcheck_table.sql", "name": "default__nullcheck_table", "macro_sql": "{% macro default__nullcheck_table(relation) %}\n\n {%- do dbt_utils._is_relation(relation, 'nullcheck_table') -%}\n {%- do dbt_utils._is_ephemeral(relation, 'nullcheck_table') -%}\n {% set cols = adapter.get_columns_in_relation(relation) %}\n\n select {{ dbt_utils.nullcheck(cols) }}\n from {{relation}}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.get_relations_by_pattern": {"unique_id": "macro.dbt_utils.get_relations_by_pattern", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/get_relations_by_pattern.sql", "original_file_path": "macros/sql/get_relations_by_pattern.sql", "name": "get_relations_by_pattern", "macro_sql": "{% macro get_relations_by_pattern(schema_pattern, table_pattern, exclude='', database=target.database) %}\n {{ return(adapter.dispatch('get_relations_by_pattern', packages = dbt_utils._get_utils_namespaces())(schema_pattern, table_pattern, exclude, database)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__get_relations_by_pattern": {"unique_id": "macro.dbt_utils.default__get_relations_by_pattern", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/get_relations_by_pattern.sql", "original_file_path": "macros/sql/get_relations_by_pattern.sql", "name": "default__get_relations_by_pattern", "macro_sql": "{% macro default__get_relations_by_pattern(schema_pattern, table_pattern, exclude='', database=target.database) %}\n\n {%- call statement('get_tables', fetch_result=True) %}\n\n {{ dbt_utils.get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude, database) }}\n\n {%- endcall -%}\n\n {%- set table_list = load_result('get_tables') -%}\n\n {%- if table_list and table_list['table'] -%}\n {%- set tbl_relations = [] -%}\n {%- for row in table_list['table'] -%}\n {%- set tbl_relation = api.Relation.create(\n database=database,\n schema=row.table_schema,\n identifier=row.table_name,\n type=row.table_type\n ) -%}\n {%- do tbl_relations.append(tbl_relation) -%}\n {%- endfor -%}\n\n {{ return(tbl_relations) }}\n {%- else -%}\n {{ return([]) }}\n {%- endif -%}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.get_powers_of_two": {"unique_id": "macro.dbt_utils.get_powers_of_two", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/generate_series.sql", "original_file_path": "macros/sql/generate_series.sql", "name": "get_powers_of_two", "macro_sql": "{% macro get_powers_of_two(upper_bound) %}\n {{ return(adapter.dispatch('get_powers_of_two', packages = dbt_utils._get_utils_namespaces())(upper_bound)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__get_powers_of_two": {"unique_id": "macro.dbt_utils.default__get_powers_of_two", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/generate_series.sql", "original_file_path": "macros/sql/generate_series.sql", "name": "default__get_powers_of_two", "macro_sql": "{% macro default__get_powers_of_two(upper_bound) %}\n\n {% if upper_bound <= 0 %}\n {{ exceptions.raise_compiler_error(\"upper bound must be positive\") }}\n {% endif %}\n\n {% for _ in range(1, 100) %}\n {% if upper_bound <= 2 ** loop.index %}{{ return(loop.index) }}{% endif %}\n {% endfor %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.generate_series": {"unique_id": "macro.dbt_utils.generate_series", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/generate_series.sql", "original_file_path": "macros/sql/generate_series.sql", "name": "generate_series", "macro_sql": "{% macro generate_series(upper_bound) %}\n {{ return(adapter.dispatch('generate_series', packages = dbt_utils._get_utils_namespaces())(upper_bound)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__generate_series": {"unique_id": "macro.dbt_utils.default__generate_series", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/generate_series.sql", "original_file_path": "macros/sql/generate_series.sql", "name": "default__generate_series", "macro_sql": "{% macro default__generate_series(upper_bound) %}\n\n {% set n = dbt_utils.get_powers_of_two(upper_bound) %}\n\n with p as (\n select 0 as generated_number union all select 1\n ), unioned as (\n\n select\n\n {% for i in range(n) %}\n p{{i}}.generated_number * pow(2, {{i}})\n {% if not loop.last %} + {% endif %}\n {% endfor %}\n + 1\n as generated_number\n\n from\n\n {% for i in range(n) %}\n p as p{{i}}\n {% if not loop.last %} cross join {% endif %}\n {% endfor %}\n\n )\n\n select *\n from unioned\n where generated_number <= {{upper_bound}}\n order by generated_number\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.get_relations_by_prefix": {"unique_id": "macro.dbt_utils.get_relations_by_prefix", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/get_relations_by_prefix.sql", "original_file_path": "macros/sql/get_relations_by_prefix.sql", "name": "get_relations_by_prefix", "macro_sql": "{% macro get_relations_by_prefix(schema, prefix, exclude='', database=target.database) %}\n {{ return(adapter.dispatch('get_relations_by_prefix', packages = dbt_utils._get_utils_namespaces())(schema, prefix, exclude, database)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__get_relations_by_prefix": {"unique_id": "macro.dbt_utils.default__get_relations_by_prefix", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/get_relations_by_prefix.sql", "original_file_path": "macros/sql/get_relations_by_prefix.sql", "name": "default__get_relations_by_prefix", "macro_sql": "{% macro default__get_relations_by_prefix(schema, prefix, exclude='', database=target.database) %}\n\n {%- call statement('get_tables', fetch_result=True) %}\n\n {{ dbt_utils.get_tables_by_prefix_sql(schema, prefix, exclude, database) }}\n\n {%- endcall -%}\n\n {%- set table_list = load_result('get_tables') -%}\n\n {%- if table_list and table_list['table'] -%}\n {%- set tbl_relations = [] -%}\n {%- for row in table_list['table'] -%}\n {%- set tbl_relation = api.Relation.create(\n database=database,\n schema=row.table_schema,\n identifier=row.table_name,\n type=row.table_type\n ) -%}\n {%- do tbl_relations.append(tbl_relation) -%}\n {%- endfor -%}\n\n {{ return(tbl_relations) }}\n {%- else -%}\n {{ return([]) }}\n {%- endif -%}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.get_tables_by_prefix_sql": {"unique_id": "macro.dbt_utils.get_tables_by_prefix_sql", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/get_tables_by_prefix_sql.sql", "original_file_path": "macros/sql/get_tables_by_prefix_sql.sql", "name": "get_tables_by_prefix_sql", "macro_sql": "{% macro get_tables_by_prefix_sql(schema, prefix, exclude='', database=target.database) %}\n {{ return(adapter.dispatch('get_tables_by_prefix_sql', packages = dbt_utils._get_utils_namespaces())(schema, prefix, exclude, database)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__get_tables_by_prefix_sql": {"unique_id": "macro.dbt_utils.default__get_tables_by_prefix_sql", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/get_tables_by_prefix_sql.sql", "original_file_path": "macros/sql/get_tables_by_prefix_sql.sql", "name": "default__get_tables_by_prefix_sql", "macro_sql": "{% macro default__get_tables_by_prefix_sql(schema, prefix, exclude='', database=target.database) %}\n\n {{ dbt_utils.get_tables_by_pattern_sql(\n schema_pattern = schema,\n table_pattern = prefix ~ '%',\n exclude = exclude,\n database = database\n ) }}\n \n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.star": {"unique_id": "macro.dbt_utils.star", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/star.sql", "original_file_path": "macros/sql/star.sql", "name": "star", "macro_sql": "{% macro star(from, relation_alias=False, except=[]) -%}\n {{ return(adapter.dispatch('star', packages = dbt_utils._get_utils_namespaces())(from, relation_alias, except)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__star": {"unique_id": "macro.dbt_utils.default__star", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/star.sql", "original_file_path": "macros/sql/star.sql", "name": "default__star", "macro_sql": "{% macro default__star(from, relation_alias=False, except=[]) -%}\n {%- do dbt_utils._is_relation(from, 'star') -%}\n {%- do dbt_utils._is_ephemeral(from, 'star') -%}\n\n {#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\n {%- if not execute -%}\n {{ return('') }}\n {% endif %}\n\n {%- set include_cols = [] %}\n {%- set cols = adapter.get_columns_in_relation(from) -%}\n\n {%- for col in cols -%}\n\n {%- if col.column not in except -%}\n {% do include_cols.append(col.column) %}\n\n {%- endif %}\n {%- endfor %}\n\n {%- for col in include_cols %}\n\n {%- if relation_alias %}{{ relation_alias }}.{% else %}{%- endif -%}{{ adapter.quote(col)|trim }}\n {%- if not loop.last %},{{ '\\n ' }}{% endif %}\n\n {%- endfor -%}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.unpivot": {"unique_id": "macro.dbt_utils.unpivot", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/unpivot.sql", "original_file_path": "macros/sql/unpivot.sql", "name": "unpivot", "macro_sql": "{% macro unpivot(relation=none, cast_to='varchar', exclude=none, remove=none, field_name='field_name', value_name='value', table=none) -%}\n {{ return(adapter.dispatch('unpivot', packages = dbt_utils._get_utils_namespaces())(relation, cast_to, exclude, remove, field_name, value_name, table)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__unpivot": {"unique_id": "macro.dbt_utils.default__unpivot", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/unpivot.sql", "original_file_path": "macros/sql/unpivot.sql", "name": "default__unpivot", "macro_sql": "{% macro default__unpivot(relation=none, cast_to='varchar', exclude=none, remove=none, field_name='field_name', value_name='value', table=none) -%}\n\n {% if table %}\n {%- set error_message = '\n Warning: the `unpivot` macro no longer accepts a `table` parameter. \\\n This parameter will be deprecated in a future release of dbt-utils. Use the `relation` parameter instead. \\\n The {}.{} model triggered this warning. \\\n '.format(model.package_name, model.name) -%}\n {%- do exceptions.warn(error_message) -%}\n {% endif %}\n\n {% if relation and table %}\n {{ exceptions.raise_compiler_error(\"Error: both the `relation` and `table` parameters were provided to `unpivot` macro. Choose one only (we recommend `relation`).\") }}\n {% elif not relation and table %}\n {% set relation=table %}\n {% elif not relation and not table %}\n {{ exceptions.raise_compiler_error(\"Error: argument `relation` is required for `unpivot` macro.\") }}\n {% endif %}\n\n {%- set exclude = exclude if exclude is not none else [] %}\n {%- set remove = remove if remove is not none else [] %}\n\n {%- set include_cols = [] %}\n\n {%- set table_columns = {} %}\n\n {%- do table_columns.update({relation: []}) %}\n\n {%- do dbt_utils._is_relation(relation, 'unpivot') -%}\n {%- do dbt_utils._is_ephemeral(relation, 'unpivot') -%}\n {%- set cols = adapter.get_columns_in_relation(relation) %}\n\n {%- for col in cols -%}\n {%- if col.column.lower() not in remove|map('lower') and col.column.lower() not in exclude|map('lower') -%}\n {% do include_cols.append(col) %}\n {%- endif %}\n {%- endfor %}\n\n\n {%- for col in include_cols -%}\n select\n {%- for exclude_col in exclude %}\n {{ exclude_col }},\n {%- endfor %}\n\n cast('{{ col.column }}' as {{ dbt_utils.type_string() }}) as {{ field_name }},\n cast({{ col.column }} as {{ cast_to }}) as {{ value_name }}\n\n from {{ relation }}\n\n {% if not loop.last -%}\n union all\n {% endif -%}\n {%- endfor -%}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.union_relations": {"unique_id": "macro.dbt_utils.union_relations", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/union.sql", "original_file_path": "macros/sql/union.sql", "name": "union_relations", "macro_sql": "{%- macro union_relations(relations, column_override=none, include=[], exclude=[], source_column_name='_dbt_source_relation') -%}\n {{ return(adapter.dispatch('union_relations', packages = dbt_utils._get_utils_namespaces())(relations, column_override, include, exclude, source_column_name)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__union_relations": {"unique_id": "macro.dbt_utils.default__union_relations", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/union.sql", "original_file_path": "macros/sql/union.sql", "name": "default__union_relations", "macro_sql": "\n\n{%- macro default__union_relations(relations, column_override=none, include=[], exclude=[], source_column_name='_dbt_source_relation') -%}\n\n {%- if exclude and include -%}\n {{ exceptions.raise_compiler_error(\"Both an exclude and include list were provided to the `union` macro. Only one is allowed\") }}\n {%- endif -%}\n\n {#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. -#}\n {%- if not execute %}\n {{ return('') }}\n {% endif -%}\n\n {%- set column_override = column_override if column_override is not none else {} -%}\n\n {%- set relation_columns = {} -%}\n {%- set column_superset = {} -%}\n\n {%- for relation in relations -%}\n\n {%- do relation_columns.update({relation: []}) -%}\n\n {%- do dbt_utils._is_relation(relation, 'union_relations') -%}\n {%- do dbt_utils._is_ephemeral(relation, 'union_relations') -%}\n {%- set cols = adapter.get_columns_in_relation(relation) -%}\n {%- for col in cols -%}\n\n {#- If an exclude list was provided and the column is in the list, do nothing -#}\n {%- if exclude and col.column in exclude -%}\n\n {#- If an include list was provided and the column is not in the list, do nothing -#}\n {%- elif include and col.column not in include -%}\n\n {#- Otherwise add the column to the column superset -#}\n {%- else -%}\n\n {#- update the list of columns in this relation -#}\n {%- do relation_columns[relation].append(col.column) -%}\n\n {%- if col.column in column_superset -%}\n\n {%- set stored = column_superset[col.column] -%}\n {%- if col.is_string() and stored.is_string() and col.string_size() > stored.string_size() -%}\n\n {%- do column_superset.update({col.column: col}) -%}\n\n {%- endif %}\n\n {%- else -%}\n\n {%- do column_superset.update({col.column: col}) -%}\n\n {%- endif -%}\n\n {%- endif -%}\n\n {%- endfor -%}\n {%- endfor -%}\n\n {%- set ordered_column_names = column_superset.keys() -%}\n\n {%- for relation in relations %}\n\n (\n select\n\n cast({{ dbt_utils.string_literal(relation) }} as {{ dbt_utils.type_string() }}) as {{ source_column_name }},\n {% for col_name in ordered_column_names -%}\n\n {%- set col = column_superset[col_name] %}\n {%- set col_type = column_override.get(col.column, col.data_type) %}\n {%- set col_name = adapter.quote(col_name) if col_name in relation_columns[relation] else 'null' %}\n cast({{ col_name }} as {{ col_type }}) as {{ col.quoted }} {% if not loop.last %},{% endif -%}\n\n {%- endfor %}\n\n from {{ relation }}\n )\n\n {% if not loop.last -%}\n union all\n {% endif -%}\n\n {%- endfor -%}\n\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.group_by": {"unique_id": "macro.dbt_utils.group_by", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/groupby.sql", "original_file_path": "macros/sql/groupby.sql", "name": "group_by", "macro_sql": "{%- macro group_by(n) -%}\n {{ return(adapter.dispatch('group_by', packages = dbt_utils._get_utils_namespaces())(n)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__group_by": {"unique_id": "macro.dbt_utils.default__group_by", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/groupby.sql", "original_file_path": "macros/sql/groupby.sql", "name": "default__group_by", "macro_sql": "\n\n{%- macro default__group_by(n) -%}\n\n group by {% for i in range(1, n + 1) -%}\n {{ i }}{{ ',' if not loop.last }} \n {%- endfor -%}\n\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.surrogate_key": {"unique_id": "macro.dbt_utils.surrogate_key", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/surrogate_key.sql", "original_file_path": "macros/sql/surrogate_key.sql", "name": "surrogate_key", "macro_sql": "{%- macro surrogate_key(field_list) -%}\n {# needed for safe_add to allow for non-keyword arguments see SO post #}\n {# https://stackoverflow.com/questions/13944751/args-kwargs-in-jinja2-macros #}\n {% set frustrating_jinja_feature = varargs %}\n {{ return(adapter.dispatch('surrogate_key', packages = dbt_utils._get_utils_namespaces())(field_list, *varargs)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__surrogate_key": {"unique_id": "macro.dbt_utils.default__surrogate_key", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/surrogate_key.sql", "original_file_path": "macros/sql/surrogate_key.sql", "name": "default__surrogate_key", "macro_sql": "\n\n{%- macro default__surrogate_key(field_list) -%}\n\n{%- if varargs|length >= 1 or field_list is string %}\n\n{%- set error_message = '\nWarning: the `surrogate_key` macro now takes a single list argument instead of \\\nmultiple string arguments. Support for multiple string arguments will be \\\ndeprecated in a future release of dbt-utils. The {}.{} model triggered this warning. \\\n'.format(model.package_name, model.name) -%}\n\n{%- do exceptions.warn(error_message) -%}\n\n{# first argument is not included in varargs, so add first element to field_list_xf #}\n{%- set field_list_xf = [field_list] -%}\n\n{%- for field in varargs %}\n{%- set _ = field_list_xf.append(field) -%}\n{%- endfor -%}\n\n{%- else -%}\n\n{# if using list, just set field_list_xf as field_list #}\n{%- set field_list_xf = field_list -%}\n\n{%- endif -%}\n\n\n{%- set fields = [] -%}\n\n{%- for field in field_list_xf -%}\n\n {%- set _ = fields.append(\n \"coalesce(cast(\" ~ field ~ \" as \" ~ dbt_utils.type_string() ~ \"), '')\"\n ) -%}\n\n {%- if not loop.last %}\n {%- set _ = fields.append(\"'-'\") -%}\n {%- endif -%}\n\n{%- endfor -%}\n\n{{dbt_utils.hash(dbt_utils.concat(fields))}}\n\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.safe_add": {"unique_id": "macro.dbt_utils.safe_add", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/safe_add.sql", "original_file_path": "macros/sql/safe_add.sql", "name": "safe_add", "macro_sql": "{%- macro safe_add() -%}\n {# needed for safe_add to allow for non-keyword arguments see SO post #}\n {# https://stackoverflow.com/questions/13944751/args-kwargs-in-jinja2-macros #}\n {% set frustrating_jinja_feature = varargs %}\n {{ return(adapter.dispatch('safe_add', packages = dbt_utils._get_utils_namespaces())(*varargs)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__safe_add": {"unique_id": "macro.dbt_utils.default__safe_add", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/safe_add.sql", "original_file_path": "macros/sql/safe_add.sql", "name": "default__safe_add", "macro_sql": "\n\n{%- macro default__safe_add() -%}\n\n{% set fields = [] %}\n\n{%- for field in varargs -%}\n\n {% do fields.append(\"coalesce(\" ~ field ~ \", 0)\") %}\n\n{%- endfor -%}\n\n{{ fields|join(' +\\n ') }}\n\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.nullcheck": {"unique_id": "macro.dbt_utils.nullcheck", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/nullcheck.sql", "original_file_path": "macros/sql/nullcheck.sql", "name": "nullcheck", "macro_sql": "{% macro nullcheck(cols) %}\n {{ return(adapter.dispatch('nullcheck', packages = dbt_utils._get_utils_namespaces())(cols)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__nullcheck": {"unique_id": "macro.dbt_utils.default__nullcheck", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/nullcheck.sql", "original_file_path": "macros/sql/nullcheck.sql", "name": "default__nullcheck", "macro_sql": "{% macro default__nullcheck(cols) %}\n{%- for col in cols %}\n\n {% if col.is_string() -%}\n\n nullif({{col.name}},'') as {{col.name}}\n\n {%- else -%}\n\n {{col.name}}\n\n {%- endif -%}\n\n{%- if not loop.last -%} , {%- endif -%}\n\n{%- endfor -%}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.get_tables_by_pattern_sql": {"unique_id": "macro.dbt_utils.get_tables_by_pattern_sql", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/get_tables_by_pattern_sql.sql", "original_file_path": "macros/sql/get_tables_by_pattern_sql.sql", "name": "get_tables_by_pattern_sql", "macro_sql": "{% macro get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude='', database=target.database) %}\n {{ return(adapter.dispatch('get_tables_by_pattern_sql', packages = dbt_utils._get_utils_namespaces())\n (schema_pattern, table_pattern, exclude, database)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__get_tables_by_pattern_sql": {"unique_id": "macro.dbt_utils.default__get_tables_by_pattern_sql", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/get_tables_by_pattern_sql.sql", "original_file_path": "macros/sql/get_tables_by_pattern_sql.sql", "name": "default__get_tables_by_pattern_sql", "macro_sql": "{% macro default__get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude='', database=target.database) %}\n\n select distinct\n table_schema as \"table_schema\",\n table_name as \"table_name\",\n case table_type\n when 'BASE TABLE' then 'table'\n else lower(table_type)\n end as \"table_type\"\n from {{ database }}.information_schema.tables\n where table_schema ilike '{{ schema_pattern }}'\n and table_name ilike '{{ table_pattern }}'\n and table_name not ilike '{{ exclude }}'\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.bigquery__get_tables_by_pattern_sql": {"unique_id": "macro.dbt_utils.bigquery__get_tables_by_pattern_sql", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/get_tables_by_pattern_sql.sql", "original_file_path": "macros/sql/get_tables_by_pattern_sql.sql", "name": "bigquery__get_tables_by_pattern_sql", "macro_sql": "{% macro bigquery__get_tables_by_pattern_sql(schema_pattern, table_pattern, exclude='', database=target.database) %}\n\n {% if '%' in schema_pattern %}\n {% set schemata=dbt_utils._bigquery__get_matching_schemata(schema_pattern, database) %}\n {% else %}\n {% set schemata=[schema_pattern] %}\n {% endif %}\n\n {% set sql %}\n {% for schema in schemata %}\n select distinct\n table_schema,\n table_name,\n case table_type\n when 'BASE TABLE' then 'table'\n else lower(table_type)\n end as table_type\n\n from {{ adapter.quote(database) }}.{{ schema }}.INFORMATION_SCHEMA.TABLES\n where lower(table_name) like lower ('{{ table_pattern }}')\n and lower(table_name) not like lower ('{{ exclude }}')\n\n {% if not loop.last %} union all {% endif %}\n\n {% endfor %}\n {% endset %}\n\n {{ return(sql) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils._bigquery__get_matching_schemata": {"unique_id": "macro.dbt_utils._bigquery__get_matching_schemata", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/get_tables_by_pattern_sql.sql", "original_file_path": "macros/sql/get_tables_by_pattern_sql.sql", "name": "_bigquery__get_matching_schemata", "macro_sql": "{% macro _bigquery__get_matching_schemata(schema_pattern, database) %}\n {% if execute %}\n\n {% set sql %}\n select schema_name from {{ adapter.quote(database) }}.INFORMATION_SCHEMA.SCHEMATA\n where lower(schema_name) like lower('{{ schema_pattern }}')\n {% endset %}\n\n {% set results=run_query(sql) %}\n\n {% set schemata=results.columns['schema_name'].values() %}\n\n {{ return(schemata) }}\n\n {% else %}\n\n {{ return([]) }}\n\n {% endif %}\n\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.get_column_values": {"unique_id": "macro.dbt_utils.get_column_values", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/get_column_values.sql", "original_file_path": "macros/sql/get_column_values.sql", "name": "get_column_values", "macro_sql": "{% macro get_column_values(table, column, max_records=none, default=none) -%}\n {{ return(adapter.dispatch('get_column_values', packages = dbt_utils._get_utils_namespaces())(table, column, max_records, default)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__get_column_values": {"unique_id": "macro.dbt_utils.default__get_column_values", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/get_column_values.sql", "original_file_path": "macros/sql/get_column_values.sql", "name": "default__get_column_values", "macro_sql": "{% macro default__get_column_values(table, column, max_records=none, default=none) -%}\n\n{#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. #}\n {%- if not execute -%}\n {{ return('') }}\n {% endif %}\n{#-- #}\n\n {%- set target_relation = adapter.get_relation(database=table.database,\n schema=table.schema,\n identifier=table.identifier) -%}\n\n {%- call statement('get_column_values', fetch_result=true) %}\n\n {%- if not target_relation and default is none -%}\n\n {{ exceptions.raise_compiler_error(\"In get_column_values(): relation \" ~ table ~ \" does not exist and no default value was provided.\") }}\n\n {%- elif not target_relation and default is not none -%}\n\n {{ log(\"Relation \" ~ table ~ \" does not exist. Returning the default value: \" ~ default) }}\n\n {{ return(default) }}\n\n {%- else -%}\n\n select\n {{ column }} as value\n\n from {{ target_relation }}\n group by 1\n order by count(*) desc\n\n {% if max_records is not none %}\n limit {{ max_records }}\n {% endif %}\n\n {% endif %}\n\n {%- endcall -%}\n\n {%- set value_list = load_result('get_column_values') -%}\n\n {%- if value_list and value_list['data'] -%}\n {%- set values = value_list['data'] | map(attribute=0) | list %}\n {{ return(values) }}\n {%- else -%}\n {{ return(default) }}\n {%- endif -%}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.pivot": {"unique_id": "macro.dbt_utils.pivot", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/pivot.sql", "original_file_path": "macros/sql/pivot.sql", "name": "pivot", "macro_sql": "{% macro pivot(column,\n values,\n alias=True,\n agg='sum',\n cmp='=',\n prefix='',\n suffix='',\n then_value=1,\n else_value=0,\n quote_identifiers=True,\n distinct=False) %}\n {{ return(adapter.dispatch('pivot', packages = dbt_utils._get_utils_namespaces())(column, values, alias, agg, cmp, prefix, suffix, then_value, else_value, quote_identifiers, distinct)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__pivot": {"unique_id": "macro.dbt_utils.default__pivot", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/pivot.sql", "original_file_path": "macros/sql/pivot.sql", "name": "default__pivot", "macro_sql": "{% macro default__pivot(column,\n values,\n alias=True,\n agg='sum',\n cmp='=',\n prefix='',\n suffix='',\n then_value=1,\n else_value=0,\n quote_identifiers=True,\n distinct=False) %}\n {% for v in values %}\n {{ agg }}(\n {% if distinct %} distinct {% endif %}\n case\n when {{ column }} {{ cmp }} '{{ v }}'\n then {{ then_value }}\n else {{ else_value }}\n end\n )\n {% if alias %}\n {% if quote_identifiers %}\n as {{ adapter.quote(prefix ~ v ~ suffix) }}\n {% else %}\n as {{prefix ~ v ~ suffix }}\n {% endif %}\n {% endif %}\n {% if not loop.last %},{% endif %}\n {% endfor %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.get_query_results_as_dict": {"unique_id": "macro.dbt_utils.get_query_results_as_dict", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/get_query_results_as_dict.sql", "original_file_path": "macros/sql/get_query_results_as_dict.sql", "name": "get_query_results_as_dict", "macro_sql": "{% macro get_query_results_as_dict(query) %}\n {{ return(adapter.dispatch('get_query_results_as_dict', packages = dbt_utils._get_utils_namespaces())(query)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.dbt_utils.default__get_query_results_as_dict": {"unique_id": "macro.dbt_utils.default__get_query_results_as_dict", "package_name": "dbt_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/dbt_utils", "path": "macros/sql/get_query_results_as_dict.sql", "original_file_path": "macros/sql/get_query_results_as_dict.sql", "name": "default__get_query_results_as_dict", "macro_sql": "{% macro default__get_query_results_as_dict(query) %}\n\n{# This macro returns a dictionary of the form {column_name: (tuple_of_results)} #}\n\n {%- call statement('get_query_results', fetch_result=True,auto_begin=false) -%}\n\n {{ query }}\n\n {%- endcall -%}\n\n {% set sql_results={} %}\n\n {%- if execute -%}\n {% set sql_results_table = load_result('get_query_results').table.columns %}\n {% for column_name, column in sql_results_table.items() %}\n {% do sql_results.update({column_name: column.values()}) %}\n {% endfor %}\n {%- endif -%}\n\n {{ return(sql_results) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.klaviyo_source.get_campaign_columns": {"unique_id": "macro.klaviyo_source.get_campaign_columns", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "macros/get_campaign_columns.sql", "original_file_path": "macros/get_campaign_columns.sql", "name": "get_campaign_columns", "macro_sql": "{% macro get_campaign_columns() %}\n\n{% set columns = [\n {\"name\": \"_fivetran_deleted\", \"datatype\": \"boolean\"},\n {\"name\": \"_fivetran_synced\", \"datatype\": dbt_utils.type_timestamp()},\n {\"name\": \"campaign_type\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"created\", \"datatype\": dbt_utils.type_timestamp()},\n {\"name\": \"email_template_id\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"from_email\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"from_name\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"id\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"is_segmented\", \"datatype\": \"boolean\"},\n {\"name\": \"name\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"send_time\", \"datatype\": dbt_utils.type_timestamp()},\n {\"name\": \"sent_at\", \"datatype\": dbt_utils.type_timestamp()},\n {\"name\": \"status\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"status_id\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"status_label\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"subject\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"updated\", \"datatype\": dbt_utils.type_timestamp()}\n] %}\n\n{{ return(columns) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.klaviyo_source.get_metric_columns": {"unique_id": "macro.klaviyo_source.get_metric_columns", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "macros/get_metric_columns.sql", "original_file_path": "macros/get_metric_columns.sql", "name": "get_metric_columns", "macro_sql": "{% macro get_metric_columns() %}\n\n{% set columns = [\n {\"name\": \"_fivetran_deleted\", \"datatype\": \"boolean\"},\n {\"name\": \"_fivetran_synced\", \"datatype\": dbt_utils.type_timestamp()},\n {\"name\": \"created\", \"datatype\": dbt_utils.type_timestamp()},\n {\"name\": \"id\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"integration_id\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"name\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"updated\", \"datatype\": dbt_utils.type_timestamp()}\n] %}\n\n{{ return(columns) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.klaviyo_source.get_flow_columns": {"unique_id": "macro.klaviyo_source.get_flow_columns", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "macros/get_flow_columns.sql", "original_file_path": "macros/get_flow_columns.sql", "name": "get_flow_columns", "macro_sql": "{% macro get_flow_columns() %}\n\n{% set columns = [\n {\"name\": \"_fivetran_deleted\", \"datatype\": \"boolean\"},\n {\"name\": \"_fivetran_synced\", \"datatype\": dbt_utils.type_timestamp()},\n {\"name\": \"created\", \"datatype\": dbt_utils.type_timestamp()},\n {\"name\": \"id\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"name\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"status\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"trigger\", \"datatype\": dbt_utils.type_string(), \"quote\": True},\n {\"name\": \"updated\", \"datatype\": dbt_utils.type_timestamp()},\n {\"name\": \"customer_filter\", \"datatype\": dbt_utils.type_string()}\n] %}\n\n{{ return(columns) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.klaviyo_source.get_integration_columns": {"unique_id": "macro.klaviyo_source.get_integration_columns", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "macros/get_integration_columns.sql", "original_file_path": "macros/get_integration_columns.sql", "name": "get_integration_columns", "macro_sql": "{% macro get_integration_columns() %}\n\n{% set columns = [\n {\"name\": \"_fivetran_deleted\", \"datatype\": \"boolean\"},\n {\"name\": \"_fivetran_synced\", \"datatype\": dbt_utils.type_timestamp()},\n {\"name\": \"category\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"id\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"name\", \"datatype\": dbt_utils.type_string()}\n] %}\n\n{{ return(columns) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.klaviyo_source.get_person_columns": {"unique_id": "macro.klaviyo_source.get_person_columns", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "macros/get_person_columns.sql", "original_file_path": "macros/get_person_columns.sql", "name": "get_person_columns", "macro_sql": "{% macro get_person_columns() %}\n\n{% set columns = [\n {\"name\": \"_fivetran_deleted\", \"datatype\": \"boolean\"},\n {\"name\": \"_fivetran_synced\", \"datatype\": dbt_utils.type_timestamp()},\n {\"name\": \"address_1\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"address_2\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"city\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"country\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"created\", \"datatype\": dbt_utils.type_timestamp()},\n {\"name\": \"email\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"first_name\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"id\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"last_name\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"latitude\", \"datatype\": dbt_utils.type_float()},\n {\"name\": \"longitude\", \"datatype\": dbt_utils.type_float()},\n {\"name\": \"organization\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"phone_number\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"region\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"timezone\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"title\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"updated\", \"datatype\": dbt_utils.type_timestamp()},\n {\"name\": \"zip\", \"datatype\": dbt_utils.type_string()}\n] %}\n\n{{ fivetran_utils.add_pass_through_columns(columns, var('klaviyo__person_pass_through_columns')) }}\n\n{{ return(columns) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.klaviyo_source.get_event_columns": {"unique_id": "macro.klaviyo_source.get_event_columns", "package_name": "klaviyo_source", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/klaviyo_source", "path": "macros/get_event_columns.sql", "original_file_path": "macros/get_event_columns.sql", "name": "get_event_columns", "macro_sql": "{% macro get_event_columns() %}\n\n{% set columns = [\n {\"name\": \"_fivetran_deleted\", \"datatype\": \"boolean\"},\n {\"name\": \"_fivetran_synced\", \"datatype\": dbt_utils.type_timestamp()},\n {\"name\": \"_variation\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"campaign_id\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"datetime\", \"datatype\": dbt_utils.type_timestamp()},\n {\"name\": \"flow_id\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"flow_message_id\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"id\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"metric_id\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"person_id\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"timestamp\", \"datatype\": dbt_utils.type_timestamp()},\n {\"name\": \"type\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"uuid\", \"datatype\": dbt_utils.type_string()},\n {\"name\": \"property_value\", \"datatype\": dbt_utils.type_string()}\n] %}\n\n{{ fivetran_utils.add_pass_through_columns(columns, var('klaviyo__event_pass_through_columns')) }}\n\n{{ return(columns) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.spark_utils.spark__type_numeric": {"unique_id": "macro.spark_utils.spark__type_numeric", "package_name": "spark_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/spark_utils", "path": "macros/dbt_utils/cross_db_utils/datatypes.sql", "original_file_path": "macros/dbt_utils/cross_db_utils/datatypes.sql", "name": "spark__type_numeric", "macro_sql": "{% macro spark__type_numeric() %}\n decimal(28, 6)\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.spark_utils.spark__dateadd": {"unique_id": "macro.spark_utils.spark__dateadd", "package_name": "spark_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/spark_utils", "path": "macros/dbt_utils/cross_db_utils/dateadd.sql", "original_file_path": "macros/dbt_utils/cross_db_utils/dateadd.sql", "name": "spark__dateadd", "macro_sql": "{% macro spark__dateadd(datepart, interval, from_date_or_timestamp) %}\n\n {%- set clock_component -%}\n {# make sure the dates + timestamps are real, otherwise raise an error asap #}\n to_unix_timestamp({{ spark_utils.assert_not_null('to_timestamp', from_date_or_timestamp) }})\n - to_unix_timestamp({{ spark_utils.assert_not_null('date', from_date_or_timestamp) }})\n {%- endset -%}\n\n {%- if datepart in ['day', 'week'] -%}\n \n {%- set multiplier = 7 if datepart == 'week' else 1 -%}\n\n to_timestamp(\n to_unix_timestamp(\n date_add({{ spark_utils.assert_not_null('date', from_date_or_timestamp) }}, {{interval}} * {{multiplier}})\n ) + {{clock_component}}\n )\n\n {%- elif datepart in ['month', 'quarter', 'year'] -%}\n \n {%- set multiplier -%} \n {%- if datepart == 'month' -%} 1\n {%- elif datepart == 'quarter' -%} 3\n {%- elif datepart == 'year' -%} 12\n {%- endif -%}\n {%- endset -%}\n\n to_timestamp(\n to_unix_timestamp(\n add_months(\n {{ spark_utils.assert_not_null('date', from_date_or_timestamp) }},\n {{interval}} * {{multiplier}}\n )\n ) + {{clock_component}}\n )\n\n {%- elif datepart in ('hour', 'minute', 'second', 'millisecond', 'microsecond') -%}\n \n {%- set multiplier -%} \n {%- if datepart == 'hour' -%} 3600\n {%- elif datepart == 'minute' -%} 60\n {%- elif datepart == 'second' -%} 1\n {%- elif datepart == 'millisecond' -%} (1/1000000)\n {%- elif datepart == 'microsecond' -%} (1/1000000)\n {%- endif -%}\n {%- endset -%}\n\n to_timestamp(\n {{ spark_utils.assert_not_null('to_unix_timestamp', from_date_or_timestamp) }}\n + {{interval}} * {{multiplier}}\n )\n\n {%- else -%}\n\n {{ exceptions.raise_compiler_error(\"macro dateadd not implemented for datepart ~ '\" ~ datepart ~ \"' ~ on Spark\") }}\n\n {%- endif -%}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.spark_utils.spark__datediff": {"unique_id": "macro.spark_utils.spark__datediff", "package_name": "spark_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/spark_utils", "path": "macros/dbt_utils/cross_db_utils/datediff.sql", "original_file_path": "macros/dbt_utils/cross_db_utils/datediff.sql", "name": "spark__datediff", "macro_sql": "{% macro spark__datediff(first_date, second_date, datepart) %}\n\n {%- if datepart in ['day', 'week', 'month', 'quarter', 'year'] -%}\n \n {# make sure the dates are real, otherwise raise an error asap #}\n {% set first_date = spark_utils.assert_not_null('date', first_date) %}\n {% set second_date = spark_utils.assert_not_null('date', second_date) %}\n \n {%- endif -%}\n \n {%- if datepart == 'day' -%}\n \n datediff({{second_date}}, {{first_date}})\n \n {%- elif datepart == 'week' -%}\n \n case when {{first_date}} < {{second_date}}\n then floor(datediff({{second_date}}, {{first_date}})/7)\n else ceil(datediff({{second_date}}, {{first_date}})/7)\n end\n \n -- did we cross a week boundary (Sunday)?\n + case\n when {{first_date}} < {{second_date}} and dayofweek({{second_date}}) < dayofweek({{first_date}}) then 1\n when {{first_date}} > {{second_date}} and dayofweek({{second_date}}) > dayofweek({{first_date}}) then -1\n else 0 end\n\n {%- elif datepart == 'month' -%}\n\n case when {{first_date}} < {{second_date}}\n then floor(months_between(date({{second_date}}), date({{first_date}})))\n else ceil(months_between(date({{second_date}}), date({{first_date}})))\n end\n \n -- did we cross a month boundary?\n + case\n when {{first_date}} < {{second_date}} and dayofmonth({{second_date}}) < dayofmonth({{first_date}}) then 1\n when {{first_date}} > {{second_date}} and dayofmonth({{second_date}}) > dayofmonth({{first_date}}) then -1\n else 0 end\n \n {%- elif datepart == 'quarter' -%}\n \n case when {{first_date}} < {{second_date}}\n then floor(months_between(date({{second_date}}), date({{first_date}}))/3)\n else ceil(months_between(date({{second_date}}), date({{first_date}}))/3)\n end\n \n -- did we cross a quarter boundary?\n + case\n when {{first_date}} < {{second_date}} and (\n (dayofyear({{second_date}}) - (quarter({{second_date}}) * 365/4))\n < (dayofyear({{first_date}}) - (quarter({{first_date}}) * 365/4))\n ) then 1\n when {{first_date}} > {{second_date}} and (\n (dayofyear({{second_date}}) - (quarter({{second_date}}) * 365/4))\n > (dayofyear({{first_date}}) - (quarter({{first_date}}) * 365/4))\n ) then -1\n else 0 end\n\n {%- elif datepart == 'year' -%}\n \n year({{second_date}}) - year({{first_date}})\n\n {%- elif datepart in ('hour', 'minute', 'second', 'millisecond', 'microsecond') -%}\n \n {%- set divisor -%} \n {%- if datepart == 'hour' -%} 3600\n {%- elif datepart == 'minute' -%} 60\n {%- elif datepart == 'second' -%} 1\n {%- elif datepart == 'millisecond' -%} (1/1000)\n {%- elif datepart == 'microsecond' -%} (1/1000000)\n {%- endif -%}\n {%- endset -%}\n\n case when {{first_date}} < {{second_date}}\n then ceil((\n {# make sure the timestamps are real, otherwise raise an error asap #}\n {{ spark_utils.assert_not_null('to_unix_timestamp', second_date) }}\n - {{ spark_utils.assert_not_null('to_unix_timestamp', first_date) }}\n ) / {{divisor}})\n else floor((\n {{ spark_utils.assert_not_null('to_unix_timestamp', second_date) }}\n - {{ spark_utils.assert_not_null('to_unix_timestamp', first_date) }}\n ) / {{divisor}})\n end\n \n {% if datepart == 'millisecond' %}\n + cast(date_format({{second_date}}, 'SSS') as int)\n - cast(date_format({{first_date}}, 'SSS') as int)\n {% endif %}\n \n {% if datepart == 'microsecond' %} \n {% set capture_str = '[0-9]{4}-[0-9]{2}-[0-9]{2}.[0-9]{2}:[0-9]{2}:[0-9]{2}.([0-9]{6})' %}\n -- Spark doesn't really support microseconds, so this is a massive hack!\n -- It will only work if the timestamp-string is of the format\n -- 'yyyy-MM-dd-HH mm.ss.SSSSSS'\n + cast(regexp_extract({{second_date}}, '{{capture_str}}', 1) as int)\n - cast(regexp_extract({{first_date}}, '{{capture_str}}', 1) as int) \n {% endif %}\n\n {%- else -%}\n\n {{ exceptions.raise_compiler_error(\"macro datediff not implemented for datepart ~ '\" ~ datepart ~ \"' ~ on Spark\") }}\n\n {%- endif -%}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.spark_utils.spark__current_timestamp": {"unique_id": "macro.spark_utils.spark__current_timestamp", "package_name": "spark_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/spark_utils", "path": "macros/dbt_utils/cross_db_utils/current_timestamp.sql", "original_file_path": "macros/dbt_utils/cross_db_utils/current_timestamp.sql", "name": "spark__current_timestamp", "macro_sql": "{% macro spark__current_timestamp() %}\n current_timestamp()\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.spark_utils.spark__current_timestamp_in_utc": {"unique_id": "macro.spark_utils.spark__current_timestamp_in_utc", "package_name": "spark_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/spark_utils", "path": "macros/dbt_utils/cross_db_utils/current_timestamp.sql", "original_file_path": "macros/dbt_utils/cross_db_utils/current_timestamp.sql", "name": "spark__current_timestamp_in_utc", "macro_sql": "{% macro spark__current_timestamp_in_utc() %}\n unix_timestamp()\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.spark_utils.spark__split_part": {"unique_id": "macro.spark_utils.spark__split_part", "package_name": "spark_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/spark_utils", "path": "macros/dbt_utils/cross_db_utils/split_part.sql", "original_file_path": "macros/dbt_utils/cross_db_utils/split_part.sql", "name": "spark__split_part", "macro_sql": "{% macro spark__split_part(string_text, delimiter_text, part_number) %}\n\n {% set delimiter_expr %}\n \n -- escape if starts with a special character\n case when regexp_extract({{ delimiter_text }}, '([^A-Za-z0-9])(.*)', 1) != '_'\n then concat('\\\\', {{ delimiter_text }})\n else {{ delimiter_text }} end\n \n {% endset %}\n\n {% set split_part_expr %}\n \n split(\n {{ string_text }},\n {{ delimiter_expr }}\n )[({{ part_number - 1 }})]\n \n {% endset %}\n \n {{ return(split_part_expr) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.spark_utils.spark__get_relations_by_pattern": {"unique_id": "macro.spark_utils.spark__get_relations_by_pattern", "package_name": "spark_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/spark_utils", "path": "macros/dbt_utils/sql/get_relations_by_prefix.sql", "original_file_path": "macros/dbt_utils/sql/get_relations_by_prefix.sql", "name": "spark__get_relations_by_pattern", "macro_sql": "{% macro spark__get_relations_by_pattern(schema_pattern, table_pattern, exclude='', database=target.database) %}\n\n {%- call statement('get_tables', fetch_result=True) %}\n\n show table extended in {{ schema_pattern }} like '{{ table_pattern }}'\n\n {%- endcall -%}\n\n {%- set table_list = load_result('get_tables') -%}\n\n {%- if table_list and table_list['table'] -%}\n {%- set tbl_relations = [] -%}\n {%- for row in table_list['table'] -%}\n {%- set tbl_relation = api.Relation.create(\n database=None,\n schema=row[0],\n identifier=row[1],\n type=('view' if 'Type: VIEW' in row[3] else 'table')\n ) -%}\n {%- do tbl_relations.append(tbl_relation) -%}\n {%- endfor -%}\n\n {{ return(tbl_relations) }}\n {%- else -%}\n {{ return([]) }}\n {%- endif -%}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.spark_utils.spark__get_relations_by_prefix": {"unique_id": "macro.spark_utils.spark__get_relations_by_prefix", "package_name": "spark_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/spark_utils", "path": "macros/dbt_utils/sql/get_relations_by_prefix.sql", "original_file_path": "macros/dbt_utils/sql/get_relations_by_prefix.sql", "name": "spark__get_relations_by_prefix", "macro_sql": "{% macro spark__get_relations_by_prefix(schema_pattern, table_pattern, exclude='', database=target.database) %}\n {% set table_pattern = table_pattern ~ '*' %}\n {{ return(spark_utils.spark__get_relations_by_pattern(schema_pattern, table_pattern, exclude='', database=target.database)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.spark_utils.spark__get_tables_by_pattern": {"unique_id": "macro.spark_utils.spark__get_tables_by_pattern", "package_name": "spark_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/spark_utils", "path": "macros/dbt_utils/sql/get_relations_by_prefix.sql", "original_file_path": "macros/dbt_utils/sql/get_relations_by_prefix.sql", "name": "spark__get_tables_by_pattern", "macro_sql": "{% macro spark__get_tables_by_pattern(schema_pattern, table_pattern, exclude='', database=target.database) %}\n {{ return(spark_utils.spark__get_relations_by_pattern(schema_pattern, table_pattern, exclude='', database=target.database)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.spark_utils.spark__get_tables_by_prefix": {"unique_id": "macro.spark_utils.spark__get_tables_by_prefix", "package_name": "spark_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/spark_utils", "path": "macros/dbt_utils/sql/get_relations_by_prefix.sql", "original_file_path": "macros/dbt_utils/sql/get_relations_by_prefix.sql", "name": "spark__get_tables_by_prefix", "macro_sql": "{% macro spark__get_tables_by_prefix(schema_pattern, table_pattern, exclude='', database=target.database) %}\n {{ return(spark_utils.spark__get_relations_by_prefix(schema_pattern, table_pattern, exclude='', database=target.database)) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.spark_utils.assert_not_null": {"unique_id": "macro.spark_utils.assert_not_null", "package_name": "spark_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/spark_utils", "path": "macros/etc/assert_not_null.sql", "original_file_path": "macros/etc/assert_not_null.sql", "name": "assert_not_null", "macro_sql": "{% macro assert_not_null(function, arg) %}\n\n coalesce({{function}}({{arg}}), nvl2({{function}}({{arg}}), assert_true({{function}}({{arg}}) is not null), null))\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.spark_utils.spark__convert_timezone": {"unique_id": "macro.spark_utils.spark__convert_timezone", "package_name": "spark_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/spark_utils", "path": "macros/snowplow/convert_timezone.sql", "original_file_path": "macros/snowplow/convert_timezone.sql", "name": "spark__convert_timezone", "macro_sql": "{% macro spark__convert_timezone(in_tz, out_tz, in_timestamp) %}\n from_utc_timestamp(to_utc_timestamp({{in_timestamp}}, {{in_tz}}), {{out_tz}})\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.enabled_vars": {"unique_id": "macro.fivetran_utils.enabled_vars", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/enabled_vars.sql", "original_file_path": "macros/enabled_vars.sql", "name": "enabled_vars", "macro_sql": "{% macro enabled_vars(vars) %}\n\n{% for v in vars %}\n \n {% if var(v, True) == False %}\n {{ return(False) }}\n {% endif %}\n\n{% endfor %}\n\n{{ return(True) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.percentile": {"unique_id": "macro.fivetran_utils.percentile", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/percentile.sql", "original_file_path": "macros/percentile.sql", "name": "percentile", "macro_sql": "{% macro percentile(percentile_field, partition_field, percent) -%}\n\n{{ adapter.dispatch('percentile', packages = fivetran_utils._get_utils_namespaces()) (percentile_field, partition_field, percent) }}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.default__percentile": {"unique_id": "macro.fivetran_utils.default__percentile", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/percentile.sql", "original_file_path": "macros/percentile.sql", "name": "default__percentile", "macro_sql": "{% macro default__percentile(percentile_field, partition_field, percent) %}\n\n percentile_cont( \n {{ percent }} )\n within group ( order by {{ percentile_field }} )\n over ( partition by {{ partition_field }} )\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.bigquery__percentile": {"unique_id": "macro.fivetran_utils.bigquery__percentile", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/percentile.sql", "original_file_path": "macros/percentile.sql", "name": "bigquery__percentile", "macro_sql": "{% macro bigquery__percentile(percentile_field, partition_field, percent) %}\n\n percentile_cont( \n {{ percentile_field }}, \n {{ percent }}) \n over (partition by {{ partition_field }} \n )\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.pivot_json_extract": {"unique_id": "macro.fivetran_utils.pivot_json_extract", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/pivot_json_extract.sql", "original_file_path": "macros/pivot_json_extract.sql", "name": "pivot_json_extract", "macro_sql": "{% macro pivot_json_extract(string, list_of_properties) %}\n\n{%- for property in list_of_properties -%}\n\nreplace( {{ fivetran_utils.json_extract(string, property) }}, '\"', '') as {{ property | replace(' ', '_') | lower }}\n\n{%- if not loop.last -%},{%- endif %}\n{% endfor -%}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.max_bool": {"unique_id": "macro.fivetran_utils.max_bool", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/max_bool.sql", "original_file_path": "macros/max_bool.sql", "name": "max_bool", "macro_sql": "{% macro max_bool(boolean_field) -%}\n\n{{ adapter.dispatch('max_bool', packages = fivetran_utils._get_utils_namespaces()) (boolean_field) }}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.default__max_bool": {"unique_id": "macro.fivetran_utils.default__max_bool", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/max_bool.sql", "original_file_path": "macros/max_bool.sql", "name": "default__max_bool", "macro_sql": "{% macro default__max_bool(boolean_field) %}\n\n bool_or( {{ boolean_field }} )\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.snowflake__max_bool": {"unique_id": "macro.fivetran_utils.snowflake__max_bool", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/max_bool.sql", "original_file_path": "macros/max_bool.sql", "name": "snowflake__max_bool", "macro_sql": "{% macro snowflake__max_bool(boolean_field) %}\n\n max( {{ boolean_field }} )\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.bigquery__max_bool": {"unique_id": "macro.fivetran_utils.bigquery__max_bool", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/max_bool.sql", "original_file_path": "macros/max_bool.sql", "name": "bigquery__max_bool", "macro_sql": "{% macro bigquery__max_bool(boolean_field) %}\n\n max( {{ boolean_field }} )\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.seed_data_helper": {"unique_id": "macro.fivetran_utils.seed_data_helper", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/seed_data_helper.sql", "original_file_path": "macros/seed_data_helper.sql", "name": "seed_data_helper", "macro_sql": "{% macro seed_data_helper(seed_name, warehouses) %}\n\n{% if target.type in warehouses %}\n {% for w in warehouses %}\n {% if target.type == w %}\n {{ return(ref(seed_name ~ \"_\" ~ w ~ \"\")) }}\n {% endif %}\n {% endfor %}\n{% else %}\n{{ return(ref(seed_name)) }}\n{% endif %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.fill_pass_through_columns": {"unique_id": "macro.fivetran_utils.fill_pass_through_columns", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/fill_pass_through_columns.sql", "original_file_path": "macros/fill_pass_through_columns.sql", "name": "fill_pass_through_columns", "macro_sql": "{% macro fill_pass_through_columns(pass_through_variable) %}\n\n{% if var(pass_through_variable) %}\n {% for field in var(pass_through_variable) %}\n {% if field.transform_sql %}\n , {{ field.transform_sql }} as {{ field.alias if field.alias else field.name }}\n {% else %}\n , {{ field.alias if field.alias else field.name }}\n {% endif %}\n {% endfor %}\n{% endif %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.string_agg": {"unique_id": "macro.fivetran_utils.string_agg", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/string_agg.sql", "original_file_path": "macros/string_agg.sql", "name": "string_agg", "macro_sql": "{% macro string_agg(field_to_agg, delimiter) -%}\n\n{{ adapter.dispatch('string_agg', packages = fivetran_utils._get_utils_namespaces()) (field_to_agg, delimiter) }}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.default__string_agg": {"unique_id": "macro.fivetran_utils.default__string_agg", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/string_agg.sql", "original_file_path": "macros/string_agg.sql", "name": "default__string_agg", "macro_sql": "{% macro default__string_agg(field_to_agg, delimiter) %}\n string_agg({{ field_to_agg }}, {{ delimiter }})\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.snowflake__string_agg": {"unique_id": "macro.fivetran_utils.snowflake__string_agg", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/string_agg.sql", "original_file_path": "macros/string_agg.sql", "name": "snowflake__string_agg", "macro_sql": "{% macro snowflake__string_agg(field_to_agg, delimiter) %}\n listagg({{ field_to_agg }}, {{ delimiter }})\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.redshift__string_agg": {"unique_id": "macro.fivetran_utils.redshift__string_agg", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/string_agg.sql", "original_file_path": "macros/string_agg.sql", "name": "redshift__string_agg", "macro_sql": "{% macro redshift__string_agg(field_to_agg, delimiter) %}\n listagg({{ field_to_agg }}, {{ delimiter }})\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.timestamp_diff": {"unique_id": "macro.fivetran_utils.timestamp_diff", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/timestamp_diff.sql", "original_file_path": "macros/timestamp_diff.sql", "name": "timestamp_diff", "macro_sql": "{% macro timestamp_diff(first_date, second_date, datepart) %}\n {{ adapter.dispatch('datediff', packages = fivetran_utils._get_utils_namespaces())(first_date, second_date, datepart) }}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.default__timestamp_diff": {"unique_id": "macro.fivetran_utils.default__timestamp_diff", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/timestamp_diff.sql", "original_file_path": "macros/timestamp_diff.sql", "name": "default__timestamp_diff", "macro_sql": "{% macro default__timestamp_diff(first_date, second_date, datepart) %}\n\n datediff(\n {{ datepart }},\n {{ first_date }},\n {{ second_date }}\n )\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.bigquery__timestamp_diff": {"unique_id": "macro.fivetran_utils.bigquery__timestamp_diff", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/timestamp_diff.sql", "original_file_path": "macros/timestamp_diff.sql", "name": "bigquery__timestamp_diff", "macro_sql": "{% macro bigquery__timestamp_diff(first_date, second_date, datepart) %}\n\n timestamp_diff(\n {{second_date}},\n {{first_date}},\n {{datepart}}\n )\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.postgres__datediff": {"unique_id": "macro.fivetran_utils.postgres__datediff", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/timestamp_diff.sql", "original_file_path": "macros/timestamp_diff.sql", "name": "postgres__datediff", "macro_sql": "{% macro postgres__datediff(first_date, second_date, datepart) %}\n\n {% if datepart == 'year' %}\n (date_part('year', ({{second_date}})::date) - date_part('year', ({{first_date}})::date))\n {% elif datepart == 'quarter' %}\n ({{ dbt_utils.datediff(first_date, second_date, 'year') }} * 4 + date_part('quarter', ({{second_date}})::date) - date_part('quarter', ({{first_date}})::date))\n {% elif datepart == 'month' %}\n ({{ dbt_utils.datediff(first_date, second_date, 'year') }} * 12 + date_part('month', ({{second_date}})::date) - date_part('month', ({{first_date}})::date))\n {% elif datepart == 'day' %}\n (({{second_date}})::date - ({{first_date}})::date)\n {% elif datepart == 'week' %}\n ({{ dbt_utils.datediff(first_date, second_date, 'day') }} / 7 + case\n when date_part('dow', ({{first_date}})::timestamp) <= date_part('dow', ({{second_date}})::timestamp) then\n case when {{first_date}} <= {{second_date}} then 0 else -1 end\n else\n case when {{first_date}} <= {{second_date}} then 1 else 0 end\n end)\n {% elif datepart == 'hour' %}\n ({{ dbt_utils.datediff(first_date, second_date, 'day') }} * 24 + date_part('hour', ({{second_date}})::timestamp) - date_part('hour', ({{first_date}})::timestamp))\n {% elif datepart == 'minute' %}\n ({{ dbt_utils.datediff(first_date, second_date, 'hour') }} * 60 + date_part('minute', ({{second_date}})::timestamp) - date_part('minute', ({{first_date}})::timestamp))\n {% elif datepart == 'second' %}\n ({{ dbt_utils.datediff(first_date, second_date, 'minute') }} * 60 + floor(date_part('second', ({{second_date}})::timestamp)) - floor(date_part('second', ({{first_date}})::timestamp)))\n {% elif datepart == 'millisecond' %}\n ({{ dbt_utils.datediff(first_date, second_date, 'minute') }} * 60000 + floor(date_part('millisecond', ({{second_date}})::timestamp)) - floor(date_part('millisecond', ({{first_date}})::timestamp)))\n {% elif datepart == 'microsecond' %}\n ({{ dbt_utils.datediff(first_date, second_date, 'minute') }} * 60000000 + floor(date_part('microsecond', ({{second_date}})::timestamp)) - floor(date_part('microsecond', ({{first_date}})::timestamp)))\n {% else %}\n {{ exceptions.raise_compiler_error(\"Unsupported datepart for macro datediff in postgres: {!r}\".format(datepart)) }}\n {% endif %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.generate_columns_macro": {"unique_id": "macro.fivetran_utils.generate_columns_macro", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/generate_columns_macro.sql", "original_file_path": "macros/generate_columns_macro.sql", "name": "generate_columns_macro", "macro_sql": "{% macro generate_columns_macro(table_name, schema_name, database_name=target.database) %}\n\n{% set columns = get_columns_for_macro(table_name, schema_name, database_name) %}\n\n{% set jinja_macro=[] %}\n\n{% do jinja_macro.append('{% macro get_' ~ table_name ~ '_columns() %}') %}\n{% do jinja_macro.append('') %}\n{% do jinja_macro.append('{% set columns = [') %}\n\n{% for col in columns %}\n{% do jinja_macro.append(' ' ~ col ~ (',' if not loop.last)) %}\n{% endfor %}\n\n{% do jinja_macro.append('] %}') %}\n{% do jinja_macro.append('') %}\n{% do jinja_macro.append('{{ return(columns) }}') %}\n{% do jinja_macro.append('') %}\n{% do jinja_macro.append('{% endmacro %}') %}\n\n{% if execute %}\n\n {% set joined = jinja_macro | join ('\\n') %}\n {{ log(joined, info=True) }}\n {% do return(joined) %}\n\n{% endif %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.first_value": {"unique_id": "macro.fivetran_utils.first_value", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/first_value.sql", "original_file_path": "macros/first_value.sql", "name": "first_value", "macro_sql": "{% macro first_value(first_value_field, partition_field, order_by_field, order=\"asc\") -%}\n\n{{ adapter.dispatch('first_value', packages = fivetran_utils._get_utils_namespaces()) (first_value_field, partition_field, order_by_field, order) }}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.default__first_value": {"unique_id": "macro.fivetran_utils.default__first_value", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/first_value.sql", "original_file_path": "macros/first_value.sql", "name": "default__first_value", "macro_sql": "{% macro default__first_value(first_value_field, partition_field, order_by_field, order=\"asc\") %}\n\n first_value( {{ first_value_field }} ignore nulls ) over (partition by {{ partition_field }} order by {{ order_by_field }} {{ order }} )\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.redshift__first_value": {"unique_id": "macro.fivetran_utils.redshift__first_value", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/first_value.sql", "original_file_path": "macros/first_value.sql", "name": "redshift__first_value", "macro_sql": "{% macro redshift__first_value(first_value_field, partition_field, order_by_field, order=\"asc\") %}\n\n first_value( {{ first_value_field }} ignore nulls ) over (partition by {{ partition_field }} order by {{ order_by_field }} {{ order }} , {{ partition_field }} rows unbounded preceding )\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.add_pass_through_columns": {"unique_id": "macro.fivetran_utils.add_pass_through_columns", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/add_pass_through_columns.sql", "original_file_path": "macros/add_pass_through_columns.sql", "name": "add_pass_through_columns", "macro_sql": "{% macro add_pass_through_columns(base_columns, pass_through_var) %}\n\n {% if pass_through_var %}\n\n {% for column in pass_through_var %}\n\n {% do base_columns.append({ \"name\": column.name, \"alias\": column.alias }) if column.alias else base_columns.append({ \"name\": column.name }) %}\n\n {% endfor %}\n\n {% endif %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.staging_models_automation": {"unique_id": "macro.fivetran_utils.staging_models_automation", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/staging_models_automation.sql", "original_file_path": "macros/staging_models_automation.sql", "name": "staging_models_automation", "macro_sql": "{% macro staging_models_automation(package, source_schema, source_database, tables) %}\n\n{% set package = \"\"~ package ~\"\" %}\n{% set source_schema = \"\"~ source_schema ~\"\" %}\n{% set source_database = \"\"~ source_database ~\"\" %}\n\n{% set zsh_command = \"source dbt_modules/fivetran_utils/columns_setup.sh '../dbt_\"\"\"~ package ~\"\"\"_source' stg_\"\"\"~ package ~\"\"\" \"\"\"~ source_database ~\"\"\" \"\"\"~ source_schema ~\"\"\" \" %}\n\n{% for t in tables %}\n {% if t != tables[-1] %}\n {% set help_command = zsh_command + t + \" && \\n\" %}\n\n {% else %}\n {% set help_command = zsh_command + t %}\n\n {% endif %}\n {{ log(help_command, info=True) }}\n\n{% endfor %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.union_relations": {"unique_id": "macro.fivetran_utils.union_relations", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/union_relations.sql", "original_file_path": "macros/union_relations.sql", "name": "union_relations", "macro_sql": "{%- macro union_relations(relations, aliases=none, column_override=none, include=[], exclude=[], source_column_name=none) -%}\n\n {%- if exclude and include -%}\n {{ exceptions.raise_compiler_error(\"Both an exclude and include list were provided to the `union` macro. Only one is allowed\") }}\n {%- endif -%}\n\n {#-- Prevent querying of db in parsing mode. This works because this macro does not create any new refs. -#}\n {%- if not execute %}\n {{ return('') }}\n {% endif -%}\n\n {%- set column_override = column_override if column_override is not none else {} -%}\n {%- set source_column_name = source_column_name if source_column_name is not none else '_dbt_source_relation' -%}\n\n {%- set relation_columns = {} -%}\n {%- set column_superset = {} -%}\n\n {%- for relation in relations -%}\n\n {%- do relation_columns.update({relation: []}) -%}\n\n {%- do dbt_utils._is_relation(relation, 'union_relations') -%}\n {%- set cols = adapter.get_columns_in_relation(relation) -%}\n {%- for col in cols -%}\n\n {#- If an exclude list was provided and the column is in the list, do nothing -#}\n {%- if exclude and col.column in exclude -%}\n\n {#- If an include list was provided and the column is not in the list, do nothing -#}\n {%- elif include and col.column not in include -%}\n\n {#- Otherwise add the column to the column superset -#}\n {%- else -%}\n\n {#- update the list of columns in this relation -#}\n {%- do relation_columns[relation].append(col.column) -%}\n\n {%- if col.column in column_superset -%}\n\n {%- set stored = column_superset[col.column] -%}\n {%- if col.is_string() and stored.is_string() and col.string_size() > stored.string_size() -%}\n\n {%- do column_superset.update({col.column: col}) -%}\n\n {%- endif %}\n\n {%- else -%}\n\n {%- do column_superset.update({col.column: col}) -%}\n\n {%- endif -%}\n\n {%- endif -%}\n\n {%- endfor -%}\n {%- endfor -%}\n\n {%- set ordered_column_names = column_superset.keys() -%}\n\n {%- for relation in relations %}\n\n (\n select\n\n cast({{ dbt_utils.string_literal(relation) }} as {{ dbt_utils.type_string() }}) as {{ source_column_name }},\n {% for col_name in ordered_column_names -%}\n\n {%- set col = column_superset[col_name] %}\n {%- set col_type = column_override.get(col.column, col.data_type) %}\n {%- set col_name = adapter.quote(col_name) if col_name in relation_columns[relation] else 'null' %}\n cast({{ col_name }} as {{ col_type }}) as {{ col.quoted }} {% if not loop.last %},{% endif -%}\n\n {%- endfor %}\n\n from {{ aliases[loop.index0] if aliases else relation }}\n )\n\n {% if not loop.last -%}\n union all\n {% endif -%}\n\n {%- endfor -%}\n\n{%- endmacro -%}\n\n", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.union_tables": {"unique_id": "macro.fivetran_utils.union_tables", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/union_relations.sql", "original_file_path": "macros/union_relations.sql", "name": "union_tables", "macro_sql": "{%- macro union_tables(tables, column_override=none, include=[], exclude=[], source_column_name='_dbt_source_table') -%}\n\n {%- do exceptions.warn(\"Warning: the `union_tables` macro is no longer supported and will be deprecated in a future release of dbt-utils. Use the `union_relations` macro instead\") -%}\n\n {{ return(dbt_utils.union_relations(tables, column_override, include, exclude, source_column_name)) }}\n\n{%- endmacro -%}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.snowflake_seed_data": {"unique_id": "macro.fivetran_utils.snowflake_seed_data", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/snowflake_seed_data.sql", "original_file_path": "macros/snowflake_seed_data.sql", "name": "snowflake_seed_data", "macro_sql": "{% macro snowflake_seed_data(seed_name) %}\n\n{% if target.type == 'snowflake' %}\n{{ return(ref(seed_name ~ '_snowflake')) }}\n{% else %}\n{{ return(ref(seed_name)) }}\n{% endif %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.snowflake__get_columns_for_macro": {"unique_id": "macro.fivetran_utils.snowflake__get_columns_for_macro", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/get_columns_for_macro.sql", "original_file_path": "macros/get_columns_for_macro.sql", "name": "snowflake__get_columns_for_macro", "macro_sql": "{% macro snowflake__get_columns_for_macro(table_name, schema_name, database_name=target.database) %}\n\n{% set query %}\n\nselect\n concat(\n '{\"name\": \"', \n lower(column_name), \n '\", \"datatype\": ',\n case\n when lower(data_type) like '%timestamp%' then 'dbt_utils.type_timestamp()' \n when lower(data_type) = 'text' then 'dbt_utils.type_string()' \n when lower(data_type) = 'boolean' then '\"boolean\"'\n when lower(data_type) = 'number' then 'dbt_utils.type_numeric()' \n when lower(data_type) = 'float' then 'dbt_utils.type_float()' \n when lower(data_type) = 'date' then '\"date\"'\n end,\n '}')\nfrom {{ database_name }}.information_schema.columns\nwhere lower(table_name) = '{{ table_name }}'\nand lower(table_schema) = '{{ schema_name }}'\norder by 1\n\n{% endset %}\n\n{% set results = run_query(query) %}\n{% set results_list = results.columns[0].values() %}}\n\n{{ return(results_list) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.bigquery__get_columns_for_macro": {"unique_id": "macro.fivetran_utils.bigquery__get_columns_for_macro", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/get_columns_for_macro.sql", "original_file_path": "macros/get_columns_for_macro.sql", "name": "bigquery__get_columns_for_macro", "macro_sql": "{% macro bigquery__get_columns_for_macro(table_name, schema_name, database_name=target.database) %}\n\n{% set query %}\n\nselect\n concat(\n '{\"name\": \"', \n lower(column_name), \n '\", \"datatype\": ',\n case\n when lower(data_type) like '%timestamp%' then 'dbt_utils.type_timestamp()' \n when lower(data_type) = 'string' then 'dbt_utils.type_string()' \n when lower(data_type) = 'bool' then '\"boolean\"'\n when lower(data_type) = 'numeric' then 'dbt_utils.type_numeric()' \n when lower(data_type) = 'float64' then 'dbt_utils.type_float()' \n when lower(data_type) = 'int64' then 'dbt_utils.type_int()' \n when lower(data_type) = 'date' then '\"date\"' \n when lower(data_type) = 'datetime' then '\"datetime\"' \n end,\n '}')\nfrom `{{ database_name }}`.{{ schema_name }}.INFORMATION_SCHEMA.COLUMNS\nwhere lower(table_name) = '{{ table_name }}'\nand lower(table_schema) = '{{ schema_name }}'\norder by 1\n\n{% endset %}\n\n{% set results = run_query(query) %}\n{% set results_list = results.columns[0].values() %}}\n\n{{ return(results_list) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.get_columns_for_macro": {"unique_id": "macro.fivetran_utils.get_columns_for_macro", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/get_columns_for_macro.sql", "original_file_path": "macros/get_columns_for_macro.sql", "name": "get_columns_for_macro", "macro_sql": "{% macro get_columns_for_macro(table_name, schema_name, database_name) -%}\n {{ return(adapter.dispatch('get_columns_for_macro')(table_name, schema_name, database_name)) }}\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.fill_staging_columns": {"unique_id": "macro.fivetran_utils.fill_staging_columns", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/fill_staging_columns.sql", "original_file_path": "macros/fill_staging_columns.sql", "name": "fill_staging_columns", "macro_sql": "{% macro fill_staging_columns(source_columns, staging_columns) -%}\n\n{%- set source_column_names = source_columns|map(attribute='name')|map('lower')|list -%}\n\n{%- for column in staging_columns %}\n {% if column.name|lower in source_column_names -%}\n {{ fivetran_utils.quote_column(column) }} as \n {%- if 'alias' in column %} {{ column.alias }} {% else %} {{ fivetran_utils.quote_column(column) }} {%- endif -%}\n {%- else -%}\n cast(null as {{ column.datatype }})\n {%- if 'alias' in column %} as {{ column.alias }} {% else %} as {{ fivetran_utils.quote_column(column) }} {% endif -%}\n {%- endif -%}\n {%- if not loop.last -%} , {% endif -%}\n{% endfor %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.quote_column": {"unique_id": "macro.fivetran_utils.quote_column", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/fill_staging_columns.sql", "original_file_path": "macros/fill_staging_columns.sql", "name": "quote_column", "macro_sql": "{% macro quote_column(column) %}\n {% if 'quote' in column %}\n {% if column.quote %}\n {% if target.type == 'bigquery' %}\n `{{ column.name }}`\n {% elif target.type == 'snowflake' %}\n \"{{ column.name | upper }}\"\n {% else %}\n \"{{ column.name }}\"\n {% endif %}\n {% else %}\n {{ column.name }}\n {% endif %}\n {% else %}\n {{ column.name }}\n {% endif %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.json_extract": {"unique_id": "macro.fivetran_utils.json_extract", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/json_extract.sql", "original_file_path": "macros/json_extract.sql", "name": "json_extract", "macro_sql": "{% macro json_extract(string, string_path) -%}\n\n{{ adapter.dispatch('json_extract', packages = fivetran_utils._get_utils_namespaces()) (string, string_path) }}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.default__json_extract": {"unique_id": "macro.fivetran_utils.default__json_extract", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/json_extract.sql", "original_file_path": "macros/json_extract.sql", "name": "default__json_extract", "macro_sql": "{% macro default__json_extract(string, string_path) %}\n\n json_extract_path_text({{string}}, {{ \"'\" ~ string_path ~ \"'\" }} )\n \n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.bigquery__json_extract": {"unique_id": "macro.fivetran_utils.bigquery__json_extract", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/json_extract.sql", "original_file_path": "macros/json_extract.sql", "name": "bigquery__json_extract", "macro_sql": "{% macro bigquery__json_extract(string, string_path) %}\n\n json_extract_scalar({{string}}, {{ \"'$.\" ~ string_path ~ \"'\" }} )\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.postgres__json_extract": {"unique_id": "macro.fivetran_utils.postgres__json_extract", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/json_extract.sql", "original_file_path": "macros/json_extract.sql", "name": "postgres__json_extract", "macro_sql": "{% macro postgres__json_extract(string, string_path) %}\n\n {{string}}::json->>{{\"'\" ~ string_path ~ \"'\" }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.timestamp_add": {"unique_id": "macro.fivetran_utils.timestamp_add", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/timestamp_add.sql", "original_file_path": "macros/timestamp_add.sql", "name": "timestamp_add", "macro_sql": "{% macro timestamp_add(datepart, interval, from_timestamp) -%}\n\n{{ adapter.dispatch('timestamp_add', packages = fivetran_utils._get_utils_namespaces()) (datepart, interval, from_timestamp) }}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.default__timestamp_add": {"unique_id": "macro.fivetran_utils.default__timestamp_add", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/timestamp_add.sql", "original_file_path": "macros/timestamp_add.sql", "name": "default__timestamp_add", "macro_sql": "{% macro default__timestamp_add(datepart, interval, from_timestamp) %}\n\n timestampadd(\n {{ datepart }},\n {{ interval }},\n {{ from_timestamp }}\n )\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.bigquery__timestamp_add": {"unique_id": "macro.fivetran_utils.bigquery__timestamp_add", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/timestamp_add.sql", "original_file_path": "macros/timestamp_add.sql", "name": "bigquery__timestamp_add", "macro_sql": "{% macro bigquery__timestamp_add(datepart, interval, from_timestamp) %}\n\n timestamp_add({{ from_timestamp }}, interval {{ interval }} {{ datepart }})\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.redshift__timestamp_add": {"unique_id": "macro.fivetran_utils.redshift__timestamp_add", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/timestamp_add.sql", "original_file_path": "macros/timestamp_add.sql", "name": "redshift__timestamp_add", "macro_sql": "{% macro redshift__timestamp_add(datepart, interval, from_timestamp) %}\n\n dateadd(\n {{ datepart }},\n {{ interval }},\n {{ from_timestamp }}\n )\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.postgres__timestamp_add": {"unique_id": "macro.fivetran_utils.postgres__timestamp_add", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/timestamp_add.sql", "original_file_path": "macros/timestamp_add.sql", "name": "postgres__timestamp_add", "macro_sql": "{% macro postgres__timestamp_add(datepart, interval, from_timestamp) %}\n\n {{ from_timestamp }} + ((interval '1 {{ datepart }}') * ({{ interval }}))\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.spark__timestamp_add": {"unique_id": "macro.fivetran_utils.spark__timestamp_add", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/timestamp_add.sql", "original_file_path": "macros/timestamp_add.sql", "name": "spark__timestamp_add", "macro_sql": "{% macro spark__timestamp_add(datepart, interval, from_timestamp) %}\n\n {{ dbt_utils.dateadd(datepart, interval, from_timestamp) }}\n \n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.ceiling": {"unique_id": "macro.fivetran_utils.ceiling", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/ceiling.sql", "original_file_path": "macros/ceiling.sql", "name": "ceiling", "macro_sql": "{% macro ceiling(num) -%}\n\n{{ adapter.dispatch('ceiling', packages = fivetran_utils._get_utils_namespaces()) (num) }}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.default__ceiling": {"unique_id": "macro.fivetran_utils.default__ceiling", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/ceiling.sql", "original_file_path": "macros/ceiling.sql", "name": "default__ceiling", "macro_sql": "{% macro default__ceiling(num) %}\n ceiling({{ num }})\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.snowflake__ceiling": {"unique_id": "macro.fivetran_utils.snowflake__ceiling", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/ceiling.sql", "original_file_path": "macros/ceiling.sql", "name": "snowflake__ceiling", "macro_sql": "{% macro snowflake__ceiling(num) %}\n ceil({{ num }})\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.remove_prefix_from_columns": {"unique_id": "macro.fivetran_utils.remove_prefix_from_columns", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/remove_prefix_from_columns.sql", "original_file_path": "macros/remove_prefix_from_columns.sql", "name": "remove_prefix_from_columns", "macro_sql": "{% macro remove_prefix_from_columns(columns, prefix='', exclude=[]) %}\n\n {%- for col in columns if col.name not in exclude -%}\n {%- if col.name[:prefix|length]|lower == prefix -%}\n {{ col.name }} as {{ col.name[prefix|length:] }}\n {%- else -%}\n {{ col.name }}\n {%- endif -%}\n {%- if not loop.last -%},{%- endif %}\n {% endfor -%}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.dummy_coalesce_value": {"unique_id": "macro.fivetran_utils.dummy_coalesce_value", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/dummy_coalesce_value.sql", "original_file_path": "macros/dummy_coalesce_value.sql", "name": "dummy_coalesce_value", "macro_sql": "{% macro dummy_coalesce_value(column) %}\n\n{% set coalesce_value = {\n 'STRING': \"'DUMMY_STRING'\",\n 'BOOLEAN': 'null',\n 'INT': 999999999,\n 'FLOAT': 999999999.99,\n 'TIMESTAMP': 'cast(\"2099-12-31\" as timestamp)',\n 'DATE': 'cast(\"2099-12-31\" as date)',\n} %}\n\n{% if column.is_float() %}\n{{ return(coalesce_value['FLOAT']) }}\n\n{% elif column.is_numeric() %}\n{{ return(coalesce_value['INT']) }}\n\n{% elif column.is_string() %}\n{{ return(coalesce_value['STRING']) }}\n\n{% elif column.data_type|lower == 'boolean' %}\n{{ return(coalesce_value['BOOLEAN']) }}\n\n{% elif 'timestamp' in column.data_type|lower %}\n{{ return(coalesce_value['TIMESTAMP']) }}\n\n{% elif 'date' in column.data_type|lower %}\n{{ return(coalesce_value['DATE']) }}\n\n{% elif 'int' in column.data_type|lower %}\n{{ return(coalesce_value['INT']) }}\n\n{% endif %}\n\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils._get_utils_namespaces": {"unique_id": "macro.fivetran_utils._get_utils_namespaces", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/_get_utils_namespaces.sql", "original_file_path": "macros/_get_utils_namespaces.sql", "name": "_get_utils_namespaces", "macro_sql": "{% macro _get_utils_namespaces() %}\n {% set override_namespaces = var('fivetran_utils_dispatch_list', []) %}\n {% do return(override_namespaces + ['dbt_utils', 'fivetran_utils']) %}\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.array_agg": {"unique_id": "macro.fivetran_utils.array_agg", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/array_agg.sql", "original_file_path": "macros/array_agg.sql", "name": "array_agg", "macro_sql": "{% macro array_agg(field_to_agg) -%}\n\n{{ adapter.dispatch('array_agg', packages = fivetran_utils._get_utils_namespaces()) (field_to_agg) }}\n\n{%- endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.default__array_agg": {"unique_id": "macro.fivetran_utils.default__array_agg", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/array_agg.sql", "original_file_path": "macros/array_agg.sql", "name": "default__array_agg", "macro_sql": "{% macro default__array_agg(field_to_agg) %}\n array_agg({{ field_to_agg }})\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.redshift__array_agg": {"unique_id": "macro.fivetran_utils.redshift__array_agg", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/array_agg.sql", "original_file_path": "macros/array_agg.sql", "name": "redshift__array_agg", "macro_sql": "{% macro redshift__array_agg(field_to_agg) %}\n listagg({{ field_to_agg }}, ',')\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.empty_variable_warning": {"unique_id": "macro.fivetran_utils.empty_variable_warning", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/empty_variable_warning.sql", "original_file_path": "macros/empty_variable_warning.sql", "name": "empty_variable_warning", "macro_sql": "{% macro empty_variable_warning(variable, downstream_model) %}\n\n{% if not var(variable) %}\n{{ log(\n \"\"\"\n Warning: You have passed an empty list to the \"\"\" ~ variable ~ \"\"\".\n As a result, you won't see the history of any columns in the \"\"\" ~ downstream_model ~ \"\"\" model.\n \"\"\",\n info=True\n) }}\n{% endif %}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}, "macro.fivetran_utils.enabled_vars_one_true": {"unique_id": "macro.fivetran_utils.enabled_vars_one_true", "package_name": "fivetran_utils", "root_path": "/Users/jamie.rodriguez/Documents/github_repos/dbt_klaviyo/dbt_modules/fivetran_utils", "path": "macros/enabled_vars_one_true.sql", "original_file_path": "macros/enabled_vars_one_true.sql", "name": "enabled_vars_one_true", "macro_sql": "{% macro enabled_vars_one_true(vars) %}\n\n{% for v in vars %}\n \n {% if var(v, False) == True %}\n {{ return(True) }}\n {% endif %}\n\n{% endfor %}\n\n{{ return(False) }}\n\n{% endmacro %}", "resource_type": "macro", "tags": [], "depends_on": {"macros": []}, "description": "", "meta": {}, "docs": {"show": true}, "patch_path": null, "arguments": []}}, "docs": {"dbt.__overview__": {"unique_id": "dbt.__overview__", "package_name": "dbt", "root_path": "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/dbt/include/global_project", "path": "overview.md", "original_file_path": "docs/overview.md", "name": "__overview__", "block_contents": "### Welcome!\n\nWelcome to the auto-generated documentation for your dbt project!\n\n### Navigation\n\nYou can use the `Project` and `Database` navigation tabs on the left side of the window to explore the models\nin your project.\n\n#### Project Tab\nThe `Project` tab mirrors the directory structure of your dbt project. In this tab, you can see all of the\nmodels defined in your dbt project, as well as models imported from dbt packages.\n\n#### Database Tab\nThe `Database` tab also exposes your models, but in a format that looks more like a database explorer. This view\nshows relations (tables and views) grouped into database schemas. Note that ephemeral models are _not_ shown\nin this interface, as they do not exist in the database.\n\n### Graph Exploration\nYou can click the blue icon on the bottom-right corner of the page to view the lineage graph of your models.\n\nOn model pages, you'll see the immediate parents and children of the model you're exploring. By clicking the `Expand`\nbutton at the top-right of this lineage pane, you'll be able to see all of the models that are used to build,\nor are built from, the model you're exploring.\n\nOnce expanded, you'll be able to use the `--models` and `--exclude` model selection syntax to filter the\nmodels in the graph. For more information on model selection, check out the [dbt docs](https://docs.getdbt.com/docs/model-selection-syntax).\n\nNote that you can also right-click on models to interactively filter and explore the graph.\n\n---\n\n### More information\n\n- [What is dbt](https://docs.getdbt.com/docs/overview)?\n- Read the [dbt viewpoint](https://docs.getdbt.com/docs/viewpoint)\n- [Installation](https://docs.getdbt.com/docs/installation)\n- Join the [chat](https://community.getdbt.com/) on Slack for live questions and support."}}, "exposures": {}, "selectors": {}, "disabled": [], "parent_map": {"model.klaviyo.klaviyo__person_campaign_flow": ["model.klaviyo.klaviyo__events"], "model.klaviyo.klaviyo__persons": ["model.klaviyo.int_klaviyo__person_metrics", "model.klaviyo.int_klaviyo__person_metrics", "model.klaviyo_source.stg_klaviyo__person"], "model.klaviyo.klaviyo__flows": ["model.klaviyo.int_klaviyo__campaign_flow_metrics", "model.klaviyo.int_klaviyo__campaign_flow_metrics", "model.klaviyo_source.stg_klaviyo__flow"], "model.klaviyo.klaviyo__campaigns": ["model.klaviyo.int_klaviyo__campaign_flow_metrics", "model.klaviyo.int_klaviyo__campaign_flow_metrics", "model.klaviyo_source.stg_klaviyo__campaign"], "model.klaviyo.klaviyo__events": ["model.klaviyo.int_klaviyo__event_attribution", "model.klaviyo.int_klaviyo__event_attribution", "model.klaviyo_source.stg_klaviyo__campaign", "model.klaviyo_source.stg_klaviyo__flow", "model.klaviyo_source.stg_klaviyo__integration", "model.klaviyo_source.stg_klaviyo__metric", "model.klaviyo_source.stg_klaviyo__person"], "model.klaviyo.int_klaviyo__campaign_flow_metrics": ["model.klaviyo.klaviyo__person_campaign_flow", "model.klaviyo.klaviyo__person_campaign_flow"], "model.klaviyo.int_klaviyo__person_metrics": ["model.klaviyo.klaviyo__person_campaign_flow", "model.klaviyo.klaviyo__person_campaign_flow"], "model.klaviyo.int_klaviyo__event_attribution": ["model.klaviyo_source.stg_klaviyo__event"], "test.klaviyo.unique_klaviyo__events_event_id": ["model.klaviyo.klaviyo__events"], "test.klaviyo.not_null_klaviyo__events_event_id": ["model.klaviyo.klaviyo__events"], "test.klaviyo.dbt_utils_unique_combination_of_columns_klaviyo__person_campaign_flow_person_id__last_touch_campaign_id__last_touch_flow_id__variation_id": ["model.klaviyo.klaviyo__person_campaign_flow"], "test.klaviyo.unique_klaviyo__campaigns_campaign_variation_key": ["model.klaviyo.klaviyo__campaigns"], "test.klaviyo.not_null_klaviyo__campaigns_campaign_variation_key": ["model.klaviyo.klaviyo__campaigns"], "test.klaviyo.unique_klaviyo__flows_flow_variation_key": ["model.klaviyo.klaviyo__flows"], "test.klaviyo.not_null_klaviyo__flows_flow_variation_key": ["model.klaviyo.klaviyo__flows"], "test.klaviyo.unique_klaviyo__persons_person_id": ["model.klaviyo.klaviyo__persons"], "test.klaviyo.not_null_klaviyo__persons_person_id": ["model.klaviyo.klaviyo__persons"], "test.klaviyo.unique_klaviyo__persons_email": ["model.klaviyo.klaviyo__persons"], "test.klaviyo.not_null_klaviyo__persons_email": ["model.klaviyo.klaviyo__persons"], "test.klaviyo.unique_int_klaviyo__event_attribution_event_id": ["model.klaviyo.int_klaviyo__event_attribution"], "test.klaviyo.not_null_int_klaviyo__event_attribution_event_id": ["model.klaviyo.int_klaviyo__event_attribution"], "model.klaviyo_source.stg_klaviyo__person": ["model.klaviyo_source.stg_klaviyo__person_tmp", "model.klaviyo_source.stg_klaviyo__person_tmp"], "model.klaviyo_source.stg_klaviyo__campaign": ["model.klaviyo_source.stg_klaviyo__campaign_tmp", "model.klaviyo_source.stg_klaviyo__campaign_tmp"], "model.klaviyo_source.stg_klaviyo__metric": ["model.klaviyo_source.stg_klaviyo__metric_tmp", "model.klaviyo_source.stg_klaviyo__metric_tmp"], "model.klaviyo_source.stg_klaviyo__integration": ["model.klaviyo_source.stg_klaviyo__integration_tmp", "model.klaviyo_source.stg_klaviyo__integration_tmp"], "model.klaviyo_source.stg_klaviyo__flow": ["model.klaviyo_source.stg_klaviyo__flow_tmp", "model.klaviyo_source.stg_klaviyo__flow_tmp"], "model.klaviyo_source.stg_klaviyo__event": ["model.klaviyo_source.stg_klaviyo__event_tmp", "model.klaviyo_source.stg_klaviyo__event_tmp"], "model.klaviyo_source.stg_klaviyo__event_tmp": ["source.klaviyo_source.klaviyo.event"], "model.klaviyo_source.stg_klaviyo__metric_tmp": ["source.klaviyo_source.klaviyo.metric"], "model.klaviyo_source.stg_klaviyo__campaign_tmp": ["source.klaviyo_source.klaviyo.campaign"], "model.klaviyo_source.stg_klaviyo__integration_tmp": ["source.klaviyo_source.klaviyo.integration"], "model.klaviyo_source.stg_klaviyo__flow_tmp": ["source.klaviyo_source.klaviyo.flow"], "model.klaviyo_source.stg_klaviyo__person_tmp": ["source.klaviyo_source.klaviyo.person"], "test.klaviyo_source.unique_stg_klaviyo__campaign_campaign_id": ["model.klaviyo_source.stg_klaviyo__campaign"], "test.klaviyo_source.not_null_stg_klaviyo__campaign_campaign_id": ["model.klaviyo_source.stg_klaviyo__campaign"], "test.klaviyo_source.unique_stg_klaviyo__event_event_id": ["model.klaviyo_source.stg_klaviyo__event"], "test.klaviyo_source.not_null_stg_klaviyo__event_event_id": ["model.klaviyo_source.stg_klaviyo__event"], "test.klaviyo_source.unique_stg_klaviyo__flow_flow_id": ["model.klaviyo_source.stg_klaviyo__flow"], "test.klaviyo_source.not_null_stg_klaviyo__flow_flow_id": ["model.klaviyo_source.stg_klaviyo__flow"], "test.klaviyo_source.unique_stg_klaviyo__integration_integration_id": ["model.klaviyo_source.stg_klaviyo__integration"], "test.klaviyo_source.not_null_stg_klaviyo__integration_integration_id": ["model.klaviyo_source.stg_klaviyo__integration"], "test.klaviyo_source.unique_stg_klaviyo__person_person_id": ["model.klaviyo_source.stg_klaviyo__person"], "test.klaviyo_source.not_null_stg_klaviyo__person_person_id": ["model.klaviyo_source.stg_klaviyo__person"], "test.klaviyo_source.unique_stg_klaviyo__person_email": ["model.klaviyo_source.stg_klaviyo__person"], "test.klaviyo_source.not_null_stg_klaviyo__person_email": ["model.klaviyo_source.stg_klaviyo__person"], "test.klaviyo_source.unique_stg_klaviyo__metric_metric_id": ["model.klaviyo_source.stg_klaviyo__metric"], "test.klaviyo_source.not_null_stg_klaviyo__metric_metric_id": ["model.klaviyo_source.stg_klaviyo__metric"], "source.klaviyo_source.klaviyo.campaign": [], "source.klaviyo_source.klaviyo.event": [], "source.klaviyo_source.klaviyo.flow": [], "source.klaviyo_source.klaviyo.integration": [], "source.klaviyo_source.klaviyo.person": [], "source.klaviyo_source.klaviyo.metric": []}, "child_map": {"model.klaviyo.klaviyo__person_campaign_flow": ["model.klaviyo.int_klaviyo__campaign_flow_metrics", "model.klaviyo.int_klaviyo__campaign_flow_metrics", "model.klaviyo.int_klaviyo__person_metrics", "model.klaviyo.int_klaviyo__person_metrics", "test.klaviyo.dbt_utils_unique_combination_of_columns_klaviyo__person_campaign_flow_person_id__last_touch_campaign_id__last_touch_flow_id__variation_id"], "model.klaviyo.klaviyo__persons": ["test.klaviyo.not_null_klaviyo__persons_email", "test.klaviyo.not_null_klaviyo__persons_person_id", "test.klaviyo.unique_klaviyo__persons_email", "test.klaviyo.unique_klaviyo__persons_person_id"], "model.klaviyo.klaviyo__flows": ["test.klaviyo.not_null_klaviyo__flows_flow_variation_key", "test.klaviyo.unique_klaviyo__flows_flow_variation_key"], "model.klaviyo.klaviyo__campaigns": ["test.klaviyo.not_null_klaviyo__campaigns_campaign_variation_key", "test.klaviyo.unique_klaviyo__campaigns_campaign_variation_key"], "model.klaviyo.klaviyo__events": ["model.klaviyo.klaviyo__person_campaign_flow", "test.klaviyo.not_null_klaviyo__events_event_id", "test.klaviyo.unique_klaviyo__events_event_id"], "model.klaviyo.int_klaviyo__campaign_flow_metrics": ["model.klaviyo.klaviyo__campaigns", "model.klaviyo.klaviyo__campaigns", "model.klaviyo.klaviyo__flows", "model.klaviyo.klaviyo__flows"], "model.klaviyo.int_klaviyo__person_metrics": ["model.klaviyo.klaviyo__persons", "model.klaviyo.klaviyo__persons"], "model.klaviyo.int_klaviyo__event_attribution": ["model.klaviyo.klaviyo__events", "model.klaviyo.klaviyo__events", "test.klaviyo.not_null_int_klaviyo__event_attribution_event_id", "test.klaviyo.unique_int_klaviyo__event_attribution_event_id"], "test.klaviyo.unique_klaviyo__events_event_id": [], "test.klaviyo.not_null_klaviyo__events_event_id": [], "test.klaviyo.dbt_utils_unique_combination_of_columns_klaviyo__person_campaign_flow_person_id__last_touch_campaign_id__last_touch_flow_id__variation_id": [], "test.klaviyo.unique_klaviyo__campaigns_campaign_variation_key": [], "test.klaviyo.not_null_klaviyo__campaigns_campaign_variation_key": [], "test.klaviyo.unique_klaviyo__flows_flow_variation_key": [], "test.klaviyo.not_null_klaviyo__flows_flow_variation_key": [], "test.klaviyo.unique_klaviyo__persons_person_id": [], "test.klaviyo.not_null_klaviyo__persons_person_id": [], "test.klaviyo.unique_klaviyo__persons_email": [], "test.klaviyo.not_null_klaviyo__persons_email": [], "test.klaviyo.unique_int_klaviyo__event_attribution_event_id": [], "test.klaviyo.not_null_int_klaviyo__event_attribution_event_id": [], "model.klaviyo_source.stg_klaviyo__person": ["model.klaviyo.klaviyo__events", "model.klaviyo.klaviyo__persons", "test.klaviyo_source.not_null_stg_klaviyo__person_email", "test.klaviyo_source.not_null_stg_klaviyo__person_person_id", "test.klaviyo_source.unique_stg_klaviyo__person_email", "test.klaviyo_source.unique_stg_klaviyo__person_person_id"], "model.klaviyo_source.stg_klaviyo__campaign": ["model.klaviyo.klaviyo__campaigns", "model.klaviyo.klaviyo__events", "test.klaviyo_source.not_null_stg_klaviyo__campaign_campaign_id", "test.klaviyo_source.unique_stg_klaviyo__campaign_campaign_id"], "model.klaviyo_source.stg_klaviyo__metric": ["model.klaviyo.klaviyo__events", "test.klaviyo_source.not_null_stg_klaviyo__metric_metric_id", "test.klaviyo_source.unique_stg_klaviyo__metric_metric_id"], "model.klaviyo_source.stg_klaviyo__integration": ["model.klaviyo.klaviyo__events", "test.klaviyo_source.not_null_stg_klaviyo__integration_integration_id", "test.klaviyo_source.unique_stg_klaviyo__integration_integration_id"], "model.klaviyo_source.stg_klaviyo__flow": ["model.klaviyo.klaviyo__events", "model.klaviyo.klaviyo__flows", "test.klaviyo_source.not_null_stg_klaviyo__flow_flow_id", "test.klaviyo_source.unique_stg_klaviyo__flow_flow_id"], "model.klaviyo_source.stg_klaviyo__event": ["model.klaviyo.int_klaviyo__event_attribution", "test.klaviyo_source.not_null_stg_klaviyo__event_event_id", "test.klaviyo_source.unique_stg_klaviyo__event_event_id"], "model.klaviyo_source.stg_klaviyo__event_tmp": ["model.klaviyo_source.stg_klaviyo__event", "model.klaviyo_source.stg_klaviyo__event"], "model.klaviyo_source.stg_klaviyo__metric_tmp": ["model.klaviyo_source.stg_klaviyo__metric", "model.klaviyo_source.stg_klaviyo__metric"], "model.klaviyo_source.stg_klaviyo__campaign_tmp": ["model.klaviyo_source.stg_klaviyo__campaign", "model.klaviyo_source.stg_klaviyo__campaign"], "model.klaviyo_source.stg_klaviyo__integration_tmp": ["model.klaviyo_source.stg_klaviyo__integration", "model.klaviyo_source.stg_klaviyo__integration"], "model.klaviyo_source.stg_klaviyo__flow_tmp": ["model.klaviyo_source.stg_klaviyo__flow", "model.klaviyo_source.stg_klaviyo__flow"], "model.klaviyo_source.stg_klaviyo__person_tmp": ["model.klaviyo_source.stg_klaviyo__person", "model.klaviyo_source.stg_klaviyo__person"], "test.klaviyo_source.unique_stg_klaviyo__campaign_campaign_id": [], "test.klaviyo_source.not_null_stg_klaviyo__campaign_campaign_id": [], "test.klaviyo_source.unique_stg_klaviyo__event_event_id": [], "test.klaviyo_source.not_null_stg_klaviyo__event_event_id": [], "test.klaviyo_source.unique_stg_klaviyo__flow_flow_id": [], "test.klaviyo_source.not_null_stg_klaviyo__flow_flow_id": [], "test.klaviyo_source.unique_stg_klaviyo__integration_integration_id": [], "test.klaviyo_source.not_null_stg_klaviyo__integration_integration_id": [], "test.klaviyo_source.unique_stg_klaviyo__person_person_id": [], "test.klaviyo_source.not_null_stg_klaviyo__person_person_id": [], "test.klaviyo_source.unique_stg_klaviyo__person_email": [], "test.klaviyo_source.not_null_stg_klaviyo__person_email": [], "test.klaviyo_source.unique_stg_klaviyo__metric_metric_id": [], "test.klaviyo_source.not_null_stg_klaviyo__metric_metric_id": [], "source.klaviyo_source.klaviyo.campaign": ["model.klaviyo_source.stg_klaviyo__campaign_tmp"], "source.klaviyo_source.klaviyo.event": ["model.klaviyo_source.stg_klaviyo__event_tmp"], "source.klaviyo_source.klaviyo.flow": ["model.klaviyo_source.stg_klaviyo__flow_tmp"], "source.klaviyo_source.klaviyo.integration": ["model.klaviyo_source.stg_klaviyo__integration_tmp"], "source.klaviyo_source.klaviyo.person": ["model.klaviyo_source.stg_klaviyo__person_tmp"], "source.klaviyo_source.klaviyo.metric": ["model.klaviyo_source.stg_klaviyo__metric_tmp"]}}
\ No newline at end of file
diff --git a/docs/run_results.json b/docs/run_results.json
new file mode 100644
index 0000000..53c10bd
--- /dev/null
+++ b/docs/run_results.json
@@ -0,0 +1 @@
+{"metadata": {"dbt_schema_version": "https://schemas.getdbt.com/dbt/run-results/v1.json", "dbt_version": "0.19.1", "generated_at": "2021-05-14T22:08:46.975607Z", "invocation_id": "f7550b65-aa65-41a7-947e-4f59ca100216", "env": {}}, "results": [{"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:39.191480Z", "completed_at": "2021-05-14T22:08:39.209490Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:39.209680Z", "completed_at": "2021-05-14T22:08:39.209697Z"}], "thread_id": "Thread-2", "execution_time": 0.020372867584228516, "adapter_response": {}, "message": null, "unique_id": "model.klaviyo_source.stg_klaviyo__campaign_tmp"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:39.192399Z", "completed_at": "2021-05-14T22:08:39.214555Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:39.215504Z", "completed_at": "2021-05-14T22:08:39.215519Z"}], "thread_id": "Thread-3", "execution_time": 0.026016950607299805, "adapter_response": {}, "message": null, "unique_id": "model.klaviyo_source.stg_klaviyo__flow_tmp"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:39.190565Z", "completed_at": "2021-05-14T22:08:39.214701Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:39.215664Z", "completed_at": "2021-05-14T22:08:39.215673Z"}], "thread_id": "Thread-1", "execution_time": 0.02743816375732422, "adapter_response": {}, "message": null, "unique_id": "model.klaviyo_source.stg_klaviyo__event_tmp"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:39.201843Z", "completed_at": "2021-05-14T22:08:39.215309Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:39.215814Z", "completed_at": "2021-05-14T22:08:39.215821Z"}], "thread_id": "Thread-4", "execution_time": 0.02597498893737793, "adapter_response": {}, "message": null, "unique_id": "model.klaviyo_source.stg_klaviyo__integration_tmp"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:39.210537Z", "completed_at": "2021-05-14T22:08:39.217221Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:39.218664Z", "completed_at": "2021-05-14T22:08:39.218676Z"}], "thread_id": "Thread-2", "execution_time": 0.009405851364135742, "adapter_response": {}, "message": null, "unique_id": "model.klaviyo_source.stg_klaviyo__metric_tmp"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:39.219440Z", "completed_at": "2021-05-14T22:08:39.245627Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:39.251901Z", "completed_at": "2021-05-14T22:08:39.251914Z"}], "thread_id": "Thread-3", "execution_time": 0.03773689270019531, "adapter_response": {}, "message": null, "unique_id": "model.klaviyo_source.stg_klaviyo__person_tmp"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:39.219863Z", "completed_at": "2021-05-14T22:08:40.539775Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:40.540432Z", "completed_at": "2021-05-14T22:08:40.540440Z"}], "thread_id": "Thread-1", "execution_time": 1.6403048038482666, "adapter_response": {}, "message": null, "unique_id": "model.klaviyo_source.stg_klaviyo__campaign"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:39.219981Z", "completed_at": "2021-05-14T22:08:40.538097Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:40.538252Z", "completed_at": "2021-05-14T22:08:40.538264Z"}], "thread_id": "Thread-4", "execution_time": 1.654939889907837, "adapter_response": {}, "message": null, "unique_id": "model.klaviyo_source.stg_klaviyo__flow"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:39.245554Z", "completed_at": "2021-05-14T22:08:40.539408Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:40.539637Z", "completed_at": "2021-05-14T22:08:40.539660Z"}], "thread_id": "Thread-2", "execution_time": 1.6357510089874268, "adapter_response": {}, "message": null, "unique_id": "model.klaviyo_source.stg_klaviyo__event"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:40.883256Z", "completed_at": "2021-05-14T22:08:40.891618Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:40.892127Z", "completed_at": "2021-05-14T22:08:40.892140Z"}], "thread_id": "Thread-2", "execution_time": 0.009540081024169922, "adapter_response": {}, "message": null, "unique_id": "test.klaviyo_source.not_null_stg_klaviyo__campaign_campaign_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:40.893016Z", "completed_at": "2021-05-14T22:08:40.899788Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:40.900012Z", "completed_at": "2021-05-14T22:08:40.900021Z"}], "thread_id": "Thread-2", "execution_time": 0.007706165313720703, "adapter_response": {}, "message": null, "unique_id": "test.klaviyo_source.unique_stg_klaviyo__campaign_campaign_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:40.901310Z", "completed_at": "2021-05-14T22:08:40.908408Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:40.908596Z", "completed_at": "2021-05-14T22:08:40.908606Z"}], "thread_id": "Thread-2", "execution_time": 0.008037805557250977, "adapter_response": {}, "message": null, "unique_id": "test.klaviyo_source.not_null_stg_klaviyo__flow_flow_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:40.909793Z", "completed_at": "2021-05-14T22:08:40.913748Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:40.913946Z", "completed_at": "2021-05-14T22:08:40.913956Z"}], "thread_id": "Thread-2", "execution_time": 0.0048558712005615234, "adapter_response": {}, "message": null, "unique_id": "test.klaviyo_source.unique_stg_klaviyo__flow_flow_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:40.914786Z", "completed_at": "2021-05-14T22:08:40.935863Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:40.936204Z", "completed_at": "2021-05-14T22:08:40.936238Z"}], "thread_id": "Thread-2", "execution_time": 0.02211475372314453, "adapter_response": {}, "message": null, "unique_id": "model.klaviyo.int_klaviyo__event_attribution"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:40.938939Z", "completed_at": "2021-05-14T22:08:40.943186Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:40.943452Z", "completed_at": "2021-05-14T22:08:40.943462Z"}], "thread_id": "Thread-2", "execution_time": 0.0061359405517578125, "adapter_response": {}, "message": null, "unique_id": "test.klaviyo_source.not_null_stg_klaviyo__event_event_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:39.258499Z", "completed_at": "2021-05-14T22:08:40.539878Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:40.540783Z", "completed_at": "2021-05-14T22:08:40.540790Z"}], "thread_id": "Thread-3", "execution_time": 1.687168836593628, "adapter_response": {}, "message": null, "unique_id": "model.klaviyo_source.stg_klaviyo__integration"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:40.944915Z", "completed_at": "2021-05-14T22:08:40.953918Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:40.954092Z", "completed_at": "2021-05-14T22:08:40.954102Z"}], "thread_id": "Thread-2", "execution_time": 0.01013803482055664, "adapter_response": {}, "message": null, "unique_id": "test.klaviyo_source.unique_stg_klaviyo__event_event_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:40.949876Z", "completed_at": "2021-05-14T22:08:40.958719Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:40.958872Z", "completed_at": "2021-05-14T22:08:40.958882Z"}], "thread_id": "Thread-3", "execution_time": 0.009726285934448242, "adapter_response": {}, "message": null, "unique_id": "test.klaviyo.not_null_int_klaviyo__event_attribution_event_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:40.954875Z", "completed_at": "2021-05-14T22:08:40.963403Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:40.963539Z", "completed_at": "2021-05-14T22:08:40.963549Z"}], "thread_id": "Thread-2", "execution_time": 0.009139060974121094, "adapter_response": {}, "message": null, "unique_id": "test.klaviyo.unique_int_klaviyo__event_attribution_event_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:40.959742Z", "completed_at": "2021-05-14T22:08:40.968994Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:40.969477Z", "completed_at": "2021-05-14T22:08:40.969497Z"}], "thread_id": "Thread-3", "execution_time": 0.011016845703125, "adapter_response": {}, "message": null, "unique_id": "test.klaviyo_source.not_null_stg_klaviyo__integration_integration_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:40.964214Z", "completed_at": "2021-05-14T22:08:40.970666Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:40.970977Z", "completed_at": "2021-05-14T22:08:40.970987Z"}], "thread_id": "Thread-2", "execution_time": 0.00723719596862793, "adapter_response": {}, "message": null, "unique_id": "test.klaviyo_source.unique_stg_klaviyo__integration_integration_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:40.860348Z", "completed_at": "2021-05-14T22:08:42.023912Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:42.024324Z", "completed_at": "2021-05-14T22:08:42.024353Z"}], "thread_id": "Thread-1", "execution_time": 1.4259603023529053, "adapter_response": {}, "message": null, "unique_id": "model.klaviyo_source.stg_klaviyo__metric"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:42.287834Z", "completed_at": "2021-05-14T22:08:42.298373Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:42.298554Z", "completed_at": "2021-05-14T22:08:42.298566Z"}], "thread_id": "Thread-3", "execution_time": 0.011806011199951172, "adapter_response": {}, "message": null, "unique_id": "test.klaviyo_source.not_null_stg_klaviyo__metric_metric_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:42.287980Z", "completed_at": "2021-05-14T22:08:42.299124Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:42.299254Z", "completed_at": "2021-05-14T22:08:42.299262Z"}], "thread_id": "Thread-2", "execution_time": 0.012027978897094727, "adapter_response": {}, "message": null, "unique_id": "test.klaviyo_source.unique_stg_klaviyo__metric_metric_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:40.875011Z", "completed_at": "2021-05-14T22:08:42.045381Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:42.045611Z", "completed_at": "2021-05-14T22:08:42.045624Z"}], "thread_id": "Thread-4", "execution_time": 1.4652972221374512, "adapter_response": {}, "message": null, "unique_id": "model.klaviyo_source.stg_klaviyo__person"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:42.342632Z", "completed_at": "2021-05-14T22:08:42.371295Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:42.371588Z", "completed_at": "2021-05-14T22:08:42.371599Z"}], "thread_id": "Thread-2", "execution_time": 0.03078603744506836, "adapter_response": {}, "message": null, "unique_id": "test.klaviyo_source.not_null_stg_klaviyo__person_person_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:42.342507Z", "completed_at": "2021-05-14T22:08:42.371452Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:42.371855Z", "completed_at": "2021-05-14T22:08:42.371863Z"}], "thread_id": "Thread-3", "execution_time": 0.0315556526184082, "adapter_response": {}, "message": null, "unique_id": "test.klaviyo_source.not_null_stg_klaviyo__person_email"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:42.342751Z", "completed_at": "2021-05-14T22:08:42.372819Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:42.374085Z", "completed_at": "2021-05-14T22:08:42.374093Z"}], "thread_id": "Thread-4", "execution_time": 0.0325009822845459, "adapter_response": {}, "message": null, "unique_id": "test.klaviyo_source.unique_stg_klaviyo__person_email"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:42.374792Z", "completed_at": "2021-05-14T22:08:42.379668Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:42.379852Z", "completed_at": "2021-05-14T22:08:42.379863Z"}], "thread_id": "Thread-2", "execution_time": 0.005831241607666016, "adapter_response": {}, "message": null, "unique_id": "test.klaviyo_source.unique_stg_klaviyo__person_person_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:42.342386Z", "completed_at": "2021-05-14T22:08:43.374192Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:43.374394Z", "completed_at": "2021-05-14T22:08:43.374407Z"}], "thread_id": "Thread-1", "execution_time": 1.300001859664917, "adapter_response": {}, "message": null, "unique_id": "model.klaviyo.klaviyo__events"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:43.644231Z", "completed_at": "2021-05-14T22:08:43.663669Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:43.663925Z", "completed_at": "2021-05-14T22:08:43.663939Z"}], "thread_id": "Thread-3", "execution_time": 0.02122211456298828, "adapter_response": {}, "message": null, "unique_id": "model.klaviyo.klaviyo__person_campaign_flow"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:43.651669Z", "completed_at": "2021-05-14T22:08:43.665508Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:43.666150Z", "completed_at": "2021-05-14T22:08:43.666160Z"}], "thread_id": "Thread-2", "execution_time": 0.033467769622802734, "adapter_response": {}, "message": null, "unique_id": "test.klaviyo.unique_klaviyo__events_event_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:43.644770Z", "completed_at": "2021-05-14T22:08:43.666024Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:43.677493Z", "completed_at": "2021-05-14T22:08:43.677505Z"}], "thread_id": "Thread-4", "execution_time": 0.044954776763916016, "adapter_response": {}, "message": null, "unique_id": "test.klaviyo.not_null_klaviyo__events_event_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:43.691525Z", "completed_at": "2021-05-14T22:08:43.706122Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:43.706326Z", "completed_at": "2021-05-14T22:08:43.706337Z"}], "thread_id": "Thread-2", "execution_time": 0.01662731170654297, "adapter_response": {}, "message": null, "unique_id": "test.klaviyo.dbt_utils_unique_combination_of_columns_klaviyo__person_campaign_flow_person_id__last_touch_campaign_id__last_touch_flow_id__variation_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:43.666272Z", "completed_at": "2021-05-14T22:08:44.683727Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:44.684184Z", "completed_at": "2021-05-14T22:08:44.684198Z"}], "thread_id": "Thread-3", "execution_time": 1.3692119121551514, "adapter_response": {}, "message": null, "unique_id": "model.klaviyo.int_klaviyo__person_metrics"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:43.665949Z", "completed_at": "2021-05-14T22:08:44.684048Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:44.684399Z", "completed_at": "2021-05-14T22:08:44.684409Z"}], "thread_id": "Thread-1", "execution_time": 1.3702640533447266, "adapter_response": {}, "message": null, "unique_id": "model.klaviyo.int_klaviyo__campaign_flow_metrics"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:45.038102Z", "completed_at": "2021-05-14T22:08:46.607664Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:46.607866Z", "completed_at": "2021-05-14T22:08:46.607878Z"}], "thread_id": "Thread-4", "execution_time": 1.862130880355835, "adapter_response": {}, "message": null, "unique_id": "model.klaviyo.klaviyo__persons"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:45.038899Z", "completed_at": "2021-05-14T22:08:46.598068Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:46.598327Z", "completed_at": "2021-05-14T22:08:46.598343Z"}], "thread_id": "Thread-3", "execution_time": 1.8620319366455078, "adapter_response": {}, "message": null, "unique_id": "model.klaviyo.klaviyo__campaigns"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:46.901671Z", "completed_at": "2021-05-14T22:08:46.916182Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:46.916347Z", "completed_at": "2021-05-14T22:08:46.916358Z"}], "thread_id": "Thread-1", "execution_time": 0.0157470703125, "adapter_response": {}, "message": null, "unique_id": "test.klaviyo.not_null_klaviyo__campaigns_campaign_variation_key"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:46.907103Z", "completed_at": "2021-05-14T22:08:46.923051Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:46.923317Z", "completed_at": "2021-05-14T22:08:46.923332Z"}], "thread_id": "Thread-3", "execution_time": 0.021919965744018555, "adapter_response": {}, "message": null, "unique_id": "test.klaviyo.not_null_klaviyo__persons_person_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:46.902097Z", "completed_at": "2021-05-14T22:08:46.923887Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:46.924429Z", "completed_at": "2021-05-14T22:08:46.924468Z"}], "thread_id": "Thread-4", "execution_time": 0.023983001708984375, "adapter_response": {}, "message": null, "unique_id": "test.klaviyo.not_null_klaviyo__persons_email"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:46.917172Z", "completed_at": "2021-05-14T22:08:46.924666Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:46.925567Z", "completed_at": "2021-05-14T22:08:46.925577Z"}], "thread_id": "Thread-1", "execution_time": 0.009325981140136719, "adapter_response": {}, "message": null, "unique_id": "test.klaviyo.unique_klaviyo__campaigns_campaign_variation_key"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:46.925713Z", "completed_at": "2021-05-14T22:08:46.935116Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:46.935297Z", "completed_at": "2021-05-14T22:08:46.935308Z"}], "thread_id": "Thread-3", "execution_time": 0.010756969451904297, "adapter_response": {}, "message": null, "unique_id": "test.klaviyo.unique_klaviyo__persons_email"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:46.931210Z", "completed_at": "2021-05-14T22:08:46.935940Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:46.936081Z", "completed_at": "2021-05-14T22:08:46.936091Z"}], "thread_id": "Thread-4", "execution_time": 0.005808115005493164, "adapter_response": {}, "message": null, "unique_id": "test.klaviyo.unique_klaviyo__persons_person_id"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:45.048436Z", "completed_at": "2021-05-14T22:08:46.658300Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:46.658583Z", "completed_at": "2021-05-14T22:08:46.658597Z"}], "thread_id": "Thread-2", "execution_time": 1.9222800731658936, "adapter_response": {}, "message": null, "unique_id": "model.klaviyo.klaviyo__flows"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:46.962147Z", "completed_at": "2021-05-14T22:08:46.972574Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:46.972829Z", "completed_at": "2021-05-14T22:08:46.972843Z"}], "thread_id": "Thread-1", "execution_time": 0.011632204055786133, "adapter_response": {}, "message": null, "unique_id": "test.klaviyo.not_null_klaviyo__flows_flow_variation_key"}, {"status": "success", "timing": [{"name": "compile", "started_at": "2021-05-14T22:08:46.967363Z", "completed_at": "2021-05-14T22:08:46.973391Z"}, {"name": "execute", "started_at": "2021-05-14T22:08:46.973685Z", "completed_at": "2021-05-14T22:08:46.973695Z"}], "thread_id": "Thread-3", "execution_time": 0.011607885360717773, "adapter_response": {}, "message": null, "unique_id": "test.klaviyo.unique_klaviyo__flows_flow_variation_key"}], "elapsed_time": 10.523230791091919, "args": {"log_format": "default", "write_json": true, "profiles_dir": "/Users/jamie.rodriguez/.dbt", "use_cache": true, "compile": true, "version_check": true, "which": "generate", "rpc_method": "docs.generate"}}
\ No newline at end of file
diff --git a/docs/what_goes_here.md b/docs/what_goes_here.md
new file mode 100644
index 0000000..62e9f80
--- /dev/null
+++ b/docs/what_goes_here.md
@@ -0,0 +1,10 @@
+# What goes in this folder?
+
+The json and html files which we use to create the github pages docs site will be dropped in this folder. To create these you will:
+- Navigate to the `integration_tests` directory in your terminal.
+- Execute `dbt deps`
+- Execute `dbt seed --full-refresh -t bigquery && dbt run --full-refresh -t bigquery && dbt test -t bigquery`
+- Execute `dbt docs -t bigquery && dbt docs serve -t bigquery`
+- Check to make sure there are no errors in the site that was just served.
+- Drag the following files into this folder: catalog.json, index.html, manifest.json, run_results.json
+- DELETE THIS FILE
\ No newline at end of file
diff --git a/integration_tests/.gitignore b/integration_tests/.gitignore
index 64454d7..2453ce7 100644
--- a/integration_tests/.gitignore
+++ b/integration_tests/.gitignore
@@ -2,4 +2,5 @@
target/
dbt_modules/
logs/
-.DS_Store
\ No newline at end of file
+.DS_Store
+env/
\ No newline at end of file
diff --git a/integration_tests/ci/sample.profiles.yml b/integration_tests/ci/sample.profiles.yml
index 872156a..8263e77 100644
--- a/integration_tests/ci/sample.profiles.yml
+++ b/integration_tests/ci/sample.profiles.yml
@@ -43,4 +43,15 @@ integration_tests:
dbname: "{{ env_var('CI_POSTGRES_DBT_DBNAME') }}"
port: 5432
schema: klaviyo_integration_tests
- threads: 8
\ No newline at end of file
+ threads: 8
+ spark:
+ type: spark
+ method: http
+ schema: klaviyo_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
\ No newline at end of file
diff --git a/integration_tests/dbt_project.yml b/integration_tests/dbt_project.yml
index b51b751..c6744bc 100644
--- a/integration_tests/dbt_project.yml
+++ b/integration_tests/dbt_project.yml
@@ -1,4 +1,4 @@
-name: 'klaviyo_source_integration_tests'
+name: 'klaviyo_integration_tests'
version: '0.1.0'
config-version: 2
profile: 'integration_tests'
@@ -15,20 +15,72 @@ vars:
klaviyo__event_pass_through_columns: []
klaviyo__person_pass_through_columns: []
+ klaviyo:
+ event_table: "{{ ref( 'stg_klaviyo__event') }}"
+ campaign: "{{ ref( 'stg_klaviyo__campaign') }}"
+ flow: "{{ ref( 'stg_klaviyo__flow') }}"
+ integration: "{{ ref( 'stg_klaviyo__integration') }}"
+ person: "{{ ref( 'stg_klaviyo__person') }}"
+ metric: "{{ ref( 'stg_klaviyo__metric') }}"
+ klaviyo__email_attribution_lookback: 120 # in hours - 5 days -> https://help.klaviyo.com/hc/en-us/articles/115005248128#conversion-tracking1
+ klaviyo__sms_attribution_lookback: 24 # in hours -> https://help.klaviyo.com/hc/en-us/articles/115005248128#sms-conversion-tracking7
+
+ klaviyo__eligible_attribution_events: # default in klaviyo -> https://help.klaviyo.com/hc/en-us/articles/115005248128
+ - 'opened email'
+ - 'clicked email'
+ - 'clicked sms'
+
+ klaviyo__count_metrics:
+ - 'Active on Site' # default API metrics
+ - 'Viewed Product'
+ - 'Ordered Product' # default Shopify metrics
+ - 'Placed Order'
+ - 'Refunded Order' # note: klaviyo only tracks FULL refunds (not partial)
+ - 'Cancelled Order'
+ - 'Fulfilled Order'
+ - 'Received Email' # default email and sms conversion metrics in Klaviyo
+ - 'Clicked Email'
+ - 'Opened Email'
+ - 'Bounced Email'
+ - 'Marked Email as Spam'
+ - 'Dropped Email'
+ - 'Subscribed to List'
+ - 'Unsubscribed to List'
+ - 'Unsubscribed'
+ - 'Updated Email Preferences'
+ - 'Subscribed to Back in Stock'
+ - 'Merged Profile'
+ - 'Received SMS'
+ - 'Clicked SMS'
+ - 'Consented to Receive SMS'
+ - 'Sent SMS'
+ - 'Unsubscribed from SMS'
+ - 'Failed to Deliver SMS'
+
+ klaviyo__sum_revenue_metrics:
+ - 'Refunded Order'
+ - 'Placed Order'
+ - 'Ordered Product'
+ - 'checkout started'
+ - 'cancelled order'
seeds:
- klaviyo_source_integration_tests:
+ klaviyo_integration_tests:
+ +quote_columns: "{{ true if target.type == 'redshift' else false }}"
+column_types:
_FIVETRAN_SYNCED: timestamp
person:
+column_types:
- PHONE_NUMBER: "{{ 'string' if target.type == 'bigquery' else 'varchar' }}"
+ PHONE_NUMBER: "{{ 'string' if target.type in ('bigquery', 'spark') else 'varchar' }}"
flow:
+enabled: "{{ true if target.type != 'snowflake' else false }}"
+ +quote_columns: "{{ true if target.type == 'redshift' else false }}"
+ +column_types:
+ TRIGGER: "{{ 'string' if target.type in ('bigquery', 'spark') else 'varchar' }}"
flow_snowflake:
+enabled: "{{ true if target.type == 'snowflake' else false }}"
- # event_table:
- # +column_types:
- # datetime: timestamp
- # timestamp: timestamp
+ event:
+ +column_types:
+ FLOW_ID: "{{ 'string' if target.type in ('bigquery', 'spark') else 'varchar' }}"
+ CAMPAIGN_ID: "{{ 'string' if target.type in ('bigquery', 'spark') else 'varchar' }}"
\ No newline at end of file
diff --git a/integration_tests/requirements.txt b/integration_tests/requirements.txt
index 38e8ae6..ca89302 100644
--- a/integration_tests/requirements.txt
+++ b/integration_tests/requirements.txt
@@ -1 +1,3 @@
-dbt==0.19.0
\ No newline at end of file
+dbt==0.19.1
+dbt-spark==0.19.1
+dbt-spark[PyHive]==0.19.1
\ No newline at end of file
diff --git a/models/intermediate/int_klaviyo.yml b/models/intermediate/int_klaviyo.yml
new file mode 100644
index 0000000..809ad2f
--- /dev/null
+++ b/models/intermediate/int_klaviyo.yml
@@ -0,0 +1,137 @@
+version: 2
+
+models:
+ - name: int_klaviyo__event_attribution
+ description: >
+ Table enriching events with an additional layer of last-touch attribution.
+ Though Klaviyo already performs attribution on events each day, this extra step is necessary,
+ as certain kinds of events/metrics never get attributed to flows or campaigns via Klaviyo's internal model.
+
+ By default, the package performs attribution [in line with Klaviyo](https://help.klaviyo.com/hc/en-us/articles/115005248128).
+ It considers email opens and clicks, and SMS opens as the events eligible to be credited with conversions.
+ This attribution-eligibility can be configured by the `klaviyo__eligible_attribution_events` variable.
+ Note that this refers to the events eligible to credit campaigns and flows with conversions, _not_ the events
+ eligible to receive attribution (all kinds of events are privy to this).
+
+ Similar to Klaviyo, the package by default considers the conversion period/lookback window for email events to
+ be 120 hours (5 days) and 24 hours for SMS events. These can be configured through the
+ `klaviyo__email_attribution_lookback` and `klaviyo__sms_attribution_lookback` variables, respectively (in integer-hours).
+
+ Note: this model has an incremental materialization. Custom event-columns specified by the `klaviyo__event_pass_through_columns`
+ variable will appear here as well.
+
+ columns:
+ - name: variation_id
+ description: >
+ Unique ID of the attributed flow or campaign variation group.
+ This does not map onto another table.
+ - name: campaign_id
+ description: Foreign key referencing the CAMPAIGN that the event is attributed to.
+ - name: occurred_at
+ description: Timestamp of when the event was triggered.
+ - name: flow_id
+ description: Foreign key referencing the FLOW that the event is attributed to.
+ - name: flow_message_id
+ description: >
+ Unique ID of the FLOW_MESSAGE that the event is attributed to.
+ This does not map onto another table.
+ - name: event_id
+ description: Unique ID of the event.
+ tests:
+ - unique
+ - not_null
+ - name: metric_id
+ description: Foreign key referencing the metric being captured.
+ - name: person_id
+ description: Foreign key referencing the PERSON who triggered the event.
+ - name: type
+ description: Type of event that was triggered. This is the same as the METRIC name.
+ - name: uuid
+ description: Universally Unique Identifier of the event.
+ - name: numeric_value
+ description: Numeric value associated with the event (ie the dollars associated with a purchase).
+ - name: touch_type
+ description: >
+ Type of touch/message that the event itself is already attributed to in Klaviyo. Either 'flow', 'campaign', or null.
+ Note that the package will refer to campaign and flow interactions as "touches".
+ - name: occurred_on
+ description: Calendar date (UTC) on which the event occurred.
+ - name: touch_id
+ description: Coalescing of the Klaviyo-attributed campaign_id and flow_id.
+ - name: touch_session
+ description: >
+ ID used to batch an individual person's events into attribution-groups. Each event that comes
+ attributed to a campaign or flow begins a new session/batch, in which the following events without
+ a flow/campaign_id have the same `touch_session` (and may be attributed to the same flow/campaign).
+ - name: session_start_at
+ description: >
+ Timestamp of when, relative to the current event, this person last interacted with a campaign or flow
+ according to Klaviyo. This is the beginning of the event's touch-session.
+ - name: session_event_type
+ description: >
+ The type of event through which, relative to the current event, the person last interacted with a campaign
+ or flow. This information is used to determine which lookback window to use (email vs sms).
+ - name: last_touch_id
+ description: The campaign or flow that the package attributed the event to.
+ - name: last_touch_type
+ description: What kind of touch the event was attributed to by the package -- 'campaign', 'flow', or null.
+ - name: _fivetran_synced
+ description: UTC Timestamp that indicates the start time of the Fivetran job that synced this event row.
+
+ - name: int_klaviyo__campaign_flow_metrics
+ description: >
+ Table that draws from the `klaviyo__person_campaign_flow` model to aggregate event metrics
+ to the campaign or flow AND variation grain. A campaign with A/B versions will have 2 records.
+ **Counts** of the unique users and instances of the events, as well as **sums** of the numeric value associated
+ with events (i.e. revenue) will be pivoted out into columns, as configured by the `klaviyo__count_metrics` and `klaviyo__sum_revenue_metrics`
+ variables, respectively. See the dbt_project.yml file for the default metrics used.
+ These columns will be prefixed with `count_`, `unique_count_`, and `sum_revenue_`.
+
+ columns:
+ - name: last_touch_campaign_id
+ description: Foreign key referencing the CAMPAIGN attributed with these metrics (by the package's attribution model).
+ - name: last_touch_flow_id
+ description: Foreign key referencing the FLOW attributed with these metrics (by the package's attribution model).
+ - name: variation_id
+ description: >
+ Unique ID of the attributed flow or campaign variation group.
+ This does not map onto another table.
+ - name: total_count_unique_people
+ description: The count of the distinct people that have interacted with this campaign or flow.
+ - name: first_event_at
+ description: Timestamp of the first ever interaction between this campaign/flow and a person.
+ - name: last_event_at
+ description: Timestamp of the most recent interaction between this campaign/flow and a person.
+
+ - name: int_klaviyo__person_metrics
+ description: >
+ Table that draws from the `klaviyo__person_campaign_flow` model to aggregate event metrics
+ to the person grain.
+
+ **Counts** of instances of the events and **sums** of the numeric value (i.e. revenue) associated
+ with events (total vs organic/not attributed to flows or campaigns) will be pivoted out into columns, as configured by the
+ `klaviyo__count_metrics` and `klaviyo__sum_revenue_metrics`variables, respectively. See the dbt_project.yml file for
+ the default metrics used.
+
+ These columns will be prefixed with `total_count_`, `total_sum_revenue_` (organic + attributed), and `organic_sum_revenue_`
+ (not attributed to a campaign or flow).
+ columns:
+ - name: person_id
+ description: Unique ID of the person.
+ - name: count_total_campaigns
+ description: Count of the number of campaigns this person has interacted with.
+ - name: count_total_flows
+ description: Count of the number of flows this person has interacted with.
+ - name: first_event_at
+ description: Timestamp of when the user first triggered an event (not limited to campaign and flow interactions).
+ - name: last_event_at
+ description: Timestamp of when the user last triggered an event (not limited to campaign and flow interactions).
+ - name: first_campaign_touch_at
+ description: Timestamp of when the user first interacted with a campaign.
+ - name: last_campaign_touch_at
+ description: Timestamp of when the user last interacted with a campaign.
+ - name: first_flow_touch_at
+ description: Timestamp of when the user first interacted with a flow.
+ - name: last_flow_touch_at
+ description: Timestamp of when the user last interacted with a flow.
+
diff --git a/models/intermediate/int_klaviyo__campaign_flow_metrics.sql b/models/intermediate/int_klaviyo__campaign_flow_metrics.sql
new file mode 100644
index 0000000..99af471
--- /dev/null
+++ b/models/intermediate/int_klaviyo__campaign_flow_metrics.sql
@@ -0,0 +1,38 @@
+with person_campaign_flow as (
+
+ select *
+ from {{ ref('klaviyo__person_campaign_flow') }}
+),
+
+{%- set pcf_columns = adapter.get_columns_in_relation(ref('klaviyo__person_campaign_flow')) %}
+
+-- aggregating to the campaign/flow - variation level. so a flow with A/B versions will have 2 rows
+agg_metrics as (
+
+ select
+ last_touch_campaign_id,
+ last_touch_flow_id,
+ variation_id,
+ count(distinct person_id) as total_count_unique_people,
+ min(first_event_at) as first_event_at,
+ max(last_event_at) as last_event_at
+
+ {% for col in pcf_columns if col.name|lower not in ['last_touch_campaign_id', 'person_id', 'last_touch_flow_id',
+ 'campaign_name', 'flow_name','variation_id', 'first_event_at', 'last_event_at'] %}
+ -- sum up any person-level metrics to the flow/campaign level
+ , sum( {{ col.name }} ) as {{ col.name }}
+
+ {% if 'sum_revenue' not in col.name|lower %} -- only look at 'count' metrics for unique people counts
+ -- get unique number of people who did each kind of event
+ -- each record in person_campaign_flow is at the person-campaign/flow-variation level,
+ -- so we can just sum up 0s and 1s to get totals at the campaign/flow-variation grain.
+ , sum(case when {{ col.name }} > 0 then 1 else 0 end) as {{ 'unique_' ~ col.name }}
+
+ {% endif %}
+ {% endfor -%}
+
+ from person_campaign_flow
+ group by 1,2,3
+)
+
+select * from agg_metrics
\ No newline at end of file
diff --git a/models/intermediate/int_klaviyo__event_attribution.sql b/models/intermediate/int_klaviyo__event_attribution.sql
new file mode 100644
index 0000000..2762ed5
--- /dev/null
+++ b/models/intermediate/int_klaviyo__event_attribution.sql
@@ -0,0 +1,120 @@
+{{
+ config(
+ materialized='incremental',
+ unique_key='event_id',
+ partition_by={
+ "field": "occurred_on",
+ "data_type": "date"
+ } if target.type != 'spark' else ['occurred_on']
+ )
+}}
+
+with events as (
+
+ select
+ *,
+ -- no event will be attributed to both a campaign and flow
+ coalesce(campaign_id, flow_id) as touch_id,
+ case
+ when campaign_id is not null then 'campaign'
+ when flow_id is not null then 'flow'
+ else null end as touch_type -- defintion: touch = interaction with campaign/flow
+
+ from {{ var('event_table') }}
+
+ {% if is_incremental() %}
+ -- grab **ALL** events for users who have any events in this new increment
+ where person_id in (
+
+ select distinct person_id
+ from {{ var('event_table') }}
+
+ -- most events (from all kinds of integrations) at least once every hour
+ -- https://help.klaviyo.com/hc/en-us/articles/115005253208
+ where _fivetran_synced >= cast(coalesce(
+ (
+ select {{ dbt_utils.dateadd(datepart = 'hour',
+ interval = -1,
+ from_date_or_timestamp = 'max(_fivetran_synced)' ) }}
+ from {{ this }}
+ ), '2012-01-01') as {{ dbt_utils.type_timestamp() }} ) -- klaviyo was founded in 2012, so let's default the min date to then
+ )
+ {% endif %}
+),
+
+-- sessionize events based on attribution eligibility -- is it the right kind of event, and does it have a campaign or flow?
+create_sessions as (
+ select
+ *,
+ -- default klaviyo__event_attribution_filter limits attribution-eligible events to to email opens, email clicks, and sms opens
+ -- https://help.klaviyo.com/hc/en-us/articles/115005248128
+
+ -- events that come with flow/campaign attributions (and are eligible event types) will create new sessions.
+ -- non-attributed events that come in afterward will be batched into the same attribution-session
+ sum(case when touch_id is not null
+ {% if var('klaviyo__eligible_attribution_events') != [] %}
+ and lower(type) in {{ "('" ~ (var('klaviyo__eligible_attribution_events') | join("', '")) ~ "')" }}
+ {% endif %}
+ then 1 else 0 end) over (
+ partition by person_id order by occurred_at asc rows between unbounded preceding and current row) as touch_session
+
+ from events
+
+),
+
+-- "session start" refers to the event in a "touch session" that is already attributed with a campaign or flow by Klaviyo
+-- a new event that is attributed with a campaign/flow will trigger a new session, so there will only be one already-attributed event per each session
+-- events that are missing attributions will borrow data from the event that triggered the session, if they are in the lookback window (see `attribute` CTE)
+last_touches as (
+
+ select
+ *,
+ -- when did the touch session begin?
+ min(occurred_at) over(partition by person_id, touch_session) as session_start_at,
+
+ -- get the kind of metric/event that triggered the attribution session, in order to decide
+ -- to use the sms or email lookback value.
+ first_value(type) over(
+ partition by person_id, touch_session order by occurred_at asc rows between unbounded preceding and current row) as session_event_type
+
+ from create_sessions
+),
+
+attribute as (
+
+ select
+ *,
+ -- klaviyo uses different lookback windows for email and sms events
+ -- default email lookback = 5 days (120 hours) -> https://help.klaviyo.com/hc/en-us/articles/115005248128#conversion-tracking1
+ -- default sms lookback: 1 day (24 hours -> https://help.klaviyo.com/hc/en-us/articles/115005248128#sms-conversion-tracking7
+
+ coalesce(touch_id, -- use pre-attributed flow/campaign if provided
+ case
+ when {{ dbt_utils.datediff('session_start_at', 'occurred_at', 'hour') }} <= (
+ case
+ when lower(session_event_type) like '%sms%' then {{ var('klaviyo__sms_attribution_lookback') }}
+ else {{ var('klaviyo__email_attribution_lookback') }} end
+ ) -- if the events fall within the lookback window, attribute
+ then first_value(touch_id) over (
+ partition by person_id, touch_session order by occurred_at asc rows between unbounded preceding and current row)
+ else null end) as last_touch_id -- session qualified for attribution -> we will call this "last touch"
+
+ from last_touches
+),
+
+final as (
+
+ select
+ *,
+
+ -- get whether the event is attributed to a flow or campaign
+ case when last_touch_id is not null then
+ coalesce(touch_type, first_value(touch_type) over(
+ partition by person_id, touch_session order by occurred_at asc rows between unbounded preceding and current row))
+
+ else null end as last_touch_type -- if the session events qualified for attribution, extract the type of touch they are attributed to
+
+ from attribute
+)
+
+select * from final
\ No newline at end of file
diff --git a/models/intermediate/int_klaviyo__person_metrics.sql b/models/intermediate/int_klaviyo__person_metrics.sql
new file mode 100644
index 0000000..1d301c6
--- /dev/null
+++ b/models/intermediate/int_klaviyo__person_metrics.sql
@@ -0,0 +1,39 @@
+with person_campaign_flow as (
+
+ select *
+ from {{ ref('klaviyo__person_campaign_flow') }}
+),
+
+{%- set pcf_columns = adapter.get_columns_in_relation(ref('klaviyo__person_campaign_flow')) %}
+
+agg_metrics as (
+
+ select
+ person_id,
+ count(distinct last_touch_campaign_id) as count_total_campaigns,
+ count(distinct last_touch_flow_id) as count_total_flows,
+ min(first_event_at) as first_event_at, -- first ever event occurred at
+ max(last_event_at) as last_event_at, -- last ever event occurred at
+ min(distinct case when last_touch_campaign_id is not null then first_event_at end) as first_campaign_touch_at,
+ max(distinct case when last_touch_campaign_id is not null then last_event_at end) as last_campaign_touch_at,
+ min(distinct case when last_touch_flow_id is not null then first_event_at end) as first_flow_touch_at,
+ max(distinct case when last_touch_flow_id is not null then last_event_at end) as last_flow_touch_at
+
+ {% for col in pcf_columns if col.name|lower not in ['last_touch_campaign_id', 'person_id', 'last_touch_flow_id',
+ 'campaign_name', 'flow_name','variation_id', 'first_event_at', 'last_event_at'] %}
+ -- sum up any count/sum_revenue metrics -> prefix with `total` since we're pulling out organic sums as well
+ , sum( {{ col.name }} ) as {{ 'total_' ~ col.name }}
+
+ -- let's pull out the organic (not attributed to a flow or campaign) revenue sums
+ {% if 'sum_revenue' in col.name|lower %}
+ , sum( case when coalesce(last_touch_campaign_id, last_touch_flow_id) is null then {{ col.name }} else 0 end ) as {{ 'organic_' ~ col.name }}
+ {% endif %}
+
+ {% endfor -%}
+
+ from person_campaign_flow
+ group by 1
+
+)
+
+select * from agg_metrics
\ No newline at end of file
diff --git a/models/klaviyo.yml b/models/klaviyo.yml
new file mode 100644
index 0000000..ee69e96
--- /dev/null
+++ b/models/klaviyo.yml
@@ -0,0 +1,292 @@
+version: 2
+
+models:
+ - name: klaviyo__events
+ description: >
+ Table of Klaviyo events, enriched with attribution data (see `int_klaviyo__event_attribution` for details), and
+ information regarding the event's associated user, flow, campaign, and platform/integration.
+
+ Note: this model has an incremental materialization. Custom event-columns specified by the `klaviyo__event_pass_through_columns`
+ variable will appear here as well.
+
+ columns:
+ - name: variation_id
+ description: >
+ Unique ID of the attributed flow or campaign variation group.
+ This does not map onto another table.
+ - name: campaign_id
+ description: Foreign key referencing the CAMPAIGN that the event is attributed to.
+ - name: occurred_at
+ description: Timestamp of when the event was triggered.
+ - name: flow_id
+ description: Foreign key referencing the FLOW that the event is attributed to.
+ - name: flow_message_id
+ description: >
+ Unique ID of the FLOW_MESSAGE that the event is attributed to.
+ This does not map onto another table.
+ - name: event_id
+ description: Unique ID of the event.
+ tests:
+ - unique
+ - not_null
+ - name: metric_id
+ description: Foreign key referencing the metric being captured.
+ - name: person_id
+ description: Foreign key referencing the PERSON who triggered the event.
+ - name: type
+ description: Type of event that was triggered. This is the same as the METRIC name.
+ - name: uuid
+ description: Universally Unique Identifier of the event.
+ - name: numeric_value
+ description: Numeric value associated with the event (ie the dollars associated with a purchase).
+ - name: touch_type
+ description: >
+ Type of touch/message that the event itself is already attributed to in Klaviyo. Either 'flow', 'campaign', or null.
+ Note that the package will refer to campaign and flow interactions as "touches".
+ - name: occurred_on
+ description: Calendar date (UTC) on which the event occurred.
+ - name: touch_id
+ description: Coalescing of the Klaviyo-attributed campaign_id and flow_id.
+ - name: last_touch_at
+ description: >
+ Timestamp of when, relative to the current event, this person last interacted with a campaign or flow
+ according to Klaviyo. This will be null if the event is not attributed to any flow or campaign.
+ - name: last_touch_event_type
+ description: >
+ The type of event through which, relative to the current event, the person last interacted with a campaign
+ or flow. This information is used to determine which lookback window to use (email vs sms).
+ This will be null if the event is not attributed to any flow or campaign.
+ - name: last_touch_type
+ description: What kind of touch the event was attributed to by the package -- 'campaign', 'flow', or null.
+ - name: last_touch_campaign_id
+ description: Foreign key referencing the CAMPAIGN that the event is attributed to by the package.
+ - name: last_touch_flow_id
+ description: Foreign key referencing the FLOW that the event is attributed to by the package.
+ - name: campaign_name
+ description: A name for this campaign. If not specified, this will default to the subject of the campaign.
+ - name: campaign_type
+ description: Type of campaign.
+ - name: campaign_subject_line
+ description: Type of campaign.
+ - name: flow_name
+ description: Name of the flow.
+ - name: person_city
+ description: City that the person who triggered this event lives in.
+ - name: person_country
+ description: Country that the person who triggered this event lives in.
+ - name: person_region
+ description: Region or state that the person who triggered this event lives in.
+ - name: person_email
+ description: The email address and the unique identifier for the person who triggered the event.
+ - name: person_timezone
+ description: Timezone that the person who triggered this event is situated in.
+ - name: integration_name
+ description: Name of the platform that triggered the event (either Klaviyo, the API, or another integration).
+ - name: integration_category
+ description: Use-case category of the platform that sent the event.
+ - name: _fivetran_synced
+ description: UTC Timestamp that indicates the start time of the Fivetran job that synced this event row.
+
+ - name: klaviyo__person_campaign_flow
+ description: >
+ Table that aggregates event metrics to the person-campaign or -flow grain (but note that if a user interacts
+ with 2 different variations of a flow/campaign somehow, they will have 2 records). Also note that organic
+ interactions (someone with null campaign_id/flow_id) are included in this table.
+
+ **Counts** of the instances of the events, as well as **sums** of the numeric value associated
+ with events (i.e. revenue) will be pivoted out into columns, as configured by the `klaviyo__count_metrics` and `klaviyo__sum_revenue_metrics`
+ variables, respectively. See the dbt_project.yml file for the default metrics used.
+ These columns will be prefixed with `count_` and `sum_revenue_`.
+ tests:
+ - dbt_utils.unique_combination_of_columns:
+ combination_of_columns:
+ - person_id
+ - last_touch_campaign_id
+ - last_touch_flow_id
+ - variation_id
+ columns:
+ - name: person_id
+ description: Foreign key referencing the PERSON who interacted with the flow/message.
+ - name: last_touch_campaign_id
+ description: Foreign key referencing the CAMPAIGN attributed with these metrics (by the package's attribution model).
+ - name: last_touch_flow_id
+ description: Foreign key referencing the FLOW attributed with these metrics (by the package's attribution model).
+ - name: campaign_name
+ description: A name for this campaign. If not specified, this will default to the subject of the campaign.
+ - name: flow_name
+ description: Name of the flow.
+ - name: variation_id
+ description: >
+ Unique ID of the attributed flow or campaign variation group.
+ This does not map onto another table.
+ - name: first_event_at
+ description: Timestamp of the first ever interaction between this campaign/flow and a person. In other words, the first event trigger attributed to the campaign/flow.
+ - name: last_event_at
+ description: Timestamp of the most recent interaction between this campaign/flow and a person. In other words, the last event trigger attributed to the campaign/flow.
+
+ - name: klaviyo__campaigns
+ description: >
+ Table of unique campaign versions. A campaign with 2 variations will have 2 distinct rows.
+ **Counts** of the unique users and instances of the events, as well as **sums** of the numeric value associated
+ with events (i.e. revenue) will be pivoted out into columns, as configured by the `klaviyo__count_metrics` and `klaviyo__sum_revenue_metrics`
+ variables, respectively. See the dbt_project.yml file for the default metrics used.
+ These columns will be prefixed with `count_`, `unique_count_`, and `sum_revenue_`.
+ columns:
+ - name: campaign_variation_key
+ description: Unique key hashed on the campaign and variation IDs.
+ tests:
+ - unique
+ - not_null
+ - name: campaign_type
+ description: Type of campaign.
+ - name: created_at
+ description: Timestamp of when the campaign was created, in UTC.
+ - name: email_template_id
+ description: >
+ Foreign key referencing the ID of the `email_template` object that will be the
+ content of this campaign. Note the Email Template is copied when creating this campaign,
+ so future changes to that Email Template will not alter the content of this campaign.
+ - name: from_email
+ description: The email address your email will be sent from and will be used in the reply-to header.
+ - name: from_name
+ description: The name or label associated with the email address you're sending from.
+ - name: campaign_id
+ description: Unique ID of the campaign.
+ - name: is_segmented
+ description: Boolean that is true if the campaign is directed at a Klaviyo segment (not a list).
+ - name: campaign_name
+ description: A name for this campaign. If not specified, this will default to the subject of the campaign.
+ - name: scheduled_to_send_at
+ description: >
+ Timestamp of when the campaign is scheduled to be sent in the future, if
+ ["smart send time"](https://help.klaviyo.com/hc/en-us/articles/360029794371-Smart-Send-Time-in-Klaviyo#how-to-utilize-smart-send-time3) is used.
+ - name: sent_at
+ description: Timestamp of when the campaign was first sent out to users.
+ - name: status
+ description: Current status of the campaign. Either "draft", "scheduled", "sent", or "cancelled".
+ - name: status_id
+ description: Corresponding ID to the current status.
+ - name: subject
+ description: The subject line of the campaign's email.
+ - name: updated_at
+ description: Timestamp of when the campaign was last updated.
+ - name: variation_id
+ description: >
+ Unique ID of the attributed campaign variation group.
+ This does not map onto another table.
+ - name: total_count_unique_people
+ description: The count of the distinct people that have interacted with this campaign.
+ - name: first_event_at
+ description: Timestamp of the first ever interaction between this campaign and a person.
+ - name: last_event_at
+ description: Timestamp of the most recent interaction between this campaign and a person.
+
+ - name: klaviyo__flows
+ description: >
+ Table of unique flow versions. A flow with 2 variations will have 2 distinct rows.
+ **Counts** of the unique users and instances of the events, as well as **sums** of the numeric value associated
+ with events (i.e. revenue) will be pivoted out into columns, as configured by the `klaviyo__count_metrics` and `klaviyo__sum_revenue_metrics`
+ variables, respectively. See the dbt_project.yml file for the default metrics used.
+ These columns will be prefixed with `count_`, `unique_count_`, and `sum_revenue_`.
+ columns:
+ - name: flow_variation_key
+ description: Unique key hashed on the flow and variation IDs.
+ tests:
+ - unique
+ - not_null
+ - name: created_at
+ description: Timestamp of when the flow was first created.
+ - name: flow_id
+ description: Unique ID of the flow.
+ - name: flow_name
+ description: Name of the flow.
+ - name: status
+ description: Current status of the flow. Either 'manual', 'live', or 'draft'. Read more [here](https://help.klaviyo.com/hc/en-us/articles/115002774932-Getting-Started-with-Flows#the-flow-action-status9).
+ - name: flow_trigger
+ description: JSON of metric, segment, list, and/or date-property filters that will trigger this flow. These are applied to the **event level**.
+ - name: updated_at
+ description: Timestamp of when the flow was last updated.
+ - name: person_filter
+ description: JSON of flow filters placed on the **person level** that will trigger this flow.
+ - name: variation_id
+ description: >
+ Unique ID of the attributed flow variation group.
+ This does not map onto another table.
+ - name: total_count_unique_people
+ description: The count of the distinct people that have interacted with this flow.
+ - name: first_event_at
+ description: Timestamp of the first ever interaction between this flow and a person.
+ - name: last_event_at
+ description: Timestamp of the most recent interaction between this flow and a person.
+
+ - name: klaviyo__persons
+ description: >
+ Table of unique person profiles, enhanced with event, campaign, flow, and revenue metrics.
+
+ **Counts** of instances of triggered events and **sums** of the numeric value (i.e. revenue) associated
+ with events (total vs organic/not attributed to flows or campaigns) will be pivoted out into columns, as configured by the
+ `klaviyo__count_metrics` and `klaviyo__sum_revenue_metrics`variables, respectively. See the dbt_project.yml file for
+ the default metrics used.
+ These columns will be prefixed with `total_count_`, `total_sum_revenue_` (organic + attributed), and `organic_sum_revenue_`
+ (not attributed to a campaign or flow).
+
+ columns:
+ - name: person_id
+ description: >
+ Unique ID of the user if you use your own unique identifier. Otherwise, Klaviyo
+ recommends using the email as the primary key.
+ tests:
+ - unique
+ - not_null
+ - name: address_1
+ description: First line of the person's address.
+ - name: address_2
+ description: Second line of the person's address.
+ - name: city
+ description: City they live in.
+ - name: country
+ description: Country they live in.
+ - name: zip
+ description: Postal code where they live.
+ - name: created_at
+ description: Timestamp of when the person's profile was created.
+ - name: email
+ description: The email address and the unique identifier for a profile.
+ tests:
+ - unique:
+ severity: warn
+ - not_null
+ - name: full_name
+ description: Person's full name.
+ - name: latitude
+ description: Latitude of the person's location.
+ - name: longitude
+ description: Longitude of the person's location.
+ - name: organization
+ description: Business organization they belong to.
+ - name: phone_number
+ description: Associated phone number.
+ - name: region
+ description: Region or state they live in.
+ - name: timezone
+ description: Timezone they are situated in.
+ - name: title
+ description: Title at their business or organization.
+ - name: updated_at
+ description: Timestamp of when the person profile was last updated.
+ - name: count_total_campaigns
+ description: Count of the number of campaigns this person has interacted with.
+ - name: count_total_flows
+ description: Count of the number of flows this person has interacted with.
+ - name: first_event_at
+ description: Timestamp of when the user first triggered an event (not limited to campaign and flow interactions).
+ - name: last_event_at
+ description: Timestamp of when the user last triggered an event (not limited to campaign and flow interactions).
+ - name: first_campaign_touch_at
+ description: Timestamp of when the user first interacted with a campaign.
+ - name: last_campaign_touch_at
+ description: Timestamp of when the user last interacted with a campaign.
+ - name: first_flow_touch_at
+ description: Timestamp of when the user first interacted with a flow.
+ - name: last_flow_touch_at
+ description: Timestamp of when the user last interacted with a flow.
diff --git a/models/klaviyo__campaigns.sql b/models/klaviyo__campaigns.sql
new file mode 100644
index 0000000..ce3be3c
--- /dev/null
+++ b/models/klaviyo__campaigns.sql
@@ -0,0 +1,36 @@
+with campaign as (
+
+ select *
+ from {{ var('campaign') }}
+),
+
+campaign_metrics as (
+
+ select *
+ from {{ ref('int_klaviyo__campaign_flow_metrics') }}
+),
+
+campaign_join as (
+
+ {% set exclude_fields = [ 'last_touch_campaign_id', 'last_touch_flow_id'] %}
+ {% set exclude_fields = exclude_fields | upper if target.type == 'snowflake' else exclude_fields %} -- snowflake needs uppercase :)
+
+ select
+ campaign.*, -- has campaign_id
+ {{ dbt_utils.star(from=ref('int_klaviyo__campaign_flow_metrics'), except=exclude_fields) }}
+
+ from campaign
+ left join campaign_metrics on campaign.campaign_id = campaign_metrics.last_touch_campaign_id
+),
+
+final as (
+
+ select
+ *,
+ {{ dbt_utils.surrogate_key(['campaign_id','variation_id']) }} as campaign_variation_key
+
+ from campaign_join
+)
+
+select *
+from final
\ No newline at end of file
diff --git a/models/klaviyo__events.sql b/models/klaviyo__events.sql
new file mode 100644
index 0000000..ca7cae6
--- /dev/null
+++ b/models/klaviyo__events.sql
@@ -0,0 +1,116 @@
+{{
+ config(
+ materialized='incremental',
+ unique_key='event_id',
+ partition_by={
+ "field": "occurred_on",
+ "data_type": "date"
+ }
+ )
+}}
+
+with events as (
+
+ select *
+ from {{ ref('int_klaviyo__event_attribution') }}
+
+ {% if is_incremental() %}
+
+ -- most events (from all kinds of integrations) at least once every hour
+ where _fivetran_synced >= cast(coalesce(
+ (
+ select {{ dbt_utils.dateadd(datepart = 'hour',
+ interval = -1,
+ from_date_or_timestamp = 'max(_fivetran_synced)' ) }}
+ from {{ this }}
+ ), '2012-01-01') as {{ dbt_utils.type_timestamp() }} ) -- klaviyo was founded in 2012, so let's default the min date to then
+ {% endif %}
+),
+
+event_fields as (
+
+ -- excluding some fields to rename them and/or make them null if needed
+ {% set exclude_fields = ['touch_session', 'last_touch_id', 'session_start_at', 'session_event_type', 'type'] %}
+ -- snowflake has to be uppercase :)
+ {% set exclude_fields = exclude_fields | upper if target.type == 'snowflake' else exclude_fields %}
+
+ select
+ {{ dbt_utils.star(from=ref('int_klaviyo__event_attribution'), except=exclude_fields) }},
+
+ type, -- need to pull this out because it gets removed by dbt_utils.star, due to being a substring of 'last_touch_event_type'
+
+ -- split out campaign and flow IDs
+ case
+ when last_touch_type = 'campaign' then last_touch_id
+ else null end as last_touch_campaign_id,
+ case
+ when last_touch_type = 'flow' then last_touch_id
+ else null end as last_touch_flow_id,
+
+ -- only make these non-null if the event indeed qualified for attribution
+ case
+ when last_touch_id is not null then session_start_at
+ else null end as last_touch_at,
+ case
+ when last_touch_id is not null then session_event_type
+ else null end as last_touch_event_type
+
+ from events
+),
+
+campaign as (
+
+ select *
+ from {{ var('campaign') }}
+),
+
+flow as (
+
+ select *
+ from {{ var('flow') }}
+),
+
+person as (
+
+ select *
+ from {{ var('person') }}
+),
+
+-- just pulling this to join with INTEGRATION
+metric as (
+
+ select *
+ from {{ var('metric') }}
+),
+
+integration as (
+
+ select *
+ from {{ var('integration') }}
+),
+
+join_fields as (
+
+ select
+ event_fields.*,
+ campaign.campaign_name,
+ campaign.campaign_type,
+ campaign.subject as campaign_subject_line,
+ flow.flow_name,
+ person.city as person_city,
+ person.country as person_country,
+ person.region as person_region,
+ person.email as person_email,
+ person.timezone as person_timezone,
+ integration.integration_name,
+ integration.category as integration_category
+
+ from event_fields
+ left join campaign on event_fields.last_touch_campaign_id = campaign.campaign_id
+ left join flow on event_fields.last_touch_flow_id = flow.flow_id
+ left join person on event_fields.person_id = person.person_id
+ left join metric on event_fields.metric_id = metric.metric_id
+ left join integration on metric.integration_id = integration.integration_id
+)
+
+select * from join_fields
\ No newline at end of file
diff --git a/models/klaviyo__flows.sql b/models/klaviyo__flows.sql
new file mode 100644
index 0000000..5224604
--- /dev/null
+++ b/models/klaviyo__flows.sql
@@ -0,0 +1,36 @@
+with flow as (
+
+ select *
+ from {{ var('flow') }}
+),
+
+flow_metrics as (
+
+ select *
+ from {{ ref('int_klaviyo__campaign_flow_metrics') }}
+),
+
+flow_join as (
+
+ {% set exclude_fields = [ 'last_touch_campaign_id', 'last_touch_flow_id'] %}
+ {% set exclude_fields = exclude_fields | upper if target.type == 'snowflake' else exclude_fields %} -- snowflake needs uppercase :)
+
+ select
+ flow.*, -- has flow_id
+ {{ dbt_utils.star(from=ref('int_klaviyo__campaign_flow_metrics'), except=exclude_fields) }}
+
+ from flow
+ left join flow_metrics on flow.flow_id = flow_metrics.last_touch_flow_id
+),
+
+final as (
+
+ select
+ *,
+ {{ dbt_utils.surrogate_key(['flow_id','variation_id']) }} as flow_variation_key
+
+ from flow_join
+)
+
+select *
+from final
\ No newline at end of file
diff --git a/models/klaviyo__person_campaign_flow.sql b/models/klaviyo__person_campaign_flow.sql
new file mode 100644
index 0000000..6ceadde
--- /dev/null
+++ b/models/klaviyo__person_campaign_flow.sql
@@ -0,0 +1,35 @@
+with events as (
+ select *
+ from {{ ref('klaviyo__events') }}
+),
+
+pivot_out_events as (
+
+ select
+ person_id,
+ last_touch_campaign_id,
+ last_touch_flow_id,
+ campaign_name,
+ flow_name,
+ variation_id,
+ min(occurred_at) as first_event_at,
+ max(occurred_at) as last_event_at
+
+ -- sum up the numeric value associated with events (most likely will mean revenue)
+ {% for rm in var('klaviyo__sum_revenue_metrics') %}
+ , sum(case when lower(type) = '{{ rm | lower }}' then numeric_value else 0 end)
+ as {{ 'sum_revenue_' ~ rm | replace(' ', '_') | replace('(', '') | replace(')', '') | lower }} -- removing special characters that I have seen in different integration events
+ {% endfor %}
+
+ -- count up the number of instances of each metric
+ {% for cm in var('klaviyo__count_metrics') %}
+ , sum(case when lower(type) = '{{ cm | lower }}' then 1 else 0 end)
+ as {{ 'count_' ~ cm | replace(' ', '_') | replace('(', '') | replace(')', '') | lower }} -- removing special characters that I have seen in different integration events
+ {% endfor %}
+
+ from events
+ group by 1,2,3,4,5,6
+)
+
+select *
+from pivot_out_events
\ No newline at end of file
diff --git a/models/klaviyo__persons.sql b/models/klaviyo__persons.sql
new file mode 100644
index 0000000..f5b8f9e
--- /dev/null
+++ b/models/klaviyo__persons.sql
@@ -0,0 +1,25 @@
+with person as (
+
+ select *
+ from {{ var('person') }}
+),
+
+person_metrics as (
+
+ select *
+ from {{ ref('int_klaviyo__person_metrics') }}
+),
+
+person_join as (
+
+ select
+ person.*,
+ {{ dbt_utils.star(from=ref('int_klaviyo__person_metrics'), except=['person_id'] if target.type != 'snowflake' else ['PERSON_ID'] ) }}
+
+ from person
+ left join person_metrics using(person_id)
+
+)
+
+select *
+from person_join
\ No newline at end of file
diff --git a/packages.yml b/packages.yml
index 599ad4f..65d846b 100644
--- a/packages.yml
+++ b/packages.yml
@@ -1,3 +1,4 @@
packages:
- - local: ../dbt_klaviyo_source
\ No newline at end of file
+ - package: fivetran/klaviyo_source
+ version: [">=0.1.0","<0.2.0"]
\ No newline at end of file