fivetran / dbt_ad_reporting

Fivetran's ad reporting dbt package. Combine your Facebook, Google, Pinterest, LinkedIn, Twitter, Snapchat, Microsoft, TikTok, Reddit, Amazon, and Apple Search advertising metrics using this package.
https://fivetran.github.io/dbt_ad_reporting/#!/overview
Apache License 2.0
143 stars 55 forks source link

[Bug] Compilation Error Could not render {{ metric('spend') }} / {{ metric('clicks') }}: 'metric' is undefined #67

Closed Elvie-JackRockett closed 1 year ago

Elvie-JackRockett commented 1 year ago

Is there an existing issue for this?

Describe the issue

DBT unable to compile project due to below error,

Server error: RPC server failed to compile project, call the "status" method for compile status: Compilation Error Could not render {{ metric('spend') }} / {{ metric('clicks') }}: 'metric' is undefined

Running DBT cloud Packages versions:

Relevant error log or model output

upon DBT DEPS command:
Installing fivetran/netsuite
09:04:48    Installed from version 0.6.0
09:04:48    Updated version available: 0.6.2
09:04:48  Installing fivetran/ad_reporting
09:04:51    Installed from version 1.0.1
09:04:51    Up to date!
09:04:51  Installing fivetran/fivetran_log
09:04:53    Installed from version 0.6.3
09:04:53    Up to date!
09:04:53  Installing fivetran/netsuite_source
09:04:56    Installed from version 0.5.1
09:04:56    Up to date!
09:04:56  Installing fivetran/apple_search_ads
09:04:57    Installed from version 0.1.0
09:04:57    Up to date!
09:04:57  Installing fivetran/snapchat_ads
09:04:58    Installed from version 0.4.0
09:04:58    Up to date!
09:04:58  Installing fivetran/facebook_ads
09:04:59    Installed from version 0.5.0
09:04:59    Up to date!
09:04:59  Installing fivetran/google_ads
09:05:01    Installed from version 0.8.0
09:05:01    Up to date!
09:05:01  Installing fivetran/pinterest
09:05:02    Installed from version 0.6.0
09:05:02    Up to date!
09:05:02  Installing fivetran/linkedin
09:05:03    Installed from version 0.5.0
09:05:03    Up to date!
09:05:03  Installing fivetran/microsoft_ads
09:05:04    Installed from version 0.5.1
09:05:04    Up to date!
09:05:04  Installing fivetran/tiktok_ads
09:05:05    Installed from version 0.2.1
09:05:05    Up to date!
09:05:05  Installing fivetran/twitter_ads
09:05:06    Installed from version 0.5.0
09:05:06    Up to date!
09:05:06  Installing fivetran/fivetran_utils
09:05:07    Installed from version 0.3.9
09:05:07    Updated version available: 0.4.0
09:05:07  Installing dbt-labs/spark_utils
09:05:08    Installed from version 0.3.0
09:05:08    Up to date!
09:05:08  Installing fivetran/apple_search_ads_source
09:05:10    Installed from version 0.1.2
09:05:10    Up to date!
09:05:10  Installing fivetran/snapchat_ads_source
09:05:11    Installed from version 0.4.0
09:05:11    Up to date!
09:05:11  Installing fivetran/facebook_ads_source
09:05:13    Installed from version 0.5.0
09:05:13    Up to date!
09:05:13  Installing fivetran/google_ads_source
09:05:14    Installed from version 0.8.0
09:05:14    Up to date!
09:05:14  Installing fivetran/pinterest_source
09:05:16    Installed from version 0.6.0
09:05:16    Up to date!
09:05:16  Installing fivetran/linkedin_source
09:05:17    Installed from version 0.5.0
09:05:17    Up to date!
09:05:17  Installing fivetran/microsoft_ads_source
09:05:19    Installed from version 0.6.0
09:05:19    Up to date!
09:05:19  Installing fivetran/tiktok_ads_source
09:05:20    Installed from version 0.2.0
09:05:20    Up to date!
09:05:20  Installing fivetran/twitter_ads_source
09:05:21    Installed from version 0.5.0
09:05:21    Up to date!
09:05:21  Installing dbt-labs/dbt_utils
09:05:28    Installed from version 0.8.6
09:05:28    Updated version available: 0.9.2
09:05:28  Installing calogica/dbt_expectations
09:05:31    Installed from version 0.5.8
09:05:31    Updated version available: 0.7.0
09:05:31  Installing calogica/dbt_date
09:05:32    Installed from version 0.5.7
09:05:32    Updated version available: 0.6.2
09:05:32  
09:05:32  Updates available for packages: ['fivetran/netsuite', 'fivetran/fivetran_utils', 'dbt-labs/dbt_utils', 'calogica/dbt_expectations', 'calogica/dbt_date']                 
Update your versions in packages.yml, then run dbt deps
Compilation Error
  Could not render {{ metric('spend') }} / {{ metric('clicks') }}: 'metric' is undefined

Expected behavior

expecting project to compile and allow for editing within DBT cloud IDE

dbt Project configurations

