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

[Feature] Unit testing models #12

Open
1 task done
JCZuurmond opened this issue Jun 1, 2022 · 5 comments
Open
1 task done

[Feature] Unit testing models #12

JCZuurmond opened this issue Jun 1, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@JCZuurmond
Copy link
Collaborator

JCZuurmond commented Jun 1, 2022

Is this your first time opening an issue?

Describe the Feature

Support unit testing models. Most likely we need another fixture to fetch a model, then similar to a macro, we use that fixture in a test.

To consider:

  • models usually contain references to other models or sources: ref and source. How do we handle this? Could we for example mock them? If so, can we share mocks across tests.

Describe alternatives you've considered

Not unit testing models, stick to unit testing macros. You can put the complex SQL - or all SQL - in (modular) macros, then test those. This is not user friendly though.

Who will this benefit?

Those who want to test models, not just macros

Are you interested in contributing this feature?

Yes

Anything else?

See discussion on this topic in the dbt-core repo

@JCZuurmond JCZuurmond added the enhancement New feature or request label Jun 1, 2022
@megetron3
Copy link

what happened with this one?

@JCZuurmond
Copy link
Collaborator Author

@megetron3 : I opened this issue to receive feedback from users on this feature. You can add a thumbs up on the first comment to signal your interest.

Currently, the package is lightweight and worked with new dbt releases with minimal/no changes making maintaining the package low time consuming. However, the functionality is also limited.

dbt Labs announced adding unit testing capabilities to dbt-core. I am not up-to-date with the status. I prefer they supporting unit testing over this package supporting unit testing.

This does not stop us from adding unit testing to this package, though, I want to do it with careful consideration. Would you be interested in adding this feature?

@megetron3
Copy link

@JCZuurmond, I appreciate your response. Upon thorough reading, it appears that the new unit-testing feature introduced by dbt-core utilizes YAML syntax. While it may be a viable option for unit testing, it's evident that pytest and Python offer distinct capabilities, which differ from the YAML syntax and the capabilities of dbt.

I believe employing pure Python for testing dbt models could serve as a valuable alternative.

@JCZuurmond
Copy link
Collaborator Author

Hi @megetron3, I agree with you on pure Python testing being a valuable alternative. That is the reason that I created this package.

Currently I don't have the time to implement this feature. I would be open to supporting someone who wants to implement this.

Thanks for your interaction on this issue. It motivates to know if users are interested in this functionality

@JCZuurmond
Copy link
Collaborator Author

The following resource might be helpful with implementing this feature: https://github.com/sqlfluff/sqlfluff/blob/main/plugins/sqlfluff-templater-dbt/sqlfluff_templater_dbt/templater.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants