-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[CT-2381] [Bug] state:modified+
selection doesn't behave as expected for dbt build
when tests are modified
#7289
Comments
state:modified+
selection doesn't behave as expected for dbt build
state:modified+
selection doesn't behave as expected for dbt build
Thanks for reporting this @b-luu ! Excellent write-up -- I was able to reproduce what you described:
Full details of the reprex I used.
select * from {{ ref("my_model_2") }}
where 0=1
Prime the pump: dbt build Alter the test and save the state: echo "-- $(date +%T)" >> tests/singular/my_test.sql
PREVIOUS_TARGET=~/previous_target
mkdir -p $PREVIOUS_TARGET
cp -r target/* $PREVIOUS_TARGET Try a few different commands: dbt list --select state:modified+ --state $PREVIOUS_TARGET
dbt run --select state:modified+ --state $PREVIOUS_TARGET
dbt test --select state:modified+ --state $PREVIOUS_TARGET
dbt build --select state:modified+ --state $PREVIOUS_TARGET |
Intuitively, I'd look into the order of execution between BuildTask.get_node_selector and BuildTask.compile_manifest. I've gotta admit I've stopped looking/lost myself in the CompilerProtocol because it lacks the |
In its current implementation, the I think it will be tricky to resolve this issue, given that's our current approach to achieving the |
state:modified+
selection doesn't behave as expected for dbt build
state:modified+
selection doesn't behave as expected for dbt build
when tests are modified
Thanks @jtcohen6 for the confirmation that it is indeed the expected behavior. True the solution would be tricky, but here it's preventing me from using Anyway, as a quicker solution, do you think we could add a note on this caveat in the documentation? Or would it add more confusion than it would solve? Actually, looking more deeply into it, I think the definitive solution isn't too complicated:
I could give it a go if you want? |
@b-luu You're more than welcome to give a go! Conceptually, that approach makes sense to me. It would be worth a quick check to see if the added attribute and filtering step results in a meaningful slowdown at scale |
Is this a new bug in dbt-core?
Current Behavior
dbt build --select state:modified+
should behave like the other commands.Specifically the following scenario doesn't yield the expected selection:
PREVIOUS_TARGET=~/previous_target
cp -r $DBT_PROJECT_DIR/target/* $PREVIOUS_TARGET
dbt list --select state:modified+ --state $PREVIOUS_TARGET
=> correctly lists only the changed tests (nothing downstream)dbt build --select state:modified+ --state $PREVIOUS_TARGET
=> runs the changed tests but also ALL downstream nodes!!dbt run --select state:modified+ --state $PREVIOUS_TARGET
does as expected: "Nothing to run"dbt test --select state:modified+ --state $PREVIOUS_TARGET
as well: only runs the changed tests.Expected Behavior
dbt build --select state:modified+
should NOT run models downstream from modified tests (if only the tests have been modified, not the tests' model(s) )Steps To Reproduce
PREVIOUS_TARGET=~/previous_target
cp -r $DBT_PROJECT_DIR/target/* $PREVIOUS_TARGET
dbt list --select state:modified+ --state $PREVIOUS_TARGET
=> correctly lists only the changed tests (nothing downstream)dbt build --select state:modified+ --state $PREVIOUS_TARGET
=> runs the changed tests but also ALL downstream nodes!!dbt run --select state:modified+ --state $PREVIOUS_TARGET
does as expected: "Nothing to run"dbt test --select state:modified+ --state $PREVIOUS_TARGET
as well: only runs the changed tests.Relevant log output
No response
Environment
Which database adapter are you using with dbt?
snowflake
Additional Context
No response
The text was updated successfully, but these errors were encountered: