Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

dbt run --empty throws an error for models with aliased refs #898

Open
rodrigorabioglio opened this issue Jan 9, 2025 · 3 comments
Open
Labels
bug Something isn't working

Comments

@rodrigorabioglio
Copy link

rodrigorabioglio commented Jan 9, 2025

Describe the bug

Running dbt run --empty fails for any model that has a aliased relation, due to double aliasing on the compiled sql code.

Steps To Reproduce

  1. Create a model with a aliased ref:
    models/aliased_ref_model.sql :
SELECT *
FROM {{ ref('my_model') }} AS table1
  1. Run dbt run -s aliased_ref_model --empty
  2. Get the error:

_[PARSE_SYNTAX_ERROR] Syntax error at or near 'AS'. SQLSTATE: 42601
... FROM (select * from my_catalog.my_schema.aliased_ref_model where false limit 0) dbt_limit_subq_aliased_ref_model AS table1
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------^^^

Expected behavior

Run without error

System information

The output of dbt --version:

Core:
  - installed: 1.9.0
  - latest:    1.9.1 - Update available!

  Your version of dbt-core is out of date!
  You can find instructions for upgrading here:
  https://docs.getdbt.com/docs/installation

Plugins:
  - databricks: 1.9.1 - Up to date!
  - spark:      1.9.0 - Up to date!

Also fails on dbt-databricks~1.8

The operating system you're using:

MacOS Sequoia 15.2

The output of python --version:
Python 3.12.7

@rodrigorabioglio rodrigorabioglio added the bug Something isn't working label Jan 9, 2025
@rodrigorabioglio rodrigorabioglio changed the title dbt run --empty throws an error for already aliased refs dbt run --empty throws an error for models with aliased refs Jan 9, 2025
@benc-db
Copy link
Collaborator

benc-db commented Jan 15, 2025

Have you reported this to core? I'm not sure the databricks adapter controls any of the substitution involved.

@rodrigorabioglio
Copy link
Author

Ok Thanks! I'll link this issue on dbt-core!

@rodrigorabioglio
Copy link
Author

Reported: dbt-labs/dbt-adapters#199 (comment)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants