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

fix: Do not require alias to avoid duplicate aliasing with --empty #1162

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

anaghshineh
Copy link

@anaghshineh anaghshineh commented Dec 14, 2024

resolves #1098
docs N/A

Problem

When running a dry run via --empty, dbt would duplicate any model aliases, causing the query to fail due to invalid syntax.

Solution

This PR adopts the approaches taken in other adapters that do not require aliasing. Namely, it overrides the default True value for require_alias, setting it to False. As a result, when dbt creates dynamic SQL for dry runs, it does not inject additional aliasing. Thus, if a reference uses an alias, it keeps it as is. If not, it does not inject anything.

I also imported the BaseTestEmptyInlineSourceRef from dbt-adapters to run those additional tests. Please let me know if you'd like to see additional testing done for this PR!

Checklist

  • I have read the contributing guide and understand what's expected of me
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc) or this PR has already received feedback and approval from Product or DX

@anaghshineh anaghshineh requested a review from a team as a code owner December 14, 2024 17:15
@cla-bot cla-bot bot added the cla:yes label Dec 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] The --empty flag produces broken SQL when code has {{ref...}}or {{source..}} with an alias
1 participant