Skip to content

Commit

Permalink
merge from main
Browse files Browse the repository at this point in the history
  • Loading branch information
aranke committed Sep 27, 2024
2 parents d808204 + 5e3d418 commit 9accf08
Show file tree
Hide file tree
Showing 31 changed files with 601 additions and 576 deletions.
2 changes: 1 addition & 1 deletion .changes/unreleased/Features-20240925-165002.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ body: Enable `retry` support for microbatch models
time: 2024-09-25T16:50:02.105069-05:00
custom:
Author: QMalcolm MichelleArk
Issue: "10624"
Issue: 10715 10729
6 changes: 6 additions & 0 deletions .changes/unreleased/Features-20240926-151057.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Features
body: Adds validations for custom_granularities to ensure unique naming.
time: 2024-09-26T15:10:57.907694-07:00
custom:
Author: courtneyholcomb
Issue: "9265"
6 changes: 6 additions & 0 deletions .changes/unreleased/Features-20240926-153210.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Features
body: Ensure microbatch models respect `full_refresh` model config
time: 2024-09-26T15:32:10.202789-05:00
custom:
Author: QMalcolm
Issue: "10785"
6 changes: 0 additions & 6 deletions .changes/unreleased/Fixes-20240923-190758.yaml

This file was deleted.

6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20240926-101220.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Attempt to skip saved query processing when no semantic manifest changes
time: 2024-09-26T10:12:20.193453-04:00
custom:
Author: gshank
Issue: "10563"
6 changes: 6 additions & 0 deletions .changes/unreleased/Under the Hood-20240926-143448.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Under the Hood
body: Add group metadata info to LogModelResult and LogTestResult
time: 2024-09-26T14:34:48.334703+01:00
custom:
Author: aranke
Issue: "10775"
13 changes: 9 additions & 4 deletions core/dbt/config/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,14 @@ def _parse_versions(versions: Union[List[str], str]) -> List[VersionSpecifier]:
return [VersionSpecifier.from_version_string(v) for v in versions]


def _all_source_paths(*args: List[str]) -> List[str]:
paths = chain(*args)
def _all_source_paths(
model_paths: List[str],
seed_paths: List[str],
snapshot_paths: List[str],
analysis_paths: List[str],
macro_paths: List[str],
) -> List[str]:
paths = chain(model_paths, seed_paths, snapshot_paths, analysis_paths, macro_paths)
# Strip trailing slashes since the path is the same even though the name is not
stripped_paths = map(lambda s: s.rstrip("/"), paths)
return list(set(stripped_paths))
Expand Down Expand Up @@ -403,7 +409,7 @@ def create_project(self, rendered: RenderComponents) -> "Project":
snapshot_paths: List[str] = value_or(cfg.snapshot_paths, ["snapshots"])

all_source_paths: List[str] = _all_source_paths(
model_paths, seed_paths, snapshot_paths, analysis_paths, macro_paths, test_paths
model_paths, seed_paths, snapshot_paths, analysis_paths, macro_paths
)

docs_paths: List[str] = value_or(cfg.docs_paths, all_source_paths)
Expand Down Expand Up @@ -646,7 +652,6 @@ def all_source_paths(self) -> List[str]:
self.snapshot_paths,
self.analysis_paths,
self.macro_paths,
self.test_paths,
)

@property
Expand Down
50 changes: 1 addition & 49 deletions core/dbt/contracts/graph/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
SavedQuery,
SeedNode,
SemanticModel,
SingularTestNode,
SourceDefinition,
UnitTestDefinition,
UnitTestFileFixture,
Expand Down Expand Up @@ -90,7 +89,7 @@
RefName = str


def find_unique_id_for_package(storage, key, package: Optional[PackageName]) -> Optional[UniqueID]:
def find_unique_id_for_package(storage, key, package: Optional[PackageName]):
if key not in storage:
return None

