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

Update docs to clarify the way aliases are used in CTEs #5795

Conversation

jeancochrane
Copy link
Contributor

What are you changing in this pull request and why?

This PR updates the docs to reflect the bugfix made in dbt-labs/dbt-core#10290 and dbt-labs/dbt-adapters#236 to bring the identifiers used for CTEs in line with the identifiers used for tables and views.

⚠️ Note that these changes should not be deployed until those two PRs have been merged and released, since these docs will not accurately reflect the behavior of the packages until they have been patched. I've included this prerequisite in the checklist below.

Checklist

Copy link

welcome bot commented Jul 17, 2024

Hello!👋 Thanks for contributing to the dbt product documentation and opening this pull request! ✨
We use Markdown and some HTML to write the dbt product documentation. When writing content, you can use our style guide and content types to understand our writing standards and how we organize information in the dbt product docs.
We'll review your contribution and respond as soon as we can. 😄

Copy link

vercel bot commented Jul 17, 2024

@jeancochrane is attempting to deploy a commit to the dbt-labs Team on Vercel.

A member of the Team first needs to authorize it.

@runleonarun runleonarun added the new contributor Label for first-time contributors label Jul 17, 2024
@github-actions github-actions bot added content Improvements or additions to content size: small This change will take 1 to 2 days to address and removed new contributor Label for first-time contributors labels Jul 17, 2024
@jeancochrane jeancochrane marked this pull request as ready for review July 17, 2024 19:28
@jeancochrane jeancochrane requested a review from a team as a code owner July 17, 2024 19:28
Comment on lines +19 to +24
| Model | Config | Relation Type | Database Identifier |
| ----- | ------ | --------------| ------------------- |
| ga_sessions.sql | {{ config(materialization='view') }} | <Term id="view" /> | "analytics"."ga_sessions" |
| ga_sessions.sql | {{ config(materialization='view', alias='sessions') }} | <Term id="view" /> | "analytics"."sessions" |
| ga_sessions.sql | {{ config(materialization='ephemeral') }} | <Term id="cte" /> | "\__dbt\__cte\__ga_sessions" |
| ga_sessions.sql | {{ config(materialization='ephemeral', alias='sessions') }} | <Term id="cte" /> | "\__dbt\__cte\__sessions" |
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not actually sure whether it's helpful to document the CTE identifier behavior here, so I understand if you'd prefer to keep this table focused on the alias rather than explaining the different behavior of ephemeral materialization.

Copy link
Contributor

Choose a reason for hiding this comment

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

Very helpful! Thank you


### Why alias model names?
The names of schemas and tables are effectively the "user interface" of your <Term id="data-warehouse" />. Well-named schemas and tables can help provide clarity and direction for consumers of this data. In combination with [custom schemas](/docs/build/custom-schemas), model aliasing is a powerful mechanism for designing your warehouse.

### Usage
The `alias` config can be used to change the name of a model's identifier in the database. The following <Term id="table" /> shows examples of database identifiers for models both with, and without, a supplied `alias`.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tweaked this line to remove the misleading <Term> component, since in this case we're not actually talking about a relation (which is what the term documents), we're just referencing the markup table that follows.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good call! Thank you

Copy link

vercel bot commented Aug 6, 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 Aug 6, 2024 8:23pm

Copy link
Contributor

@matthewshaver matthewshaver left a comment

Choose a reason for hiding this comment

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

This looks great @jeancochrane Thank you so much!

Not sure why the links weren't taking with the anchor. Will have to figure out what's causing that to fail.

@matthewshaver matthewshaver merged commit a4c9f11 into dbt-labs:current Aug 6, 2024
3 checks passed
@jeancochrane
Copy link
Contributor Author

Thanks for getting this over the line @matthewshaver! Just a quick flag that per the note in the PR description, the behavior described in this PR is not technically correct until dbt-labs/dbt-core#10290 and dbt-labs/dbt-adapters#236 get merged and released. I'll leave it to @dbeatty10 to decide the priority on those PRs, as the person who has been reviewing them so far.

@dbeatty10
Copy link
Contributor

Thanks for calling this out @jeancochrane.

@matthewshaver could we revert this docs PR until dbt-labs/dbt-core#10290 and dbt-labs/dbt-adapters#236 are included in a release?

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.

4 participants