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

[Bug] --exclude doesn't work when --defer flag is provided #4645

Closed
1 task done
AndrewCanva opened this issue Jan 31, 2022 · 5 comments
Closed
1 task done

[Bug] --exclude doesn't work when --defer flag is provided #4645

AndrewCanva opened this issue Jan 31, 2022 · 5 comments
Labels
bug Something isn't working state Stateful selection (state:modified, defer)

Comments

@AndrewCanva
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

it runs the model in --exclude while it has --defer in the dbt command whether the model is included in --select or not.

Expected Behavior

dbt should exclude the model specified after --exclude whether it is included in --select when --defer is provided. In other words, --exclude overrides --select.

Steps To Reproduce

run a project with dbt run --select state:modified+1 --exclude m --state /tmp/tmp.daf --defer --target tgt

Relevant log output

same as the usual dbt logs but runs the excluded ones

Environment

- OS: ubuntu 20.04
- Python: 3.7.9
- dbt: 1.0.1

What database are you using dbt with?

redshift

Additional Context

No response

@AndrewCanva AndrewCanva added bug Something isn't working triage labels Jan 31, 2022
@AndrewCanva AndrewCanva changed the title [Bug] --exclude doesn't work when --defer is used [Bug] --exclude doesn't work when --defer flag is provided Jan 31, 2022
@jtcohen6 jtcohen6 added state Stateful selection (state:modified, defer) Team:Execution labels Jan 31, 2022
@ChenyuLInx
Copy link
Contributor

Hey @AndrewCanva, thanks for opening this, and sorry for getting back to you late. I looked up the test case and seems like we don't have test coverage of mixing --defer and --exclude together.
To get more information related to this, I have two questions.

  • Does the --exclude work as expected in the case --defer is not provided?
  • are the model/s in --exclude exists in the --state /tmp/tmp.daf?

We probably should exclude those model/s regarding the answer to the questions, but more information is always helpful. Thanks!

@ChenyuLInx ChenyuLInx removed the triage label Feb 11, 2022
@AndrewCanva
Copy link
Author

Hey @AndrewCanva, thanks for opening this, and sorry for getting back to you late. I looked up the test case and seems like we don't have test coverage of mixing --defer and --exclude together. To get more information related to this, I have two questions.

  • Does the --exclude work as expected in the case --defer is not provided?
  • are the model/s in --exclude exists in the --state /tmp/tmp.daf?

We probably should exclude those model/s regarding the answer to the questions, but more information is always helpful. Thanks!

  • --exclude works when `--defer is not provided
  • the model in --exclude is in the --state /tmp/tmp.daf

@jtcohen6
Copy link
Contributor

Hey @AndrewCanva, I haven't been able to reproduce this one!

  1. Create two models, m and mplusone (where the the latter is select * from {{ ref('m') }})
  2. dbt run --target prod
  3. mv target/manifest.json state/
  4. Change m in some way (e.g. add a SQL comment in models/m.sql)
  5. dbt run --select state:modified+1 --exclude m --state state/ --defer --target dev
$ dbt run --select state:modified+1 --exclude m --state state/ --defer --target dev
09:29:54  Running with dbt=1.0.1
09:29:54  Unable to do partial parsing because config vars, config profile, or config target have changed
09:29:54  Found 2 models, 0 tests, 0 snapshots, 0 analyses, 167 macros, 0 operations, 1 seed file, 0 sources, 0 exposures, 0 metrics
09:29:54
09:29:55  Concurrency: 5 threads (target='dev')
09:29:55
09:29:55  1 of 1 START view model dbt_jcohen.mplusone..................................... [RUN]
09:29:55  1 of 1 OK created view model dbt_jcohen.mplusone................................ [CREATE VIEW in 0.06s]
09:29:55
09:29:55  Finished running 1 view model in 0.41s.
09:29:55
09:29:55  Completed successfully
09:29:55
09:29:55  Done. PASS=1 WARN=0 ERROR=0 SKIP=0 TOTAL=1

And, when I check compiled/run SQL in target/ or logs/, I see that mplusone selects from the "prod" version of m

@AndrewCanva
Copy link
Author

AndrewCanva commented Feb 16, 2022

@jtcohen6 ah, I know why it doesn't exclude the model when I run it. it is not related to defer, what I did in a script is

local args="--exclude m"
dbt run --select state:modified+1 "${args}" --state /tmp/tmp.daf --defer --target tgt

when I remove the double quotes, it works fine

local args="--exclude m"
dbt run --select state:modified+1 ${args} --state /tmp/tmp.daf --defer --target tgt

the m isn't in the --select, what's confusing is that dbt ignores the --exclude and takes "${args}" as m.

that's probably because of argparse, I will close this issue if you think it is not a bug.

@jtcohen6
Copy link
Contributor

Ahh, that's a weird one all right. We're talking about refactoring the dbt CLI (#4179, #4475). That work might include moving away from argparse, given some of its shortcomings. I think we should close the issue, and I'm happy to have it linked from there for visibility.

@jtcohen6 jtcohen6 mentioned this issue Feb 17, 2022
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working state Stateful selection (state:modified, defer)
Projects
None yet
Development

No branches or pull requests

3 participants