Expand Down Expand Up @@ -471,43 +470,6 @@ class AnalysisLookup(RefableLookup):
_versioned_types: ClassVar[set] = set()


class SingularTestLookup(dbtClassMixin):
def __init__(self, manifest: "Manifest") -> None:
self.storage: Dict[str, Dict[PackageName, UniqueID]] = {}
self.populate(manifest)

def get_unique_id(self, search_name, package: Optional[PackageName]) -> Optional[UniqueID]:
return find_unique_id_for_package(self.storage, search_name, package)

def find(
self, search_name, package: Optional[PackageName], manifest: "Manifest"
) -> Optional[SingularTestNode]:
unique_id = self.get_unique_id(search_name, package)
if unique_id is not None:
return self.perform_lookup(unique_id, manifest)
return None

def add_singular_test(self, source: SingularTestNode) -> None:
if source.search_name not in self.storage:
self.storage[source.search_name] = {}

self.storage[source.search_name][source.package_name] = source.unique_id

def populate(self, manifest: "Manifest") -> None:
for node in manifest.nodes.values():
if isinstance(node, SingularTestNode):
self.add_singular_test(node)

def perform_lookup(self, unique_id: UniqueID, manifest: "Manifest") -> SingularTestNode:
if unique_id not in manifest.nodes:
raise dbt_common.exceptions.DbtInternalError(
f"Singular test {unique_id} found in cache but not found in manifest"
)
node = manifest.nodes[unique_id]
assert isinstance(node, SingularTestNode)
return node


