From 922c75344bdef91e27b1c771555bbd70f9abd4e6 Mon Sep 17 00:00:00 2001 From: Gerda Shank Date: Wed, 12 Apr 2023 10:56:10 -0400 Subject: [PATCH] Add access, has_group, contract_enforced, versioned to run_model (#7309) --- .../Under the Hood-20230411-114149.yaml | 6 +++++ core/dbt/task/run.py | 22 +++++++++++++++---- core/dbt/tracking.py | 4 ++-- 3 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 .changes/unreleased/Under the Hood-20230411-114149.yaml diff --git a/.changes/unreleased/Under the Hood-20230411-114149.yaml b/.changes/unreleased/Under the Hood-20230411-114149.yaml new file mode 100644 index 00000000000..2728468afc8 --- /dev/null +++ b/.changes/unreleased/Under the Hood-20230411-114149.yaml @@ -0,0 +1,6 @@ +kind: Under the Hood +body: Track data about group, access, contract, version usage +time: 2023-04-11T11:41:49.84883-04:00 +custom: + Author: gshank + Issue: 7170 7171 diff --git a/core/dbt/task/run.py b/core/dbt/task/run.py index 213627a4651..4b1cea04727 100644 --- a/core/dbt/task/run.py +++ b/core/dbt/task/run.py @@ -108,6 +108,16 @@ def track_model_run(index, num_nodes, run_model_result): if tracking.active_user is None: raise DbtInternalError("cannot track model run with no active user") invocation_id = get_invocation_id() + node = run_model_result.node + has_group = True if hasattr(node, "group") and node.group else False + if node.resource_type == NodeType.Model: + access = node.access.value if node.access is not None else None + contract_enforced = node.contract.enforced + versioned = True if node.version else False + else: + access = None + contract_enforced = False + versioned = False tracking.track_model_run( { "invocation_id": invocation_id, @@ -117,11 +127,15 @@ def track_model_run(index, num_nodes, run_model_result): "run_status": str(run_model_result.status).upper(), "run_skipped": run_model_result.status == NodeStatus.Skipped, "run_error": run_model_result.status == NodeStatus.Error, - "model_materialization": run_model_result.node.get_materialization(), - "model_id": utils.get_hash(run_model_result.node), - "hashed_contents": utils.get_hashed_contents(run_model_result.node), + "model_materialization": node.get_materialization(), + "model_id": utils.get_hash(node), + "hashed_contents": utils.get_hashed_contents(node), "timing": [t.to_dict(omit_none=True) for t in run_model_result.timing], - "language": str(run_model_result.node.language), + "language": str(node.language), + "has_group": has_group, + "contract_enforced": contract_enforced, + "access": access, + "versioned": versioned, } ) diff --git a/core/dbt/tracking.py b/core/dbt/tracking.py index 594ec952c30..f306d9f0b00 100644 --- a/core/dbt/tracking.py +++ b/core/dbt/tracking.py @@ -42,10 +42,10 @@ PARTIAL_PARSER = "iglu:com.dbt/partial_parser/jsonschema/1-0-1" PLATFORM_SPEC = "iglu:com.dbt/platform/jsonschema/1-0-0" PROJECT_ID_SPEC = "iglu:com.dbt/project_id/jsonschema/1-0-1" -RESOURCE_COUNTS = "iglu:com.dbt/resource_counts/jsonschema/1-0-0" +RESOURCE_COUNTS = "iglu:com.dbt/resource_counts/jsonschema/1-0-1" RPC_REQUEST_SPEC = "iglu:com.dbt/rpc_request/jsonschema/1-0-1" RUNNABLE_TIMING = "iglu:com.dbt/runnable/jsonschema/1-0-0" -RUN_MODEL_SPEC = "iglu:com.dbt/run_model/jsonschema/1-0-2" +RUN_MODEL_SPEC = "iglu:com.dbt/run_model/jsonschema/1-0-3" class TimeoutEmitter(Emitter):