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

tuple index out of range in custom schema tests with select * #1808

Closed
abronner opened this issue Oct 5, 2019 · 1 comment · Fixed by #1903
Closed

tuple index out of range in custom schema tests with select * #1808

abronner opened this issue Oct 5, 2019 · 1 comment · Fixed by #1903
Labels
bug Something isn't working good_first_issue Straightforward + self-contained changes, good for new contributors!

Comments

@abronner
Copy link

abronner commented Oct 5, 2019

if a custom schema test returns the result of select * instead of select count(*), and the query returns 0 records, then the test fails with the error message: tuple index out of range.

schema tests should return a single row with a single column that contains the count of failures. if select * returns 0 records, dbt hits tuple index out of range when it tries to grab the first column in the first row of that result set.

to reproduce, add the following test to your model:

{% macro test_my_custom_schema_test(model, column_name) %}

SELECT * from {{ model }} WHERE 1=0

{% endmacro %}

result of dbt test:

Completed with 1 errors:

tuple index out of range

please add a better error message when a test returns a different result than what is expected.

@abronner abronner added bug Something isn't working triage labels Oct 5, 2019
@drewbanin drewbanin added good_first_issue Straightforward + self-contained changes, good for new contributors! and removed triage labels Oct 7, 2019
@drewbanin
Copy link
Contributor

Thanks @abronner! Agreed, a better error message here would be a great addition.

I just put a good first issue label on this issue - please let me know if it's something you'd be interested in contributing a fix for! I think the patch should be pretty self-contained :)

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good_first_issue Straightforward + self-contained changes, good for new contributors!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants