# global variable

**URL:** <https://discourse.getdbt.com/t/global-variable/13163>\
**Category:** Help\
**Created:** [May 2, 2024, 3:53pm UTC](https://discourse.getdbt.com/t/global-variable/13163 "2024-05-02T15:53:37Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![nagko.neni](https://avatars.discourse-cdn.com/v4/letter/n/c37758/32.png) [@nagko.neni](https://discourse.getdbt.com/u/nagko.neni)\
**Post date:** [May 2, 2024, 3:53pm UTC](https://discourse.getdbt.com/t/global-variable/13163/1 "2024-05-02T15:53:37Z")

</div>

## The problem I’m having

was trying , having some issue  
Compilation Error in model stg\_tpch\_line\_items (models/staging/tpch/stg\_tpch\_line\_items.sql)

Warning: dbt\_utils.surrogate\_key has been replaced by dbt\_utils.generate\_surrogate\_key. The new macro treats null values differently to empty strings. To restore the behaviour of the original macro, add a global variable in dbt\_project.yml called surrogate\_key\_treat\_nulls\_as\_empty\_strings to your dbt\_project.yml file with a value of True. The snowflake\_workshop.stg\_tpch\_line\_items model triggered this warning.

I have tried , added the dbt\_utils.surrogate\_key in dbt\_project.yml , still having the same issue ! any suggestions \>

---

<div class="post-metadata">

**Author:** ![brunoszdl](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/brunoszdl/32/4113_2.png) [@brunoszdl](https://discourse.getdbt.com/u/brunoszdl)\
**Post date:** [May 2, 2024, 5:37pm UTC](https://discourse.getdbt.com/t/global-variable/13163/2 "2024-05-02T17:37:56Z")

</div>

> [@nagko.neni](#):
>
> I have tried , added the dbt\_utils.surrogate\_key in dbt\_project.yml , still having the same issue ! any suggestions \>

Have you tried `dbt_utils.surrogate_key ` or `dbt_utils.generate.surrogate_key `?

---

<div class="post-metadata">

**Author:** ![nagko.neni](https://avatars.discourse-cdn.com/v4/letter/n/c37758/32.png) [@nagko.neni](https://discourse.getdbt.com/u/nagko.neni)\
**Post date:** [May 2, 2024, 5:42pm UTC](https://discourse.getdbt.com/t/global-variable/13163/3 "2024-05-02T17:42:06Z")

</div>

> [@brunoszdl](#):
>
> dbt\_utils.generate.surrogate\_key

Brother, bruno…thx  
yes, I have tried both `dbt_utils.surrogate_key ` or `dbt_utils.generate.surrogate_key` , but still having the same issue ! do you suspect any issues with versions …(I’m new to dbt)…if you think so! guide , thanks

---

<div class="post-metadata">

**Author:** ![brunoszdl](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/brunoszdl/32/4113_2.png) [@brunoszdl](https://discourse.getdbt.com/u/brunoszdl)\
**Post date:** [May 2, 2024, 8:19pm UTC](https://discourse.getdbt.com/t/global-variable/13163/4 "2024-05-02T20:19:00Z")

</div>

Could you paste your model here? And the versions of dbt and dbt\_utils you are using?

---

<div class="post-metadata">

**Author:** ![nagko.neni](https://avatars.discourse-cdn.com/v4/letter/n/c37758/32.png) [@nagko.neni](https://discourse.getdbt.com/u/nagko.neni)\
**Post date:** [May 3, 2024, 6:17am UTC](https://discourse.getdbt.com/t/global-variable/13163/5 "2024-05-03T06:17:39Z")

</div>

version 0.37.12 of the dbt Cloud CLI is now available. As of now, old versions are not actively supported - update now!  
dbt Cloud CLI - 0.37.11 (9221855f5b35004b4bc53ba2c9df9baf02fb9331 2024-04-26T15:56:01Z)

–dbt\_utils: version: 0.8.4

---

<div class="post-metadata">

**Author:** ![nagko.neni](https://avatars.discourse-cdn.com/v4/letter/n/c37758/32.png) [@nagko.neni](https://discourse.getdbt.com/u/nagko.neni)\
**Post date:** [May 3, 2024, 8:43am UTC](https://discourse.getdbt.com/t/global-variable/13163/6 "2024-05-03T08:43:16Z")

</div>

here is the model…

```auto
with source as (

    select * from {{ source('tpch', 'lineitem') }}

),

renamed as (

    select
    
        {{ dbt_utils.surrogate_key(
            ['l_orderkey', 
            'l_linenumber']) }}
                as order_item_key,
        l_orderkey as order_key,
        l_partkey as part_key,
        l_suppkey as supplier_key,
        l_linenumber as line_number,
        l_quantity as quantity,
        l_extendedprice as extended_price,
        l_discount as discount_percentage,
        l_tax as tax_rate,
        l_returnflag as return_flag,
        l_linestatus as status_code,
        l_shipdate as ship_date,
        l_commitdate as commit_date,
        l_receiptdate as receipt_date,
        l_shipinstruct as ship_instructions,
        l_shipmode as ship_mode,
        l_comment as comment

    from source

)

select * from renamed

```

---

<div class="post-metadata">

**Author:** ![brunoszdl](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/brunoszdl/32/4113_2.png) [@brunoszdl](https://discourse.getdbt.com/u/brunoszdl)\
**Post date:** [May 3, 2024, 12:43pm UTC](https://discourse.getdbt.com/t/global-variable/13163/7 "2024-05-03T12:43:53Z")

</div>

Ok, you are using dbt Cloud. Yeah this could be a version issue.

Check the dbt version in your environment in dbt Cloud, you are probably using a version \>=1.3.

You will probably need to update your dbt utils to at least v1.0.0, where the new surrogate key macro was implemented.

---

<div class="post-metadata">

**Author:** ![nagko.neni](https://avatars.discourse-cdn.com/v4/letter/n/c37758/32.png) [@nagko.neni](https://discourse.getdbt.com/u/nagko.neni)\
**Post date:** [May 3, 2024, 1:58pm UTC](https://discourse.getdbt.com/t/global-variable/13163/8 "2024-05-03T13:58:31Z")

</div>

Hi Bro,  
yes, utils version is updated to 1.0.0, the problem is resolved…thanks a lot …
