# \#dbt-utils

**URL:** https://discourse.getdbt.com/tag/dbt-utils/3.md

[Latest](https://discourse.getdbt.com/latest.md) · [Categories](https://discourse.getdbt.com/categories.md) · [Tags](https://discourse.getdbt.com/tags.md)

---

## [Serve dbt-hub packages through PyPi?](https://discourse.getdbt.com/t/serve-dbt-hub-packages-through-pypi/20926)

<div class="topic-metadata">

**Author:** [@Henk-Jan](https://discourse.getdbt.com/u/Henk-Jan)\
**Replies:** 0\
**Last updated:** [August 13, 2026, 3:23pm UTC](https://discourse.getdbt.com/t/serve-dbt-hub-packages-through-pypi/20926 "2026-08-13T15:23:14Z")

</div>

Dear dbt community, because of recent supply-chain incidents regarding third-party packages we can no longer download and install third party libraries from public registries, like dbt-hub, PyPi, npm etc. Now for Pytho…

---

## [Install dbt\_utils \> dbt\_project.yml not found](https://discourse.getdbt.com/t/install-dbt-utils-dbt-project-yml-not-found/15551)

<div class="topic-metadata">

**Author:** [@ab2374923](https://discourse.getdbt.com/u/ab2374923)\
**Replies:** 2\
**Last updated:** [April 22, 2025, 6:56am UTC](https://discourse.getdbt.com/t/install-dbt-utils-dbt-project-yml-not-found/15551 "2025-04-22T06:56:42Z")

</div>

Hey, I am using dbt-core 1.5.4 via Airflow on Google Cloud Composer. Recently I started using dbt\_utils and defined it in the packages.yml on the same level of the dbt\_project.yml as follows: packages: - local: ../oth…

---

## [🚀 Introducing \`cte2dbt\`: effortlessly convert SQL CTE into dbt models](https://discourse.getdbt.com/t/introducing-cte2dbt-effortlessly-convert-sql-cte-into-dbt-models/18369)

<div class="topic-metadata">

**Author:** [@piotr-yuxuan](https://discourse.getdbt.com/u/piotr-yuxuan)\
**Replies:** 0\
**Last updated:** [February 22, 2025, 5:42pm UTC](https://discourse.getdbt.com/t/introducing-cte2dbt-effortlessly-convert-sql-cte-into-dbt-models/18369 "2025-02-22T17:42:37Z")

</div>

Hello everyone! :waving\_hand: I’m excited to share cte2dbt, a small yet powerful Python module designed to simplify the transition from large, monolithic SQL queries to modular, reusable dbt models. If you’ve ever str…

---

## [Using variables inside the dbt\_utils.date\_spine macro](https://discourse.getdbt.com/t/using-variables-inside-the-dbt-utils-date-spine-macro/6566)

<div class="topic-metadata">

**Author:** [@dschupak](https://discourse.getdbt.com/u/dschupak)\
**Replies:** 10\
**Last updated:** [January 23, 2025, 8:26pm UTC](https://discourse.getdbt.com/t/using-variables-inside-the-dbt-utils-date-spine-macro/6566 "2025-01-23T20:26:17Z")

</div>

I’m trying to create a date spine that where the first and last timestamps are taken from another model. For example, if I have a table that shows the times that someone logs onto their computer, I want to create a date…

---

## [Check row count of columns within a same table](https://discourse.getdbt.com/t/check-row-count-of-columns-within-a-same-table/16634)

<div class="topic-metadata">

**Author:** [@Jinns](https://discourse.getdbt.com/u/Jinns)\
**Replies:** 1\
**Last updated:** [October 18, 2024, 11:57pm UTC](https://discourse.getdbt.com/t/check-row-count-of-columns-within-a-same-table/16634 "2024-10-18T23:57:08Z")

</div>

The problem I’m having I would like to seek for a solution that can help to check the row count of different columns within a same table (Do not want to use macro) The context of why I’m trying to do this What I’ve alre…

---

## [A partial workaround for dbt\_utils.star not working with CTEs](https://discourse.getdbt.com/t/a-partial-workaround-for-dbt-utils-star-not-working-with-ctes/1369)

<div class="topic-metadata">

**Author:** [@joellabes](https://discourse.getdbt.com/u/joellabes)\
**Replies:** 0\
**Last updated:** [July 6, 2020, 10:13pm UTC](https://discourse.getdbt.com/t/a-partial-workaround-for-dbt-utils-star-not-working-with-ctes/1369 "2020-07-06T22:13:44Z")

</div>

Since dbt\_utils.star doesn’t work on CTEs, I’ve made a wee macro which solves my most common need: pulling all but a couple of columns out of a CTE in the same model file. To use it, you need to set the columns in your s…

---

## [Combining dbt\_utils.get\_relations\_by\_pattern with dbt\_utils.union\_relations breaks lineage in Redshift](https://discourse.getdbt.com/t/combining-dbt-utils-get-relations-by-pattern-with-dbt-utils-union-relations-breaks-lineage-in-redshift/13394)

<div class="topic-metadata">

**Author:** [@malte.hoefers](https://discourse.getdbt.com/u/malte.hoefers)\
**Replies:** 2\
**Last updated:** [May 16, 2024, 1:02pm UTC](https://discourse.getdbt.com/t/combining-dbt-utils-get-relations-by-pattern-with-dbt-utils-union-relations-breaks-lineage-in-redshift/13394 "2024-05-16T13:02:22Z")

</div>

The problem I’m having We have a few models, that select from a longer list of other models and combine them with a “union all”. Thus we found the two macros in dbt\_utils, that in combination makes the modeling much more…

---

## [I'm trying to install packages from packages.yml using dbt deps and encountering an issue in Mac with SSL cert](https://discourse.getdbt.com/t/im-trying-to-install-packages-from-packages-yml-using-dbt-deps-and-encountering-an-issue-in-mac-with-ssl-cert/11731)

<div class="topic-metadata">

**Author:** [@swetha\_dbt](https://discourse.getdbt.com/u/swetha_dbt)\
**Replies:** 2\
**Last updated:** [January 29, 2024, 1:35pm UTC](https://discourse.getdbt.com/t/im-trying-to-install-packages-from-packages-yml-using-dbt-deps-and-encountering-an-issue-in-mac-with-ssl-cert/11731 "2024-01-29T13:35:54Z")

</div>

The problem I’m having When I try to run dbt deps command in terminal I’m encountering the following issue Encountered an error: External connection exception occurred: HTTPSConnectionPool(host=‘hub.getdbt.com’, port=4…

---

## [dbt\_utils macros problem](https://discourse.getdbt.com/t/dbt-utils-macros-problem/8853)

<div class="topic-metadata">

**Author:** [@anshuldimri5](https://discourse.getdbt.com/u/anshuldimri5)\
**Replies:** 1\
**Last updated:** [June 26, 2023, 3:21am UTC](https://discourse.getdbt.com/t/dbt-utils-macros-problem/8853 "2023-06-26T03:21:10Z")

</div>

I was using dbt\_utils packages date\_spine macro but it shows ‘dict object’ has no attribute ‘get\_intervals\_between’ \> in macro date\_spine (macros/date\_spine.sql) \> called by rpc request (from remote system.sql) The con…

---

## [dbt\_utils union\_relations column\_override not working](https://discourse.getdbt.com/t/dbt-utils-union-relations-column-override-not-working/8675)

<div class="topic-metadata">

**Author:** [@master78east](https://discourse.getdbt.com/u/master78east)\
**Replies:** 1\
**Last updated:** [June 12, 2023, 5:47pm UTC](https://discourse.getdbt.com/t/dbt-utils-union-relations-column-override-not-working/8675 "2023-06-12T17:47:04Z")

</div>

I am trying to use the column\_override arg in the dbt\_utils union\_relations macro, but it doesn’t seem to work when my code compiles. {{ dbt\_utils.union\_relations( relations=\[ ref('base\_consumer\_digital\_ad\_…

---

## [How to config the dbt\_profile.yml in proper way to tag schemas in folder](https://discourse.getdbt.com/t/how-to-config-the-dbt-profile-yml-in-proper-way-to-tag-schemas-in-folder/8088)

<div class="topic-metadata">

**Author:** [@Sam777](https://discourse.getdbt.com/u/Sam777)\
**Replies:** 0\
**Last updated:** [April 29, 2023, 7:33pm UTC](https://discourse.getdbt.com/t/how-to-config-the-dbt-profile-yml-in-proper-way-to-tag-schemas-in-folder/8088 "2023-04-29T19:33:39Z")

</div>

Hi there How do I config the models properly in the dbt\_profile.yml Project\_name/ data\_ingestion/ | input\_data/ | | input.csv | staging/ | dbt\_mode…

---

## [How to capture dbt expectations tests on Big query](https://discourse.getdbt.com/t/how-to-capture-dbt-expectations-tests-on-big-query/7008)

<div class="topic-metadata">

**Author:** [@vennapuc](https://discourse.getdbt.com/u/vennapuc)\
**Replies:** 2\
**Last updated:** [March 3, 2023, 11:07pm UTC](https://discourse.getdbt.com/t/how-to-capture-dbt-expectations-tests-on-big-query/7008 "2023-03-03T23:07:05Z")

</div>

Hi All, I am planning to use dbt\_expectations package to do data quality checks in Big query using dbt. After defining data quality checks in schema.yaml , when I run dbt TEST, it’s showing failures on console. Is th…

---

## [Insert to a table using loops](https://discourse.getdbt.com/t/insert-to-a-table-using-loops/6776)

<div class="topic-metadata">

**Author:** [@Elinor](https://discourse.getdbt.com/u/Elinor)\
**Replies:** 1\
**Last updated:** [February 13, 2023, 10:49am UTC](https://discourse.getdbt.com/t/insert-to-a-table-using-loops/6776 "2023-02-13T10:49:27Z")

</div>

Hey All, I have a use case that I need to iterate on an sql query and insert the results each iteration to an existing table. for example I want to run it on a period of 3 days, so each iteration will have a different …

---

## [Combing dbtutils "surrogate key" with "get filtered columns in relation" produces new warning](https://discourse.getdbt.com/t/combing-dbtutils-surrogate-key-with-get-filtered-columns-in-relation-produces-new-warning/5132)

<div class="topic-metadata">

**Author:** [@jeffsk](https://discourse.getdbt.com/u/jeffsk)\
**Replies:** 5\
**Last updated:** [November 4, 2022, 7:34pm UTC](https://discourse.getdbt.com/t/combing-dbtutils-surrogate-key-with-get-filtered-columns-in-relation-produces-new-warning/5132 "2022-11-04T19:34:50Z")

</div>

Environment: dbt 1.3, dbt could beta, snowflake, windows packages: - package: dbt-labs/dbt\_utils version: 0.9.2 Issue: doing this: {{ dbt\_utils.surrogate\_key(dbt\_utils.get\_filtered\_columns\_in\_relation( source('…

---

## [Unusual UndefinedMacroException error](https://discourse.getdbt.com/t/unusual-undefinedmacroexception-error/4827)

<div class="topic-metadata">

**Author:** [@datachef](https://discourse.getdbt.com/u/datachef)\
**Replies:** 1\
**Last updated:** [September 6, 2022, 4:26pm UTC](https://discourse.getdbt.com/t/unusual-undefinedmacroexception-error/4827 "2022-09-06T16:26:24Z")

</div>

I am trying to create histogram bins in dbt using jinja. This is the code I am using. {% set sql\_statement %} select min(eir) as min\_eir, floor((max(eir) - min(eir))/10) + 1 as bin\_size from {{ ref('interest\_rate\_t…

---

## [Avoiding collisions during MD5 surrogate key creation](https://discourse.getdbt.com/t/avoiding-collisions-during-md5-surrogate-key-creation/4727)

<div class="topic-metadata">

**Author:** [@mf36](https://discourse.getdbt.com/u/mf36)\
**Replies:** 2\
**Last updated:** [August 10, 2022, 11:28pm UTC](https://discourse.getdbt.com/t/avoiding-collisions-during-md5-surrogate-key-creation/4727 "2022-08-10T23:28:13Z")

</div>

Hi all, I searched the forum but did not find a thread specific to my topic, but only closely related ones as per the following: For surrogate key creation, dbt utils implements md5 hashing \[1\] Auto incrementing has o…

---

## [Using get\_column\_values with CTEs](https://discourse.getdbt.com/t/using-get-column-values-with-ctes/1423)

<div class="topic-metadata">

**Author:** [@fishinwdbt](https://discourse.getdbt.com/u/fishinwdbt)\
**Replies:** 2\
**Last updated:** [July 21, 2020, 3:03pm UTC](https://discourse.getdbt.com/t/using-get-column-values-with-ctes/1423 "2020-07-21T15:03:48Z")

</div>

Using: dbt 0.17.0 with BigQuery I’m new to dbt and looking to how to better incorporate macros from dbt\_utils into my workflow. In particular, I’m interested in using pivot and get\_column\_values but I have been unsucces…

---

## [Finding active days for a subscription/user/account (date spining)](https://discourse.getdbt.com/t/finding-active-days-for-a-subscription-user-account-date-spining/265)

<div class="topic-metadata">

**Author:** [@claire](https://discourse.getdbt.com/u/claire)\
**Replies:** 5\
**Last updated:** [August 3, 2021, 3:41am UTC](https://discourse.getdbt.com/t/finding-active-days-for-a-subscription-user-account-date-spining/265 "2021-08-03T03:41:43Z")

</div>

Every often, someone asks us about finding the active days for a subscription/user/account. We call this pattern “date spining” For example, this question was asked on dbt Slack last week: Any idea how to calculate th…

---

## [Can I create an auto-incrementing ID in dbt?](https://discourse.getdbt.com/t/can-i-create-an-auto-incrementing-id-in-dbt/579)

<div class="topic-metadata">

**Author:** [@momomoro](https://discourse.getdbt.com/u/momomoro)\
**Replies:** 4\
**Last updated:** [January 13, 2020, 9:03pm UTC](https://discourse.getdbt.com/t/can-i-create-an-auto-incrementing-id-in-dbt/579 "2020-01-13T21:03:34Z")

</div>

Is it possible to create an auto number field while creating models?

---

## [Pivoting and Incremental Materializations](https://discourse.getdbt.com/t/pivoting-and-incremental-materializations/532)

<div class="topic-metadata">

**Author:** [@elexisvenator](https://discourse.getdbt.com/u/elexisvenator)\
**Replies:** 0\
**Last updated:** [August 22, 2019, 6:35am UTC](https://discourse.getdbt.com/t/pivoting-and-incremental-materializations/532 "2019-08-22T06:35:06Z")

</div>

Pivoting data is a very common task for reporting models in dbt. So much so that one of the oldest and most useful utility macros is for pivoiting. In my experience though, pivoting doesn’t play very nice with one of on…
