-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[Bug] Unexpected unit test exception - column does not exist #11480
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
Comments
Thanks for reaching out @Auric-Manteo ! Do you get the error if you use a seed file instead of a source file? i.e. using See below for a full example with all necessary files. Could you try tweaking these to get the error that you are reporting? Project files and commandsCreate these files:
with agreement_party as (
select
agreement_party.id,
_airbyte_emitted_at as added_to_staging_layer_at_utc
from {{ ref("core_api_source__core_api_agreement_party") }} as agreement_party
)
select *
from agreement_party
unit_tests:
- name: test42
model: core_api_agreement_party
given:
- input: ref("core_api_source__core_api_agreement_party")
rows:
- {id: 5, agreement_id: 102, name: 'roro', phone_number: 1234567, email: '[email protected]', _airbyte_emitted_at: 2024-02-01}
- input: this
rows:
- {id: 1, added_to_staging_layer_at_utc: 2025-01-01}
expect:
rows:
- {id: 5} Run these commands: dbt seed
dbt run
dbt test --debug --exclude "test_type:data" --select models/test_core_api_agreement_party.yml Get this output:
|
Hi dbeatty10, |
@Auric-Manteo We'll need to reproduce the issue reported first before we can choose next steps. Could you try tweaking the code I provided to get the error that you are reporting? |
@dbeatty10 yes, of course
You mean the example I posted does not produce the error for you? |
@Auric-Manteo After taking another look, the issue you are running into is the same as open issue #10433, so I'm going to close this one as a duplicate. Short explanationThe name of your source table and the name of your dbt model are identical. In these cases, dbt is only creating one CTE when it needs two CTE for the unit test fixtures, leading to the error you are seeing 💥 Could you try the 1st workaround listed below and let me know if it works for you? WorkaroundsSome different workarounds in the meantime:
Use a source name that differs from the table name in the databaseChange this: sources:
- name: core_api_source
tables:
- name: core_api_agreement_party # actual name in the database to this: sources:
- name: core_api_source
tables:
- name: SOURCE_WITH_UNIQUE_NAME_HERE # what I want to call it in dbt
identifier: core_api_source__core_api_agreement_party # actual name in the database |
Ok, cool. I'll wait for the bugfix and try again then.
|
Thanks for trying that out @Auric-Manteo ! You're right -- the error message you ran into is a related issue to what you originally reported. So the workarounds are just these two:
|
Is this a new bug in dbt-core?
Current Behavior
Hi,
I get an unexpected error in my unit test. We boiled it down to this "working" example.
If you see a possible workaround please respond in the Slack thread:
https://getdbt.slack.com/archives/C01UM2N7814/p1744267340681719
models/core_api_agreement_party.sql
models/test_core_api_agreement_party.yml
The generated SQL query is:
Expected Behavior
The unit test does not raise an unexpected error.
Steps To Reproduce
Add the files mentioned in the description and run the test via:
Relevant log output
Environment
Which database adapter are you using with dbt?
redshift
Additional Context
No response
The text was updated successfully, but these errors were encountered: