# Can we use multiple Bigquery datasets (or projects) in the same dbt project?

**URL:** <https://discourse.getdbt.com/t/can-we-use-multiple-bigquery-datasets-or-projects-in-the-same-dbt-project/769>\
**Category:** Help\
**Created:** [December 25, 2019, 6:04pm UTC](https://discourse.getdbt.com/t/can-we-use-multiple-bigquery-datasets-or-projects-in-the-same-dbt-project/769 "2019-12-25T18:04:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hangtran](https://avatars.discourse-cdn.com/v4/letter/h/73ab20/32.png) [@hangtran](https://discourse.getdbt.com/u/hangtran)\
**Post date:** [December 25, 2019, 6:04pm UTC](https://discourse.getdbt.com/t/can-we-use-multiple-bigquery-datasets-or-projects-in-the-same-dbt-project/769/1 "2019-12-25T18:04:18Z")

</div>

Hi friends,

I’m a newbie. And I have a question about using multiple BigQuery datasets (or projects).  
dbt means by “warehouse” as “BigQuery: a single BigQuery account, with access to one or more projects”. So in the documents, it just shows how to config and work with one dataset only.

My scenario is as shown below.  
In the same project of bigquery, I have multiple datasets of data sources e.g. recurly, saleforces, …  
and a dataset for transformed data e.g. edw.

Is it possible in dbt project when using multiple BigQuery datasets (or multiple BigQuery projects)? If so, please let me know how to configure in profiles.yml and give me a sample model using these configs.

I’m looking forward to hearing from you.

Thanks,  
Hang Tran

---

<div class="post-metadata">

**Author:** ![ruben.tvh](https://avatars.discourse-cdn.com/v4/letter/r/e9bcb4/32.png) [@ruben.tvh](https://discourse.getdbt.com/u/ruben.tvh)\
**Post date:** [November 12, 2020, 3:21pm UTC](https://discourse.getdbt.com/t/can-we-use-multiple-bigquery-datasets-or-projects-in-the-same-dbt-project/769/2 "2020-11-12T15:21:38Z")

</div>

I’m dealing with the exact same issue.  
My query consists out of data from different bigquery projects and different bigquery datasets. But if I read the documentation it seems like only querying within the same Bigquery project is allowed.  
Any updates if this is possible?

Kind regards,  
Ruben

---

<div class="post-metadata">

**Author:** ![PowdyPowPow](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/powdypowpow/32/551_2.png) [@PowdyPowPow](https://discourse.getdbt.com/u/PowdyPowPow)\
**Post date:** [November 15, 2020, 9:01am UTC](https://discourse.getdbt.com/t/can-we-use-multiple-bigquery-datasets-or-projects-in-the-same-dbt-project/769/3 "2020-11-15T09:01:56Z")

</div>

Yes, this is possible to do using custom [database](https://docs.getdbt.com/docs/building-a-dbt-project/building-models/using-custom-database) and [schema](https://docs.getdbt.com/docs/building-a-dbt-project/building-models/using-custom-schemas).

In the simplest form you would use the `database` and `schema` parameters. You can use those parameters when defining `sources`, to specify where your source datasets are. And you can use them to define where dbt should build your `models`, either in your `dbt_project.yml` or `model` config.

For even more control you can also consider changing the `generate_schema_name` or `generate_database_name` macros.

Also note that the `project_id` you define in your `profiles.yml` will be the project used for BQ billing.

Hope that helps,

---

<div class="post-metadata">

**Author:** ![ruben.tvh](https://avatars.discourse-cdn.com/v4/letter/r/e9bcb4/32.png) [@ruben.tvh](https://discourse.getdbt.com/u/ruben.tvh)\
**Post date:** [November 23, 2020, 2:35pm UTC](https://discourse.getdbt.com/t/can-we-use-multiple-bigquery-datasets-or-projects-in-the-same-dbt-project/769/4 "2020-11-23T14:35:24Z")

</div>

Thanks for your comprehensive answer! 😃 You’ve even already answered the question I wanted to ask next 😃

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/getdbt/original/1X/a7a7ca1fe379aaf90952b0e13118a817babcd14f.png) [@system](https://discourse.getdbt.com/u/system)\
**Post date:** [September 9, 2022, 4:00am UTC](https://discourse.getdbt.com/t/can-we-use-multiple-bigquery-datasets-or-projects-in-the-same-dbt-project/769/5 "2022-09-09T04:00:22Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
