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

Add relation info to node_info in logging #7304

Merged
merged 4 commits into from
Apr 10, 2023

Conversation

jtcohen6
Copy link
Contributor

@jtcohen6 jtcohen6 commented Apr 10, 2023

resolves #6724

Description

Add to node_info dictionary another nested message/dictionary for node_relation, including:

  • database
  • schema
  • alias
  • relation_name (with include + quote policies applied)
{
  "data": {
    "description": "sql view model dbt_jcohen.my_model",
    "index": 1,
    "node_info": {
      "materialized": "view",
      "meta": {},
      "node_finished_at": "",
      "node_name": "my_model",
      "node_path": "my_model.sql",
      "node_relation": {
        "alias": "my_model",
        "database": "jerco",
        "relation_name": "\"jerco\".\"dbt_jcohen\".\"my_model\"",
        "schema": "dbt_jcohen"
      },
      "node_started_at": "2023-04-10T19:21:43.288413",
      "node_status": "started",
      "resource_type": "model",
      "unique_id": "model.test.my_model"
    },
    "total": 1
  },
  "info": {
    "category": "",
    "code": "Q011",
    "extra": {},
    "invocation_id": "a0234d14-04ef-4eec-94bc-f409100f92e4",
    "level": "info",
    "msg": "1 of 1 START sql view model dbt_jcohen.my_model ................................ [RUN]",
    "name": "LogStartLine",
    "pid": 8576,
    "thread": "Thread-1",
    "ts": "2023-04-10T19:21:43.289185Z"
  }
}

Checklist

@jtcohen6 jtcohen6 requested review from a team as code owners April 10, 2023 15:49
@cla-bot cla-bot bot added the cla:yes label Apr 10, 2023
Comment on lines 40 to 43
string node_database = 10;
string node_schema = 11;
string node_alias = 12;
string node_relation_name = 13;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gshank @peterallenwebb Does either of you have a strong feeling around whether:

  • We should prefix these with node_ (like the other ones)
  • We should nest these as fields in a relation_info dictionary, instead of having them all as top-level fields (strings)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tbh I kind of wish none of the other fields started with "node_". It feels duplicative. But that's moot, I guess :)

Nested or not I don't have strong feelings.

I wonder if we need to make these "optional" though. Did you test this with a node with database = None? The version of betterproto we were using before didn't have "optional", and google protobuf behaves a bit differently anyway. I'm not quite sure what it will do with a None passed in. Changing the event in test_events.py should tell.

Copy link
Contributor

@gshank gshank Apr 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about node_relation: { database='...', schema='', alias='', name: '...' }?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I pass in None for database, it comes back as "". I'll add a test for this. I think this is how proto works, right? All fields are technically optional, and there's no way to really distinguish between empty string ("") and missing (None), short of adding another boolean field has_database

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an "optional" thing, but it's not exactly the same as in Python, so I suspect we'd still get an empty string. betterproto was trying to be more python-like, so I think they implemented it in a somewhat more pythonic way, but I haven't done any optional fields with google protobuf yet...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went with

node_relation: {database='...', schema='...', alias='...', relation_name: '...'}

To match the nomenclature in the existing top-level node attributes, and because name by itself feels closer to alias/identifier

Comment on lines 124 to 127
"node_database": "some_database",
"node_schema": "some_schema",
"node_alias": "some_alias",
"node_relation_name": "some.relation.name",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated this test. Not sure if we would want to update these functional tests as well, to ensure the field values are actually present:

@jtcohen6 jtcohen6 requested a review from gshank April 10, 2023 19:24
@jtcohen6 jtcohen6 merged commit ef2ba39 into main Apr 10, 2023
@jtcohen6 jtcohen6 deleted the jerco/add-node-relation-info-logging branch April 10, 2023 20:16
emmyoop pushed a commit that referenced this pull request Apr 11, 2023
* Add db, schema, alias, rel_name to node_info

* Add changelog entry

* Default to None

* Nested node_relation message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CT-1902] [Feature] Add relation_name to the node_info dictionary
2 participants