Skip to content

Commit

Permalink
Include Compiled Node Attributes in run_results.json (#8492)
Browse files Browse the repository at this point in the history
* Add compiled node properties to run_results.json

* Include compiled-node attributes in run_results.json

* Fix typo

* Bump schema version of run_results

* Fix test assertions

* Update expected run_results to reflect new attributes

* Code review changes

* Fix mypy warnings for ManifestLoader.load() (#8443)

* revert python version for docker images (#8445)

* revert python version for docker images

* add comment to not update python version, update changelog

* Bumping version to 1.7.0b1 and generate changelog

* [CT-3013]  Fix parsing of `window_groupings` (#8454)

* Update semantic model parsing tests to check measure non_additive_dimension spec

* Make `window_groupings` default to empty list if not specified on `non_additive_dimension`

* Add changie doc for `window_groupings`  parsing fix

* update `Number` class to handle integer values (#8306)

* add show test for json data

* oh changie my changie

* revert unecessary cahnge to fixture

* keep decimal class for precision methods, but return __int__ value

* jerco updates

* update integer type

* update other tests

* Update .changes/unreleased/Fixes-20230803-093502.yaml

---------

Co-authored-by: Emily Rockman <emily.rockman@dbtlabs.com>

* Improve docker image README (#8212)

* Improve docker image README

- Fix unnecessary/missing newline escapes
- Remove double whitespace between parameters
- 2-space indent for extra lines in image build commands

* Add changelog entry for #8212

* ADAP-814: Refactor prep for MV updates (#8459)

* apply reformatting changes only for #8449
* add logging back to get_create_materialized_view_as_sql
* changie

* swap trigger (#8463)

* update the implementation template (#8466)

* update the implementation template

* add colon

* Split tests into classes (#8474)

* add flaky decorator

* split up tests into classes

* revert update agate for int (#8478)

* updated typing and methods to meet mypy standards (#8485)

* Convert error to conditional warning for unversioned contracted model, fix msg format (#8451)

* first pass, tests need updates

* update proto defn

* fixing tests

* more test fixes

* finish fixing test file

* reformat the message

* formatting messages

* changelog

* add event to unit test

* feedback on message structure

* WIP

* fix up event to take in all fields

* fix test

* Fix ambiguous reference error for duplicate model names across packages with tests (#8488)

* Safely remove external nodes from manifest (#8495)

* [CT-2840] Improved semantic layer protocol satisfaction tests (#8456)

* Test `SemanticModel` satisfies protocol when none of it's `Optionals` are specified

* Add tests ensuring SourceFileMetadata and FileSlice satisfiy DSI protocols

* Add test asserting Defaults obj satisfies protocol

* Add test asserting SemanticModel with optionals specified satisfies protocol

* Split dimension protocol satisfaction tests into with and without optionals

* Simplify DSI Protocol import strategy in protocol satisfaction tests

* Add test asserting DimensionValidtyParams satisfies protocol

* Add test asserting DimensionTypeParams satisfies protocol

* Split entity protocol satisfaction tests into with and without optionals

* Split measure protocol satisfication tests and add measure aggregation params satisficaition test

* Split metric protocol satisfaction test into optional specified an unspecified

Additionally, create where_filter pytest fixture

* Improve protocol satisfaction tests for MetricTypeParams and sub protocols

Specifically we added/improved protocol satisfaction tests for
- MetricTypeParams
- MetricInput
- MetricInputMeasure
- MetricTimeWindow

* Convert to using mashumaro jsonschema with acceptable performance (#8437)

* Regenerate run_results schema after merging in changes from main.

---------

Co-authored-by: Gerda Shank <gerda@dbtlabs.com>
Co-authored-by: Matthew McKnight <91097623+McKnight-42@users.noreply.github.com>
Co-authored-by: Github Build Bot <buildbot@fishtownanalytics.com>
Co-authored-by: Quigley Malcolm <QMalcolm@users.noreply.github.com>
Co-authored-by: dave-connors-3 <73915542+dave-connors-3@users.noreply.github.com>
Co-authored-by: Emily Rockman <emily.rockman@dbtlabs.com>
Co-authored-by: Jaime Martínez Rincón <jaime@jamezrin.name>
Co-authored-by: Mike Alfare <13974384+mikealfare@users.noreply.github.com>
Co-authored-by: Michelle Ark <MichelleArk@users.noreply.github.com>
  • Loading branch information
10 people authored Aug 30, 2023
1 parent f063e4e commit fc1a14a
Show file tree
Hide file tree
Showing 8 changed files with 361 additions and 14 deletions.
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

0 comments on commit fc1a14a

Please sign in to comment.