Skip to content

Commit 0168c62

Browse files
authored
Allow partial parsing when default target and profile names are used (#12498)
* use resolved profile and target name * fix mock_project for ut
1 parent de47edf commit 0168c62

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: Fixes
2+
body: Use resolved profile and target names to allow partial parsing for default profile and target
3+
time: 2026-02-16T23:08:17.820862+05:30
4+
custom:
5+
Author: akshatha-code71 ash2shukla
6+
Issue: "7612"

core/dbt/parser/manifest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,8 +1034,8 @@ def build_manifest_state_check(self):
10341034
"\x00".join(
10351035
[
10361036
stringified_cli_vars,
1037-
getattr(config.args, "profile", "") or "",
1038-
getattr(config.args, "target", "") or "",
1037+
config.profile_name,
1038+
config.target_name,
10391039
__version__,
10401040
]
10411041
)
@@ -1044,8 +1044,8 @@ def build_manifest_state_check(self):
10441044
StateCheckVarsHash(
10451045
checksum=vars_hash.checksum,
10461046
vars=scrub_secrets(stringified_cli_vars, secret_vars),
1047-
profile=config.args.profile,
1048-
target=config.args.target,
1047+
profile=config.profile_name,
1048+
target=config.target_name,
10491049
version=__version__,
10501050
)
10511051
)

tests/functional/partial_parsing/test_partial_parsing.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import dbt.flags as flags
1010
from dbt.contracts.files import ParseFileType
1111
from dbt.contracts.results import TestStatus
12+
from dbt.events.types import UnableToPartialParse
1213
from dbt.exceptions import CompilationError
1314
from dbt.plugins.manifest import ModelNodeArgs, PluginNodes
1415
from dbt.tests.fixtures.project import write_project_files
@@ -20,6 +21,7 @@
2021
run_dbt_and_capture,
2122
write_file,
2223
)
24+
from dbt_common.events.event_catcher import EventCatcher
2325
from tests.functional.partial_parsing.fixtures import (
2426
custom_schema_tests1_sql,
2527
custom_schema_tests2_sql,
@@ -996,3 +998,17 @@ def test_profile_change(self, project, dbt_profile_data):
996998
write_file(yaml.safe_dump(dbt_profile_data), project.profiles_dir, "profiles.yml")
997999
_, stdout = run_dbt_and_capture(["parse"])
9981000
assert "Unable to do partial parsing" not in stdout
1001+
1002+
1003+
class TestExplicitDefaultProfileAndTarget:
1004+
def test_explicit_default_profile_allows_partial_parse(self, project):
1005+
event_catcher = EventCatcher(UnableToPartialParse)
1006+
run_dbt(["parse"])
1007+
run_dbt(["parse", "--profile", "test"], callbacks=[event_catcher.catch])
1008+
assert len(event_catcher.caught_events) == 0
1009+
1010+
def test_explicit_default_target_allows_partial_parse(self, project):
1011+
event_catcher = EventCatcher(UnableToPartialParse)
1012+
run_dbt(["parse"])
1013+
run_dbt(["parse", "--target", "default"], callbacks=[event_catcher.catch])
1014+
assert len(event_catcher.caught_events) == 0

tests/unit/utils/project.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ def mock_project():
8282
mock_project = MagicMock(RuntimeConfig)
8383
mock_project.cli_vars = {}
8484
mock_project.args = MagicMock()
85+
mock_project.profile_name = "test"
86+
mock_project.target_name = "test"
8587
mock_project.args.profile = "test"
8688
mock_project.args.target = "test"
8789
mock_project.project_env_vars = {}

0 commit comments

Comments
 (0)