`

Name your project! Project names should contain only lowercase characters

and underscores. A good package name should reflect your organization's

name or the intended use of these models

name: 'elvie_bi' version: '1.0.0' config-version: 2

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

profile: 'default'

These configurations specify where dbt should look for different types of files.

The source-paths config, for example, states that models in this project can be

found in the "models/" directory. You probably won't need to change these!

model-paths: ["models"] analysis-paths: ["analyses"] test-paths: ["tests"] seed-paths: ["seeds"] macro-paths: ["macros"] snapshot-paths: ["snapshots"]

target-path: "target_{{ env_var('HOSTNAME') }}" # directory which will store compiled SQL files clean-targets: # directories to be removed by dbt clean

Configuring models

Full documentation: https://docs.getdbt.com/docs/configuring-models

In this example config, we tell dbt to build all models in the example/ directory

as tables. These settings can be overridden in the individual model files

using the {{ config(...) }} macro.

models:

elvie_bi:

stg_amazon:
  schema: stg_amazon
  materialized: table

stg_netsuite:
  schema: stg_netsuite
  materialized: table

stg_finance:
  schema: stg_finance
  materialized: table

stg_hierarchies:
  schema: stg_hierarchies
  materialized: table

stg_operations:
  schema: stg_operations
  materialized: table

reporting_marketing:
  schema: reporting_marketing
  materialized: table

reporting_trading:
  schema: reporting_trading
  materialized: table

netsuite: +schema: reporting_trading netsuite_source: +schema: stg_netsuite

ad_reporting: +schema: reporting_marketing

facebook_ads: +schema: stg_facebook_ads facebook_ads_source: +schema: stg_facebook_ads facebook_ads_creative_history: +schema: stg_facebook_ads

google_ads: +schema: stg_google_ads google_ads_source: +schema: stg_google_ads

fivetran_log: +schema: reporting_bi # leave blank for just the target_schema

ADS MODELS

disable both pinterest models if not using pinterest ads

pinterest:

enabled: false

pinterest_source:

enabled: false

disable both microsoft ads models if not using microsoft ads

microsoft_ads:

enabled: false

microsoft_ads_source:

enabled: false

disable both linkedin ads models if not using linkedin ads

linkedin:

enabled: false

linkedin_source:

enabled: false

disable both twitter ads models if not using twitter ads

twitter_ads:

enabled: false

twitter_ads_source:

enabled: false

disable both snapchat ads models if not using snapchat ads

snapchat_ads:

enabled: false

snapchat_ads_source:

enabled: false

disable both tiktok ads models if not using tiktok ads

tiktok_ads:

enabled: false

tiktok_ads_source:

enabled: false

vars: netsuite_data_model: netsuite2 #netsuite by default netsuite_schema: raw_netsuite

netsuite_source:

netsuite_database: your_database_name

netsuite_schema: src_netsuite

netsuite_schema: netsuite_suiteanalytics

ADS MODEL

ad_reportingapple_search_ads_enabled: False ad_reportingpinterest_ads_enabled: False ad_reportingmicrosoft_ads_enabled: False ad_reporting__linkedin_ads_enabled: False ad_reportingtwitter_ads_enabled: False ad_reporting__snapchat_ads_enabled: False ad_reporting__tiktok_ads_enabled: False

facebook_ads_schema: raw_facebook_ads

google_ads_schema: raw_google_ads

Fivetran Log DBT MODEL

fivetran_log_schema: raw_fivetran_log
fivetran_log_using_transformations: false # this will disable all transformation + trigger_table logic fivetran_log_using_triggers: false # this will disable only trigger_table logic

fivetran_log_using_account_membership: false # this will disable only the account membership logic

fivetran_log_using_destination_membership: false # this will disable only the destination membership logic

fivetran_log_using_user: false # this will disable only the user logic

fivetran_log_using_sync_alert_messages: false # this will disable only the sync alert messages within the connector status model`

Package versions

packages:

What database are you using dbt with?

bigquery

dbt Version

image

Unable to perform this request as project cannot compile

Additional Context

No response

Are you willing to open a PR to help address this issue?

fivetran-reneeli commented 1 year ago

Hi @Elvie-JackRockett thanks for raising this ticket! To get metrics to render, you'll need to add the dbt metrics package to your packages.yml. See our readme for more info. Let me know if that solves it!

Elvie-JackRockett commented 1 year ago

Thanks for the speedy reply @fivetran-reneeli I've added that in now (odd as it worked fine without this package before!)

Unfortunately its having an issue with the version:

**Runtime Error Failed to read package: Runtime Error This version of dbt is not supported with the 'metrics' package. Installed version of dbt: =1.0.8 Required version of dbt for 'metrics': ['>=1.4.0-a1', '<1.5.0'] Check for a different version of the 'metrics' package, or run dbt again with --no-version-check

Error encountered in /usr/src/develop/user-80335/environment-113802/repository-90021/dbt_packages/metrics/dbt_project.yml

Error encountered in /usr/src/develop/user-80335/environment-113802/repository-90021/dbt_packages/metrics**

Elvie-JackRockett commented 1 year ago

I use the version required as per that error message and still nothing

Elvie-JackRockett commented 1 year ago

OK @fivetran-reneeli I resolved following your guidsance and updating my IDE to DBT core 1.3 Thank you!

fivetran-reneeli commented 1 year ago

No problem! Thanks for the updates!