Velir / dbt-ga4

dbt Package for modeling raw data exported by Google Analytics 4. BigQuery support, only.
MIT License
289 stars 128 forks source link

Can't change destination project easily #231

Closed NicoGraziani closed 5 months ago

NicoGraziani commented 1 year ago

I've got several GA4 projects that my team works with and we use a single project in BigQuery to hosts each projects' extracts. We are using one project-raw to store raw tables and one project-staging to store base and staging models. Do you know if I can specify the destination project (=project-staging) to create each ga4_base and ga4_staging models in ?

adamribaudo-velir commented 1 year ago

Yes, you can do that in your dbt_project.yml https://docs.getdbt.com/reference/model-configs#general-configurations

jice-lavocat commented 1 year ago

Hi @adamribaudo-velir ,

I work with @NicoGraziani.

Thanks for the help. However, I'm not sure the general config related to the output will be enough.

Nicolas forgot to mention we are using the combined projects configuration. In this configuration, the pre-hook will call macro combine_property_data and will try to write into {{var('project')}}.{{var('dataset')}} (permalink).

Similarly, when building the model base_ga4__events, the source is specified in src_ga4.yml and uses the variable project specified to run the package (permalink).

So I'm not quite sure the only use of +database property will help here. We're still investigating if we could work our way around with available settings, or if we need to submit a PR to add some new parameter.

adamribaudo-velir commented 1 year ago

Got it. Yea the +database property will help for the staging and mart models, but not the base model.

Would it meet your needs if we had 2 variables source_project (to be used in src_ga4.yml and destination_project (to be used in the combine_property_data macro)? Open to other ideas.

NicoGraziani commented 1 year ago

Indeed. We were able to manually change the destination name into combine_property_data macro and in src_ga4.yml and it worked just fine. Adding these two variables will definitely help. I’m not sure whether it’s the best design for the library, but that’s the modification we had in mind too.

adamribaudo-velir commented 1 year ago

Oh great. Are you aware that you can override the macro in your own project so that you can continue to pull the latest from the library repo without fear of it being overwritten?

From: Nicolas Graziani @.> Sent: Tuesday, June 6, 2023 9:49 AM To: Velir/dbt-ga4 @.> Cc: Adam Ribaudo @.>; Mention @.> Subject: Re: [Velir/dbt-ga4] Can't change destination project easily (Issue #231)

Indeed. We were able to manually change the destination name into combine_property_data macro and in src_ga4.yml and it worked just fine. Adding these two variables will definitely help. I'm not sure whether it's the best design for the library, but that's the modification we had in mind too.

- Reply to this email directly, view it on GitHubhttps://github.com/Velir/dbt-ga4/issues/231#issuecomment-1578805603, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ARCCAAFTD5DXQAAU4UJYRB3XJ4YMHANCNFSM6AAAAAAY3HCA2A. You are receiving this because you were mentioned.Message ID: @.**@.>>

NicoGraziani commented 1 year ago

Yep, that's what we did. But ideally, we would like to avoid situations where the overwritten macro becomes outdated from the one in the package.

(Edited) We will do this in the meantime and if the 2 variables discussed above emerge, then, we will update our code. Note that overriding the macro is not enough unfortunately, because of the src_ga4.yml file.

adamribaudo-velir commented 5 months ago

This should be handled with #294