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

Snapshot config to define column names #6146

Closed

Conversation

nataliefiann
Copy link
Contributor

@nataliefiann nataliefiann commented Sep 25, 2024

I've created this PR / added section to highlight new config allows users to define column names following this Git issue: https://github.com/orgs/dbt-labs/projects/14/views/35?pane=issue&itemId=80581863

Resolves #6112

What are you changing in this pull request and why?

Checklist

  • I have reviewed the Content style guide so my content adheres to these guidelines.
  • The topic I'm writing about is for specific dbt version(s) and I have versioned it according to the version a whole page and/or version a block of content guidelines.
  • I have added checklist item(s) to this list for anything anything that needs to happen before this PR is merged, such as "needs technical review" or "change base branch."

@nataliefiann nataliefiann requested a review from a team as a code owner September 25, 2024 12:19
Copy link

vercel bot commented Sep 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
docs-getdbt-com ✅ Ready (Inspect) Visit Preview Sep 30, 2024 0:41am

@github-actions github-actions bot added content Improvements or additions to content size: small This change will take 1 to 2 days to address labels Sep 25, 2024

- When you run your snapshots, dbt handles the renames from `example_valid_from` to `test_valid_from` for you.

You can read through the section on [Defining column names](/docs/build/snapshots#define-column-names-in-snapshot-table) for more information.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the link doesn't take me to the right place? or for some reason i didn't see the 'define column names' section?


```yml

snapshots:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use the full example from the issue!

snapshots:
  my_project:
    +snapshot_meta_column_names={
      dbt_valid_from: start_date,
      dbt_valid_to: end_date,
      dbt_scd_id: scd_id,
      dbt_updated_at: updated_date
    }


Use the following configuration to define the names of the columns created in the [snapshot table](/docs/build/snapshots#snapshot-meta-fields).

<File name='dbt_project.yml'>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's also show the example from the issue on how to do this in the config block:

{{
    config(
      target_database='analytics',
      target_schema='snapshots',
      unique_key='id',

      strategy='timestamp',
      updated_at='updated_at',
      
      snapshot_meta_column_names={
        dbt_valid_from: start_date,
        dbt_valid_to: end_date,
        dbt_scd_id: scd_id,
        dbt_updated_at: updated_date
      }
    )
}}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have some tab thing for other examples so you can see how to write a config in different places

</File>

- When you run your snapshots, dbt handles the renames from `dbt_valid_from` to `example_valid_from` for you.
- If you make subsequent updates to the config to rename the column, dbt manages the migration of column names for each configuration change. For example:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not true.

See issue -> #6112 (comment)

we aren't doing anything for migration, so if a user renames the columns for a snapshot without updating an existing table, they will get an error. The recommendation is to use these settings for new snapshots, or to arrange to update their existing tables prior to committing a column name change.


</File>

- When you run your snapshots, dbt handles the renames from `example_valid_from` to `test_valid_from` for you.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as above - this is not true

Copy link
Collaborator

@graciegoheen graciegoheen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments - I think this needs more work. Please see docs issue for examples to include and callout that we do not handle the migration -> #6112 (comment)

@nataliefiann
Copy link
Contributor Author

Closed off as Core project has been paused

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content Improvements or additions to content size: small This change will take 1 to 2 days to address
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Core] New snapshot_meta_column_names config for dbt snapshots
3 participants