Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Arbitrary aliasing in macros #149

Open
DVAlexHiggs opened this issue Aug 15, 2022 · 0 comments
Open

[FEATURE] Arbitrary aliasing in macros #149

DVAlexHiggs opened this issue Aug 15, 2022 · 0 comments
Assignees
Labels
feature This is is requesting a new feature

Comments

@DVAlexHiggs
Copy link
Member

DVAlexHiggs commented Aug 15, 2022

At the moment you can alias a hashdiff in dbtvault satellite macros. This is so that you may have a standardised name for your hashdiff in every satellite, even if they share the same primed staging area.

This use case is not isolated to hashdiffs however, for example for a Link Primary key we may want to always call them LINK_HK fo simplicity of joins later on, or just so we have uniform links.

Being able to do this for any parameter in any macro would be ideal, and would make it much easier to standardise across our raw vault.

Something like the following would be very useful:

{%- set yaml_metadata -%}
source_model: stg_web_customer_hashed
src_pk: CUSTOMER_HK
src_nk: 
  - source_column: HUB_CUSTOMER_CK
    alias: COLLISION_KEY
  - CUSTOMER_ID
src_ldts: LOAD_DATETIME
src_source: RECORD_SOURCE
{%- endset -%}

{% set metadata_dict = fromyaml(yaml_metadata) %}

{{ dbtvault.hub(src_pk=metadata_dict["src_pk"],
                src_nk=metadata_dict["src_nk"], 
                src_ldts=metadata_dict["src_ldts"],
                src_source=metadata_dict["src_source"],
                source_model=metadata_dict["source_model"]) }}

Resulting in a table like:

CUSTOMER_HK CUSTOMER_ID COLLISION_KEY LOAD_DATETIME RECORD_SOURCE
b8c37e33defde51cf91e1e03e51657da 1001 CUSTOMER_CRM 1993-01-01 00:00:00.000 CUSTOMER_CRM

The future

On the topic of standardised naming, we plan to make this configuration centralised. Some day wuldn't it be cool if you could do the following in dbt_project.yml:

vars:
  hash: MD5
  hashdiff_name: HASHDIFF

This would ensure the hashdiff of every satellite would be named HASHDIFF

AB#5370

@DVAlexHiggs DVAlexHiggs added the feature This is is requesting a new feature label Aug 15, 2022
@DVAlexHiggs DVAlexHiggs self-assigned this Aug 15, 2022
@DVAlexHiggs DVAlexHiggs modified the milestone: Version 0.9.0 Aug 15, 2022
@DVAlexHiggs DVAlexHiggs added feature This is is requesting a new feature and removed feature This is is requesting a new feature labels May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This is is requesting a new feature
Projects
None yet
Development

No branches or pull requests

1 participant