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

[Bug] The --empty argument doesn't work on models with table aliases #818

Closed
2 tasks done
armandduijn opened this issue May 10, 2024 · 3 comments · Fixed by #817
Closed
2 tasks done

[Bug] The --empty argument doesn't work on models with table aliases #818

armandduijn opened this issue May 10, 2024 · 3 comments · Fixed by #817
Labels
bug Something isn't working Stale

Comments

@armandduijn
Copy link

armandduijn commented May 10, 2024

Is this a new bug in dbt-core?

  • I believe this is a new bug in dbt-core
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

I get a Database Error when I use the --empty argument on a model that uses table aliases.

Expected Behavior

I expect dbt to materialize the empty model.

Steps To Reproduce

  1. Create a model my_model. Alias the referenced model.

    SELECT e.*
    FROM {{ source("atomic", "events") }} e
  2. Run dbt with the --empty argument.

    dbt --debug run --select my_model --empty

I get the same error if I add AS in front of the alias name.

Relevant log output

10:25:16  On model.snowplow.my_model: /* {"app": "dbt", "dbt_version": "1.8.0", "profile_name": "studyportals", "target_name": "staging", "node_id": "model.snowplow.my_model"} */


  create view studyportals.dbt_test.my_model__dbt_tmp as (
    SELECT e.*
FROM (select * from studyportals.atomic.events where false limit 0) _dbt_limit_subq_events e
  ) with no schema binding;
10:25:16  Redshift adapter: Redshift error: syntax error at or near "e"
10:25:16  On model.snowplow.my_model: ROLLBACK
10:25:16  On model.snowplow.my_model: Close
10:25:16  Database Error in model my_model (models\my_model.sql)
  syntax error at or near "e"
  compiled Code at target\run\snowplow\models\my_model.sql

Environment

- OS: Windows
- Python: 3.10.11
- dbt: 1.8.0

Which database adapter are you using with dbt?

redshift

Additional Context

No response

@armandduijn armandduijn added bug Something isn't working triage labels May 10, 2024
@jtcohen6
Copy link
Contributor

@armandduijn This is a known limitation on data platforms that require aliases for subqueries (e.g. Postgres):

However, it looks like you're using Redshift, so I'm surprised to hear you're hitting this error —

It looks like that PR was merged to main but wasn't backported to 1.8.latestfor inclusion in v1.8.0. As soon as we merge that backport and include it in adbt-redshift` patch release, I hope this will start working for you:

In the meantime, I'm going to transfer this issue to dbt-redshift.

@jtcohen6 jtcohen6 removed the triage label May 10, 2024
@jtcohen6 jtcohen6 transferred this issue from dbt-labs/dbt-core May 10, 2024
Copy link
Contributor

github-actions bot commented Nov 7, 2024

This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days.

@github-actions github-actions bot added the Stale label Nov 7, 2024
Copy link
Contributor

Although we are closing this issue as stale, it's not gone forever. Issues can be reopened if there is renewed community interest. Just add a comment to notify the maintainers.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants