Skip to content
This repository was archived by the owner on Sep 2, 2025. It is now read-only.

Conversation

@anaghshineh
Copy link

@anaghshineh anaghshineh commented Dec 14, 2024

resolves dbt-labs/dbt-adapters#474
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
@VersusFacit
Copy link
Contributor

Thanks for your contribution. I ported your PR here and preserved your contribution entry on the changelog. Always appreciate when SMEs point out gaps in our runtime: dbt-labs/dbt-adapters#474

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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

2 participants