fix: prevent duplicate alias in --empty mode for inline ref/source#1397
Open
fix: prevent duplicate alias in --empty mode for inline ref/source#1397
Conversation
DatabricksRelation inherited require_alias=True from BaseRelation, causing render_limited() to inject a _dbt_limit_subq_* alias that conflicts with user-provided AS aliases when running dbt run --empty. Databricks SQL does not require subquery aliases, so require_alias should be False. Resolves dbt-labs/dbt-adapters#660 for Databricks.
b2ca444 to
796bc4a
Compare
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
require_alias: bool = FalseonDatabricksRelation, preventingrender_limited()from injecting a_dbt_limit_subq_*alias that conflicts with user-providedASaliases when runningdbt run --empty--emptymode (BaseTestEmptyandBaseTestEmptyInlineSourceRef)render_limited()output has no trailing subquery aliasContext
When
dbt run --emptyis used, dbt wrapsref()andsource()in a zero-row subquery.BaseRelationdefaults torequire_alias=True, which appends an auto-generated alias (_dbt_limit_subq_{table}). If the user also has anASalias in their SQL (e.g.{{ ref('orders') }} AS orders), the two aliases conflict and produce invalid SQL.Databricks SQL does not require subquery aliases, so
require_aliasshould beFalse.Resolves dbt-labs/dbt-adapters#660 for Databricks.
Test plan
test_render_limited_with_empty_no_alias— assertsrender_limited()produces no trailing alias withlimit=0TestDatabricksEmptyInlineSourceRef— end-to-end against live cluster,dbt run --emptywith inline source aliasTestDatabricksEmpty— general--emptyconformance