dbt-msft / tsql-utils

dbt-utils for the dbt-msft family of packages
MIT License
25 stars 24 forks source link

Multi-field surrogate key failing due to using default dbt_utils concat macro #62

Closed chiblackhawks closed 2 years ago

chiblackhawks commented 2 years ago

Hi,

I noticed while using surrogate_key that the compiled sql was syntactically incorrect due to the operator used to concat the list of fields I am passing to the macro. After some triage, I realized that it was using the default dbt_utils.concat() macro which uses '||' to concat.

In order to resolve this, I added the following to my dbt_project.yml:

dispatch:
  - macro_namespace: dbt_utils
    search_order: ['tsql_utils', 'dbt_utils']

vars:
  dbt_utils_dispatch_list: ['tsql_utils']
  dbt_date_dispatch_list: ['tsql_utils']
  audit_helper_dispatch_list: ['tsql_utils']
  dbt_expectations_dispatch_list: ['tsql_utils']

This solved the issue but I am not confident that this is the correct solution?

dataders commented 2 years ago

this is related to #52, which is a change as part of dbt 0.20.0. are you by chance using that version of dbt-sqlserver or dbt-synapse? If so, my apologies, I still have to update the docs to reflect those changes. It sounds, as if you've figured it out now though?

chiblackhawks commented 2 years ago

Sorry to have overlooked the original ticket. I am using the dbt-sqlserver package and was able to get it figured out by noticing the new dispatch method on the DBT docs page https://docs.getdbt.com/reference/dbt-jinja-functions/dispatch.

I am still getting set in a new role and am unsure how much longer we will be using Azure SQL - but if it appears to be a longer term architecture for us, I will gladly help out with anything in this repo.

Thanks for the quick response!

dataders commented 2 years ago

@chiblackhawks this week I'll be updating this repo, there's a number of pending changes that users are asking of. thanks for opening the issue!