def _packages_to_search(
current_project: str,
node_package: str,
Expand Down Expand Up @@ -907,9 +869,6 @@ class Manifest(MacroMethods, dbtClassMixin):
_analysis_lookup: Optional[AnalysisLookup] = field(
default=None, metadata={"serialize": lambda x: None, "deserialize": lambda x: None}
)
_singular_test_lookup: Optional[SingularTestLookup] = field(
default=None, metadata={"serialize": lambda x: None, "deserialize": lambda x: None}
)
_parsing_info: ParsingInfo = field(
default_factory=ParsingInfo,
metadata={"serialize": lambda x: None, "deserialize": lambda x: None},
Expand Down Expand Up @@ -1305,12 +1264,6 @@ def analysis_lookup(self) -> AnalysisLookup:
self._analysis_lookup = AnalysisLookup(self)
return self._analysis_lookup

@property
def singular_test_lookup(self) -> SingularTestLookup:
if self._singular_test_lookup is None:
self._singular_test_lookup = SingularTestLookup(self)
return self._singular_test_lookup

@property
def external_node_unique_ids(self):
return [node.unique_id for node in self.nodes.values() if node.is_external_node]
Expand Down Expand Up @@ -1755,7 +1708,6 @@ def __reduce_ex__(self, protocol):
self._semantic_model_by_measure_lookup,
self._disabled_lookup,
self._analysis_lookup,
self._singular_test_lookup,
)
return self.__class__, args

Expand Down
8 changes: 2 additions & 6 deletions core/dbt/contracts/graph/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1473,7 +1473,7 @@ def to_logging_dict(self) -> Dict[str, Union[str, Dict[str, str]]]:
return {
"name": self.name,
"package_name": self.package_name,
"owner": self.owner.to_dict(),
"owner": self.owner.to_dict(omit_none=True),
}


Expand Down Expand Up @@ -1642,11 +1642,6 @@ class ParsedMacroPatch(ParsedPatch):
arguments: List[MacroArgument] = field(default_factory=list)


@dataclass
class ParsedSingularTestPatch(ParsedPatch):
pass


# ====================================
# Node unions/categories
# ====================================
Expand Down Expand Up @@ -1697,6 +1692,7 @@ class ParsedSingularTestPatch(ParsedPatch):

TestNode = Union[SingularTestNode, GenericTestNode]

SemanticManifestNode = Union[SavedQuery, SemanticModel, Metric]

RESOURCE_CLASS_TO_NODE_CLASS: Dict[Type[BaseResource], Type[BaseNode]] = {
node_class.resource_class(): node_class
Expand Down
5 changes: 0 additions & 5 deletions core/dbt/contracts/graph/unparsed.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,6 @@ class UnparsedAnalysisUpdate(HasConfig, HasColumnDocs, HasColumnProps, HasYamlMe
access: Optional[str] = None


@dataclass
class UnparsedSingularTestUpdate(HasConfig, HasColumnProps, HasYamlMetadata):
pass


@dataclass
class UnparsedNodeUpdate(HasConfig, HasColumnTests, HasColumnAndTestProps, HasYamlMetadata):
quote_columns: Optional[bool] = None
Expand Down
17 changes: 10 additions & 7 deletions core/dbt/events/core_types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,12 @@ message SQLRunnerExceptionMsg {
SQLRunnerException data = 2;
}

message Group {
string name = 1;
string package_name = 3;
map<string, string> owner = 7;
}

// Q007
message LogTestResult {
NodeInfo node_info = 1;
Expand All @@ -1280,6 +1286,8 @@ message LogTestResult {
int32 num_models = 5;
float execution_time = 6;
int32 num_failures = 7;
Group group = 8;
string attached_node = 9;
}

message LogTestResultMsg {
Expand Down Expand Up @@ -1312,6 +1320,7 @@ message LogModelResult {
int32 index = 4;
int32 total = 5;
float execution_time = 6;
Group group = 7;
}

message LogModelResultMsg {
Expand Down Expand Up @@ -1373,7 +1382,7 @@ message LogFreshnessResultMsg {
LogFreshnessResult data = 2;
}

// Q018
// Q019
message LogNodeNoOpResult {
NodeInfo node_info = 1;
string description = 2;
Expand Down Expand Up @@ -1820,12 +1829,6 @@ message ServingDocsExitInfoMsg {
ServingDocsExitInfo data = 2;
}

message Group {
string name = 1;
string package_name = 3;
map<string, string> owner = 7;
}

// Z021
message RunResultWarning {
string resource_type = 1;
Expand Down
574 changes: 287 additions & 287 deletions core/dbt/events/core_types_pb2.py

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions core/dbt/parser/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
UnparsedMacroUpdate,
UnparsedModelUpdate,
UnparsedNodeUpdate,
UnparsedSingularTestUpdate,
)
from dbt.exceptions import ParsingError
from dbt.node_types import NodeType
Expand Down Expand Up @@ -59,7 +58,6 @@ def trimmed(inp: str) -> str:
UnpatchedSourceDefinition,
UnparsedExposure,
UnparsedModelUpdate,
UnparsedSingularTestUpdate,
)


Expand Down
18 changes: 18 additions & 0 deletions core/dbt/parser/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
ResultNode,
SavedQuery,
SeedNode,
SemanticManifestNode,
SemanticModel,
SourceDefinition,
)
Expand Down Expand Up @@ -1141,6 +1142,23 @@ def process_metrics(self, config: RuntimeConfig):

def process_saved_queries(self, config: RuntimeConfig):
"""Processes SavedQuery nodes to populate their `depends_on`."""
# Note: This will also capture various nodes which have been re-parsed
# because they refer to some other changed node, so there will be
# false positives. Ideally we would compare actual changes.
semantic_manifest_changed = False
semantic_manifest_nodes: chain[SemanticManifestNode] = chain(
self.manifest.saved_queries.values(),
self.manifest.semantic_models.values(),
self.manifest.metrics.values(),
)
for node in semantic_manifest_nodes:
# Check if this node has been modified in this parsing run
if node.created_at > self.started_at:
semantic_manifest_changed = True
break # as soon as we run into one changed node we can stop
if semantic_manifest_changed is False:
return

current_project = config.project_name
for saved_query in self.manifest.saved_queries.values():
# TODO:
Expand Down
Loading

0 comments on commit 9accf08

Please sign in to comment.