godatadriven / pytest-dbt-core Goto Github PK
View Code? Open in Web Editor NEWPytest plugin for dbt core
Home Page: https://pytest-dbt-core.readthedocs.io/en/latest/
License: Apache License 2.0
Pytest plugin for dbt core
Home Page: https://pytest-dbt-core.readthedocs.io/en/latest/
License: Apache License 2.0
dbt adds the 'this' somehow in the is_incremental macro:
https://github.com/dbt-labs/dbt-core/blob/main/core/dbt/include/global_project/macros/materializations/models/incremental/is_incremental.sql
is_incremental.sql
{% macro is_incremental() %}
{#-- do not run introspective queries in parsing #}
{% if not execute %}
{{ return(False) }}
I would like to test the following macro that uses 'is_incremental' and 'this' argument
{% macro get_table_max_id(where_clause = '', id_column = '"id"') %}
{% if is_incremental() %}
{% set max_id_query %}
select coalesce(max({{ id_column }}), 0) from {{ this }}
{{ where_clause }}
{% endset %}
{% set max_id_res = run_query(max_id_query) %}
{%endif%}
{{ return(max_id) }}
{% endmacro %}
following error:
def raise_compiler_error(msg, node=None) -> NoReturn:
raise CompilationException(msg, node)
E dbt.exceptions.CompilationException: Compilation Error in macro is_incremental (macros/materializations/models/incremental/is_incremental.sql)
E 'this' is undefined
E
E > in macro get_table_max_id (macros/unioner.sql)
E > called by macro test_table_max_id (macros/test_macro.sql)
E > called by macro is_incremental (macros/materializations/models/incremental/is_incremental.sql)
All dbt users since is_incremental is very popular
No response
No response
Add more examples to the docs, maybe as a separate page.
NA
Users, the examples should help them get started quickly
yes
No response
Test against Python 3.11
N.A.
Those who use Python 3.11
yes
No response
The docs contain example tests, we should verify that those pass.
Note:
NA
Me, as package maintainer I want to make sure that the examples in docs are accurate
yes
No response
Extend the tox matrix to test for all minor versions of dbt.
N.A.
Testing stability
No response
No response
Lots of my colleagues uses the DBT Cloud IDE. It lowers the entry barrier for anyone not experience with IDEs, git, etc. With that in mind, I would like them to also have the possibility to write unit tests and run the tests in that environment.
Running tests in CI pipeline, but this creates a very slow feedback loop.
Any DBT developer using DBT Cloud IDE
Yes
I have now clue if this is even remotely possible. Does that DBT cloud runtime include Pytest? Is it possible to create a DBT package which pulls in additional packages from pypi?
The CI runs some tox environments multiple times.
N.A.
Devs
yes
No response
Add a flag to set the target.
Do not set a specific target, use the default target
Everyone who does not want to use the default target
yes
Add flag to plugin:
# src/pytest_dbt_core/plugin.py
...
def pytest_addoption(...):
....
parser.addoption(
"--dbt-target",
help="Which target to load for the given profile",
type="string",
)
And test in the example project in tests/
We are working on a use case where the macro internally maps to some classes. To perform the testing efficiently, classes need to be mocked instead of class functionality being used.
With macros directly pytest mocking cannot be used, some examples need to be added to showcase how to mock in the case of macros.
No response
No response
No response
No response
hi @JCZuurmond ! dbt-core 1.6 released last week; do you plan on supporting it sometime soon?
if not, we're thinking about submitting a PR to support it since we use your library and we'd like to keep dbt up to date. just checking in before we do duplicative work.
FYI @ybressler
yes
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:
ref
and source
. How do we handle this? Could we for example mock them? If so, can we share mocks across tests.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.
Those who want to test models, not just macros
Yes
Add a quickstart guide to the docs
NA
Package users, the quickstart should help them get started quickly.
yes
No response
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.