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

[CT-2832] [Spike] Can the hook for latest model version unsuffixed view/clone leverage our clone macro/materialization? #8126

Closed
Tracked by #7979
jtcohen6 opened this issue Jul 18, 2023 · 3 comments

Comments

@jtcohen6
Copy link
Contributor

spike split out of #7442

We have documented/recommended some code for an opt-in post-hook, that creates an extra view pointing to the "latest" object: https://docs.getdbt.com/docs/collaborate/govern/model-versions#configuring-database-location-with-alias

Definition of done:

  • Spike on whether we can clean up this code by leveraging the clone macro / materialization that we developed for v1.6

If we can get to cleaner code that's supported across DWHs, it's then just a UX question of whether this is enabled/disabled via yaml config (option 2) or post-hook (option 3)

@github-actions github-actions bot changed the title [Spike] Can the hook for latest model version unsuffixed view/clone leverage our clone macro/materialization? [CT-2832] [Spike] Can the hook for latest model version unsuffixed view/clone leverage our clone macro/materialization? Jul 18, 2023
@aranke
Copy link
Member

aranke commented Sep 15, 2023

Thanks to @mikealfare's work, we can simplify the macro in the documentation to the following:

{% macro create_latest_version_view() %}

    -- this hook will run only if the model is versioned, and only if it's the latest version
    -- otherwise, it's a no-op
    {% if model.get('version') and model.get('version') == model.get('latest_version') %}

        {% set target_relation = this.incorporate(path={"identifier": model['name']}) %}
        
        {% do log("Creating view " ~ target_relation ~ " pointing to " ~ this, info = true) if execute %}
        
        {{ return(get_replace_view_sql(target_relation, "select * from {{ this }}")) }}
        
    {% else %}
    
        -- no-op
        select 1 as id
    
    {% endif %}

{% endmacro %}

I think this resolves the spike @jtcohen6, what should the next steps here be?

@jtcohen6
Copy link
Contributor Author

jtcohen6 commented Sep 15, 2023

@aranke That's great news! I think the next step here is actually moving forward with:

By (roughly):

  • executing that macro within the model run/build step
  • iff it's a versioned model, and this is the latest version
  • returning the appropriate information about the created/updated object to the cache

If that sounds right to you, I think we can close this spike and move forward with #7442 (schedule for the next sprint). Does that sound right to you?

@aranke
Copy link
Member

aranke commented Sep 15, 2023

Yup, that sounds right to me.
Closing this issue, and we can queue up #7442 for the next sprint.

@aranke aranke closed this as completed Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants