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

Include Compiled Node Attributes in run_results.json #8492

Merged
merged 26 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6448cc1
Add compiled node properties to run_results.json
peterallenwebb Aug 21, 2023
516f50f
Include compiled-node attributes in run_results.json
peterallenwebb Aug 24, 2023
1afd3aa
Fix typo
peterallenwebb Aug 25, 2023
fd510e4
Bump schema version of run_results
peterallenwebb Aug 29, 2023
8f69ca7
Fix test assertions
peterallenwebb Aug 29, 2023
9736a89
Update expected run_results to reflect new attributes
peterallenwebb Aug 29, 2023
57808b4
Code review changes
peterallenwebb Aug 29, 2023
59012dd
Fix mypy warnings for ManifestLoader.load() (#8443)
gshank Aug 17, 2023
79f6dc8
revert python version for docker images (#8445)
McKnight-42 Aug 17, 2023
debfb3c
Bumping version to 1.7.0b1 and generate changelog
FishtownBuildBot Aug 17, 2023
3769acd
[CT-3013] Fix parsing of `window_groupings` (#8454)
QMalcolm Aug 18, 2023
0d6a813
update `Number` class to handle integer values (#8306)
dave-connors-3 Aug 18, 2023
45c8d6d
Improve docker image README (#8212)
jamezrin Aug 18, 2023
7bb45d5
ADAP-814: Refactor prep for MV updates (#8459)
mikealfare Aug 21, 2023
1313739
swap trigger (#8463)
emmyoop Aug 21, 2023
9b02109
update the implementation template (#8466)
emmyoop Aug 22, 2023
9f64fa8
Split tests into classes (#8474)
emmyoop Aug 23, 2023
1aff3b4
revert update agate for int (#8478)
MichelleArk Aug 23, 2023
a890087
updated typing and methods to meet mypy standards (#8485)
mikealfare Aug 24, 2023
6f92b08
Convert error to conditional warning for unversioned contracted model…
emmyoop Aug 25, 2023
49e1843
Fix ambiguous reference error for duplicate model names across packag…
MichelleArk Aug 25, 2023
a51f383
Safely remove external nodes from manifest (#8495)
MichelleArk Aug 28, 2023
22216a3
[CT-2840] Improved semantic layer protocol satisfaction tests (#8456)
QMalcolm Aug 29, 2023
9097548
Convert to using mashumaro jsonschema with acceptable performance (#8…
gshank Aug 30, 2023
8f4b440
Merge remote-tracking branch 'origin/main' into paw/copiled-code-in-r…
peterallenwebb Aug 30, 2023
bda7219
Regenerate run_results schema after merging in changes from main.
peterallenwebb Aug 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/unreleased/Features-20230821-103357.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Features
body: Add node attributes related to compilation to run_results.json
time: 2023-08-21T10:33:57.200883-04:00
custom:
Author: peterallenwebb
Issue: "7519"
13 changes: 11 additions & 2 deletions core/dbt/contracts/results.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import threading

from dbt.contracts.graph.unparsed import FreshnessThreshold
from dbt.contracts.graph.nodes import SourceDefinition, ResultNode
from dbt.contracts.graph.nodes import CompiledNode, SourceDefinition, ResultNode
from dbt.contracts.util import (
BaseArtifactMetadata,
ArtifactMixin,
Expand Down Expand Up @@ -203,9 +203,15 @@ class RunResultsMetadata(BaseArtifactMetadata):
@dataclass
class RunResultOutput(BaseResult):
unique_id: str
compiled: Optional[bool]
compiled_code: Optional[str]
relation_name: Optional[str]


def process_run_result(result: RunResult) -> RunResultOutput:

compiled = isinstance(result.node, CompiledNode)

return RunResultOutput(
unique_id=result.node.unique_id,
status=result.status,
Expand All @@ -215,6 +221,9 @@ def process_run_result(result: RunResult) -> RunResultOutput:
message=result.message,
adapter_response=result.adapter_response,
failures=result.failures,
compiled=result.node.compiled if compiled else None, # type:ignore
compiled_code=result.node.compiled_code if compiled else None, # type:ignore
relation_name=result.node.relation_name if compiled else None, # type:ignore
)


Expand All @@ -237,7 +246,7 @@ def write(self, path: str):


@dataclass
@schema_version("run-results", 4)
@schema_version("run-results", 5)
class RunResultsArtifact(ExecutionResult, ArtifactMixin):
results: Sequence[RunResultOutput]
args: Dict[str, Any] = field(default_factory=dict)
Expand Down
12 changes: 11 additions & 1 deletion core/dbt/tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import json
import warnings
from datetime import datetime
from typing import Dict, List, Optional
from typing import Any, Dict, List, Optional
from contextlib import contextmanager
from dbt.adapters.factory import Adapter

Expand Down Expand Up @@ -160,6 +160,16 @@ def get_manifest(project_root) -> Optional[Manifest]:
return None


# Used in test cases to get the run_results.json file.
def get_run_results(project_root) -> Any:
path = os.path.join(project_root, "target", "run_results.json")
if os.path.exists(path):
with open(path) as run_result_text:
return json.load(run_result_text)
else:
return None


# Used in tests to copy a file, usually from a data directory to the project directory
def copy_file(src_path, src, dest_path, dest) -> None:
# dest is a list, so that we can provide nested directories, like 'models' etc.
Expand Down
229 changes: 229 additions & 0 deletions schemas/dbt/run-results/v5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
{
"$ref": "#/$defs/RunResultsArtifact",
"$defs": {
"BaseArtifactMetadata": {
"type": "object",
"title": "BaseArtifactMetadata",
"properties": {
"dbt_schema_version": {
"type": "string"
},
"dbt_version": {
"type": "string",
"default": "1.7.0b1"
},
"generated_at": {
"type": "string"
},
"invocation_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
]
},
"env": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"propertyNames": {
"type": "string"
}
}
},
"additionalProperties": false,
"required": [
"dbt_schema_version"
]
},
"TimingInfo": {
"type": "object",
"title": "TimingInfo",
"properties": {
"name": {
"type": "string"
},
"started_at": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null
},
"completed_at": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null
}
},
"additionalProperties": false,
"required": [
"name"
]
},
"RunResultOutput": {
"type": "object",
"title": "RunResultOutput",
"properties": {
"status": {
"anyOf": [
{
"enum": [
"success",
"error",
"skipped"
]
},
{
"enum": [
"pass",
"error",
"fail",
"warn",
"skipped"
]
},
{
"enum": [
"pass",
"warn",
"error",
"runtime error"
]
}
]
},
"timing": {
"type": "array",
"items": {
"$ref": "#/$defs/TimingInfo"
}
},
"thread_id": {
"type": "string"
},
"execution_time": {
"type": "number"
},
"adapter_response": {
"type": "object",
"propertyNames": {
"type": "string"
}
},
"message": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
]
},
"failures": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
]
},
"unique_id": {
"type": "string"
},
"compiled": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
]
},
"compiled_code": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
]
},
"relation_name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
]
}
},
"additionalProperties": false,
"required": [
"status",
"timing",
"thread_id",
"execution_time",
"adapter_response",
"message",
"failures",
"unique_id",
"compiled",
"compiled_code",
"relation_name"
]
},
"RunResultsArtifact": {
"type": "object",
"title": "RunResultsArtifact",
"properties": {
"metadata": {
"$ref": "#/$defs/BaseArtifactMetadata"
},
"results": {
"type": "array",
"items": {
"$ref": "#/$defs/RunResultOutput"
}
},
"elapsed_time": {
"type": "number"
},
"args": {
"type": "object",
"propertyNames": {
"type": "string"
}
}
},
"additionalProperties": false,
"required": [
"metadata",
"results",
"elapsed_time"
]
}
},
"$id": "https://schemas.getdbt.com/dbt/run-results/v5.json"
}
Loading