[CT-3290] [Bug] Using --inline should exclude selectors.yml defaults
Is this a new bug in dbt-core?
- [X] I believe this is a new bug in dbt-core
- [X] I have searched the existing issues, and I could not find an existing issue for this bug
Current Behavior
If a default selector is defined in selectors.yml, that selector will still applied when the --inline flag is used with show or compile.
See slack thread for additional context
Expected Behavior
- When we do
dbt show --inline ...we expect default selectors to be ignored - make
--inlineand--selectmutually exclusive fordbt show(do this at the click level)
Steps To Reproduce
- Add a default selector to a local dbt project's
selectors.yml:
selectors:
- name: test_selector
description: Exclude everything
default: true
definition:
method: package
value: "foo"
- Using dbt-core 1.5+ (for support for --inline), run
dbt compile --inline 'select 1' - Observe that inline compile does not execute
Relevant log output
(dbt-core-1.6-local) racheldaniel:jaffle_shop/ (master✗) $ dbt compile --inline 'select 1' [14:22:20]
19:22:26 Running with dbt=1.6.6
19:22:26 Registered adapter: postgres=1.6.6
19:22:26 Found 10 models, 3 seeds, 1 operation, 18 tests, 0 sources, 0 exposures, 0 metrics, 661 macros, 1 group, 0 semantic models
19:22:26 Using default selector test_selector
19:22:26
19:22:26 Nothing to do. Try checking your model configs and model specification args
Environment
- OS: MacOS Ventura 13.5.2
- Python: 3.8.10
- dbt: 1.6.6
Which database adapter are you using with dbt?
postgres
Additional Context
See https://github.com/dbt-labs/dbt-core/issues/9269#issuecomment-2125718609 for several specific cases where --inline doesn't work as desired.
From @jtcohen6:
This does feel like unexpected behavior / a bug to me. Using
--inlineis mutually exclusive with using--select, so it would make sense to me that it should fully disregard all selection syntax.I'd hope it could be a (relatively) quick fix here.
Notes from estimation:
- this could be related to how default selection works - maybe instead of piping this through we would just add a selection criteria when
--inline
This error also surfaces if you pass in both --select and --inline to dbt show when they shouldn't be:
❯ dbt show --select stg_orders
18:00:47 Running with dbt=1.7.9
18:00:47 Registered adapter: duckdb=1.7.3
18:00:47 Found 5 models, 3 seeds, 20 tests, 0 sources, 0 exposures, 0 metrics, 772 macros, 0 groups, 0 semantic models
18:00:47
18:00:47 Concurrency: 24 threads (target='dev')
18:00:47
18:00:48 Previewing node 'stg_orders':
| order_id | customer_id | order_date | status |
| -------- | ----------- | ---------- | --------- |
| 1 | 1 | 2018-01-01 | returned |
| 2 | 3 | 2018-01-02 | completed |
| 3 | 94 | 2018-01-04 | completed |
| 4 | 50 | 2018-01-05 | completed |
| 5 | 64 | 2018-01-05 | completed |
❯ dbt show --inline 'select 1 as foo'
18:01:15 Running with dbt=1.7.9
18:01:16 Registered adapter: duckdb=1.7.3
18:01:16 Found 5 models, 3 seeds, 20 tests, 0 sources, 0 exposures, 0 metrics, 772 macros, 0 groups, 0 semantic models
18:01:16
18:01:16 Concurrency: 24 threads (target='dev')
18:01:16
18:01:16 Previewing inline node:
| foo |
| --- |
| 1 |
❯ dbt show --select stg_orders --inline 'select 1 as foo'
18:00:58 Running with dbt=1.7.9
18:00:59 Registered adapter: duckdb=1.7.3
18:00:59 Found 5 models, 3 seeds, 20 tests, 0 sources, 0 exposures, 0 metrics, 772 macros, 0 groups, 0 semantic models
18:00:59
18:00:59 Nothing to do. Try checking your model configs and model specification args
Another related bug https://github.com/dbt-labs/dbt-core/issues/9269 -> dbt core should disregard selection / selectors altogether when running in inline mode during "interactive compile" and dbt show.