-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Move deferral resolution from merge_from_artifact
to RuntimeRefResolver
#9199
Changes from 6 commits
4f44339
0840647
8b5618e
658999f
6f1ad1e
5513e16
6b63e31
7854bfa
1377431
9db16a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
kind: Under the Hood | ||
body: Split up deferral across parsing (adding 'defer_relation' from state manifest) | ||
and runtime ref resolution" | ||
time: 2024-02-01T00:30:33.573665+01:00 | ||
custom: | ||
Author: jtcohen6 | ||
Issue: "9199" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,12 +57,7 @@ def message(self) -> str: | |
return f"Tracking: {self.user_state}" | ||
|
||
|
||
class MergedFromState(DebugLevel): | ||
def code(self) -> str: | ||
return "A004" | ||
|
||
def message(self) -> str: | ||
return f"Merged {self.num_merged} items from state (sample: {self.sample})" | ||
# Removed A004: MergedFromState | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we're no longer fully overwriting deferred manifest nodes with the stateful manifest's alternative, I didn't see much use in keeping this event around |
||
|
||
|
||
class MissingProfileTarget(InfoLevel): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
from dataclasses import field | ||
import datetime | ||
import os | ||
from pathlib import Path | ||
import traceback | ||
from typing import ( | ||
Dict, | ||
|
@@ -21,6 +22,7 @@ | |
|
||
from dbt.context.query_header import generate_query_header_context | ||
from dbt.contracts.graph.semantic_manifest import SemanticManifest | ||
from dbt.contracts.state import PreviousState | ||
from dbt_common.events.base_types import EventLevel | ||
from dbt_common.exceptions.base import DbtValidationError | ||
import dbt_common.utils | ||
|
@@ -117,6 +119,7 @@ | |
TargetNotFoundError, | ||
AmbiguousAliasError, | ||
InvalidAccessTypeError, | ||
DbtRuntimeError, | ||
scrub_secrets, | ||
) | ||
from dbt.parser.base import Parser | ||
|
@@ -1886,7 +1889,12 @@ def write_manifest(manifest: Manifest, target_path: str, which: Optional[str] = | |
write_semantic_manifest(manifest=manifest, target_path=target_path) | ||
|
||
|
||
def parse_manifest(runtime_config, write_perf_info, write, write_json): | ||
def parse_manifest( | ||
runtime_config: RuntimeConfig, | ||
write_perf_info: bool, | ||
write: bool, | ||
write_json: bool, | ||
) -> Manifest: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before 6b63e31, this was where I was calling |
||
register_adapter(runtime_config, get_mp_context()) | ||
adapter = get_adapter(runtime_config) | ||
adapter.set_macro_context_generator(generate_runtime_macro_context) | ||
|
@@ -1895,6 +1903,26 @@ def parse_manifest(runtime_config, write_perf_info, write, write_json): | |
write_perf_info=write_perf_info, | ||
) | ||
|
||
# If deferral is enabled, add 'defer_relation' attribute to all nodes | ||
flags = get_flags() | ||
if flags.defer: | ||
defer_state_path = flags.defer_state or flags.state | ||
if not defer_state_path: | ||
raise DbtRuntimeError( | ||
"Deferral is enabled and requires a stateful manifest, but none was provided" | ||
) | ||
defer_state = PreviousState( | ||
state_path=defer_state_path, | ||
target_path=Path(runtime_config.target_path), | ||
project_root=Path(runtime_config.project_root), | ||
) | ||
if not defer_state.manifest: | ||
raise DbtRuntimeError( | ||
f'Could not find manifest in deferral state path: "{defer_state_path}"' | ||
) | ||
manifest.merge_from_artifact(defer_state.manifest) | ||
|
||
# If we should (over)write the manifest in the target path, do that now | ||
if write and write_json: | ||
write_manifest(manifest, runtime_config.project_target_path) | ||
pm = plugins.get_plugin_manager(runtime_config.project_name) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirming this is a minor change and safe to make here from a runtime serialization/deserialization perspective 👍 Independent unit tests here: #10066
Additionally, we're not using this field for anything functional in dbt-core's implementation, it was previously just accessed in testing to assert certain behaviour had occurred during deferral.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving minor schema evolution changes