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

update run results docs to include compiled node attributes from dbt-core PR #8492 #4125

Closed
FishtownBuildBot opened this issue Sep 25, 2023 · 4 comments · Fixed by #4974
Closed
Assignees
Labels
content Improvements or additions to content dbt Core The changes proposed in this issue relate to dbt Core improvement Use this when an area of the docs needs improvement as it's currently unclear

Comments

@FishtownBuildBot
Copy link

FishtownBuildBot commented Sep 25, 2023

dbt-labs/dbt-core#8492

Page to update

Content to update

In particular, update this section:

Each entry in results is a Result object, with one difference: Instead of including the entire node object, only the unique_id is included

Also: "Current schema: v4" should be updated to v5 per here.

What changed?

dbt-labs/dbt-core#8492 added three new attributes related to "applied" state to run_results.json (to complement unique_id):

  • compiled - boolean whether the node has been compiled or not (False after parsing, but True after compiling)
  • compiled_code - rendered string of the code that was compiled (empty after parsing, but full string after compiling)
  • relation_name - the fully-qualified name of the object that was (or will be) created/updated within the database

Any additional information about the "logical" state of nodes should continue to be looked up in the full node object in manifest.json via the unique_id.

Examples

Compile model

Create this model:
models/my_model.sql

select {{ dbt.current_timestamp() }} as created_at

Compile the model:

dbt compile -s my_model

Look at a pretty-printed snippet from run_results.json:

    {
      "status": "success",
      "timing": [
        {
          "name": "compile",
          "started_at": "2023-10-12T16:35:28.510434Z",
          "completed_at": "2023-10-12T16:35:28.519086Z"
        },
        {
          "name": "execute",
          "started_at": "2023-10-12T16:35:28.521633Z",
          "completed_at": "2023-10-12T16:35:28.521641Z"
        }
      ],
      "thread_id": "Thread-2",
      "execution_time": 0.0408780574798584,
      "adapter_response": {},
      "message": null,
      "failures": null,
      "unique_id": "model.my_project.my_model",
      "compiled": true,
      "compiled_code": "select now() as created_at",
      "relation_name": "\"postgres\".\"dbt_dbeatty\".\"my_model\""
    }

Run generic tests

Use the new store_failures_as config (#4246) to store failures for one test in the database, but not for the other:

models/_models.yml

models:
  - name: my_model
    columns:
      - name: created_at
        tests:
          - not_null:
              config:
                store_failures_as: view
          - unique:
              config:
                store_failures_as: ephemeral

Run the built-in unique test (and store the failures as a table):

dbt test -s my_model

Look at a pretty-printed snippet from run_results.json:

  "results": [
    {
      "status": "pass",
      "timing": [
        {
          "name": "compile",
          "started_at": "2023-10-12T17:20:51.279437Z",
          "completed_at": "2023-10-12T17:20:51.317312Z"
        },
        {
          "name": "execute",
          "started_at": "2023-10-12T17:20:51.319812Z",
          "completed_at": "2023-10-12T17:20:51.441967Z"
        }
      ],
      "thread_id": "Thread-2",
      "execution_time": 0.1807551383972168,
      "adapter_response": {
        "_message": "SELECT 1",
        "code": "SELECT",
        "rows_affected": 1
      },
      "message": null,
      "failures": 0,
      "unique_id": "test.my_project.unique_my_model_created_at.a9276afbbb",
      "compiled": true,
      "compiled_code": "\n    \n    \n\nselect\n    created_at as unique_field,\n    count(*) as n_records\n\nfrom \"postgres\".\"dbt_dbeatty\".\"my_model\"\nwhere created_at is not null\ngroup by created_at\nhaving count(*) > 1\n\n\n",
      "relation_name": null
    },
    {
      "status": "pass",
      "timing": [
        {
          "name": "compile",
          "started_at": "2023-10-12T17:20:51.274049Z",
          "completed_at": "2023-10-12T17:20:51.295237Z"
        },
        {
          "name": "execute",
          "started_at": "2023-10-12T17:20:51.296361Z",
          "completed_at": "2023-10-12T17:20:51.491327Z"
        }
      ],
      "thread_id": "Thread-1",
      "execution_time": 0.22345590591430664,
      "adapter_response": {
        "_message": "SELECT 1",
        "code": "SELECT",
        "rows_affected": 1
      },
      "message": null,
      "failures": 0,
      "unique_id": "test.my_project.not_null_my_model_created_at.9b412fbcc7",
      "compiled": true,
      "compiled_code": "\n    \n    \n\n\n\nselect *\nfrom \"postgres\".\"dbt_dbeatty\".\"my_model\"\nwhere created_at is null\n\n\n",
      "relation_name": "\"postgres\".\"dbt_dbeatty_dbt_test__audit\".\"not_null_my_model_created_at\""
    }
  ],

cc: @peterallenwebb

@runleonarun runleonarun added content Improvements or additions to content improvement Use this when an area of the docs needs improvement as it's currently unclear dbt Core The changes proposed in this issue relate to dbt Core labels Sep 25, 2023
@graciegoheen graciegoheen changed the title Docs Changes Needed from dbt-core PR #8492 update run results docs to include compiled node attributes from dbt-core PR #8492 Sep 25, 2023
@matthewshaver matthewshaver self-assigned this Sep 27, 2023
@graciegoheen
Copy link
Collaborator

Looks like the schema version has been bumped to 5

@runleonarun runleonarun removed this from the dbt Core v1.7 Documentation milestone Oct 13, 2023
@jtcohen6 jtcohen6 added this to the dbt Core v1.8 Documentation milestone Feb 7, 2024
@graciegoheen
Copy link
Collaborator

graciegoheen commented Feb 7, 2024

@jtcohen6 is this for 1.7 or 1.8? I see it was removed from the 1.7 milestone and added to 1.8, but i believe this change was made for 1.7

@runleonarun
Copy link
Collaborator

@matthewshaver (apologies for commenting on all your issues) I think we should aim to have all issues addressed by Friday 2/23 to give reviewers and authors enough time. Let me know if you need support!

matthewshaver added a commit that referenced this issue Feb 29, 2024
## What are you changing in this pull request and why?

Adding new attributes to `run_results.json`.

Closes #4125

## Checklist

Uncomment when publishing docs for a prerelease version of dbt:
- [x] Add versioning components, as described in [Versioning
Docs](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/single-sourcing-content.md#versioning-entire-pages)
- [x] Add a note to the prerelease version [Migration
Guide](https://github.com/dbt-labs/docs.getdbt.com/tree/current/website/docs/docs/dbt-versions/core-upgrade)

- [x] Review the [Content style
guide](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/content-style-guide.md)
so my content adheres to these guidelines.
- [x] For [docs
versioning](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/single-sourcing-content.md#about-versioning),
review how to [version a whole
page](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/single-sourcing-content.md#adding-a-new-version)
and [version a block of
content](https://github.com/dbt-labs/docs.getdbt.com/blob/current/contributing/single-sourcing-content.md#versioning-blocks-of-content).
@jtcohen6
Copy link
Collaborator

This was included in v1.7! Sorry for the confusion. I think it was removed from the milestone (not sure why); my motivation in re-adding a milestone was to make sure this got shipped, but it wasn't actually part of v1.8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content Improvements or additions to content dbt Core The changes proposed in this issue relate to dbt Core improvement Use this when an area of the docs needs improvement as it's currently unclear
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants