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

Capture dbt meta field #779

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions metaphor/dbt/artifact_parser.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
from copy import deepcopy
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union

Expand Down Expand Up @@ -37,6 +38,7 @@
DbtMacroArgument,
DbtMaterialization,
DbtMaterializationType,
DbtMetadataItem,
DbtMetric,
DbtModel,
DbtTest,
Expand Down Expand Up @@ -741,6 +743,13 @@ def get_dataset():
if len(tag_names) > 0:
get_dataset().tag_assignment = TagAssignment(tag_names=tag_names)

# Capture the whole "meta" field as key-value pairs
if len(meta) > 0:
virtual_view.dbt_model.meta = [
DbtMetadataItem(key=key, value=json.dumps(value))
for key, value in meta.items()
]

def _parse_node_materialization(
self, node: VIRTUAL_VIEW_NODE_TYPE, dbt_model: DbtModel
) -> None:
Expand Down
45 changes: 33 additions & 12 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "metaphor-connectors"
version = "0.13.121"
version = "0.13.122"
license = "Apache-2.0"
description = "A collection of Python-based 'connectors' that extract metadata from various sources to ingest into the Metaphor app."
authors = ["Metaphor <[email protected]>"]
Expand Down Expand Up @@ -36,7 +36,7 @@ jsonschema = "^4.18.6"
lkml = { version = "^1.3.1", optional = true }
llama-hub = {version = "0.0.67", optional = true }
looker-sdk = { version = "^23.6.0", optional = true }
metaphor-models = "0.30.16"
metaphor-models = "0.30.17"
more-itertools = { version = "^10.1.0", optional = true }
msal = { version = "^1.20.0", optional = true }
msgraph-beta-sdk = { version = "1.0.0", optional = true }
Expand Down
10 changes: 10 additions & 0 deletions tests/dbt/data/trial_v4/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,16 @@
"targetDataset": "DATASET~95F35FDE6E7C3F9E556D701A1B00CA23",
"type": "VIEW"
},
"meta": [
{
"key": "owner",
"value": "\"[email protected]\""
},
{
"key": "pii",
"value": "true"
}
],
"packageName": "trial",
"rawSql": "/*\n Welcome to your first dbt model!\n Did you know that you can also configure models directly within SQL files?\n This will override configurations stated in dbt_project.yml\n\n Try changing \"table\" to \"view\" below\n*/\n\nwith source_data as (\n\n select 1 as id\n union all\n select null as id\n\n)\n\nselect *\nfrom source_data\n\n/*\n Uncomment the line below to remove records with null `id` values\n*/\n\n-- where id is not null",
"tests": [
Expand Down
10 changes: 10 additions & 0 deletions tests/dbt/data/trial_v5/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,16 @@
"targetDataset": "DATASET~95F35FDE6E7C3F9E556D701A1B00CA23",
"type": "VIEW"
},
"meta": [
{
"key": "owner",
"value": "\"[email protected]\""
},
{
"key": "pii",
"value": "true"
}
],
"packageName": "trial",
"rawSql": "/*\n Welcome to your first dbt model!\n Did you know that you can also configure models directly within SQL files?\n This will override configurations stated in dbt_project.yml\n\n Try changing \"table\" to \"view\" below\n*/\n\nwith source_data as (\n\n select 1 as id\n union all\n select null as id\n\n)\n\nselect *\nfrom source_data\n\n/*\n Uncomment the line below to remove records with null `id` values\n*/\n\n-- where id is not null",
"tests": [
Expand Down
10 changes: 10 additions & 0 deletions tests/dbt/data/trial_v6/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,16 @@
"targetDataset": "DATASET~95F35FDE6E7C3F9E556D701A1B00CA23",
"type": "VIEW"
},
"meta": [
{
"key": "owner",
"value": "\"[email protected]\""
},
{
"key": "pii",
"value": "true"
}
],
"packageName": "trial",
"rawSql": "/*\n Welcome to your first dbt model!\n Did you know that you can also configure models directly within SQL files?\n This will override configurations stated in dbt_project.yml\n\n Try changing \"table\" to \"view\" below\n*/\n\nwith source_data as (\n\n select 1 as id\n union all\n select null as id\n\n)\n\nselect *\nfrom source_data\n\n/*\n Uncomment the line below to remove records with null `id` values\n*/\n\n-- where id is not null",
"tests": [
Expand Down
10 changes: 10 additions & 0 deletions tests/dbt/data/trial_v7/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,16 @@
"targetDataset": "DATASET~95F35FDE6E7C3F9E556D701A1B00CA23",
"type": "VIEW"
},
"meta": [
{
"key": "owner",
"value": "\"[email protected]\""
},
{
"key": "pii",
"value": "true"
}
],
"packageName": "trial",
"rawSql": "/*\n Welcome to your first dbt model!\n Did you know that you can also configure models directly within SQL files?\n This will override configurations stated in dbt_project.yml\n\n Try changing \"table\" to \"view\" below\n*/\n\nwith source_data as (\n\n select 1 as id\n union all\n select null as id\n\n)\n\nselect *\nfrom source_data\n\n/*\n Uncomment the line below to remove records with null `id` values\n*/\n\n-- where id is not null",
"tests": [
Expand Down
10 changes: 10 additions & 0 deletions tests/dbt/data/trial_v8/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,16 @@
"targetDataset": "DATASET~95F35FDE6E7C3F9E556D701A1B00CA23",
"type": "VIEW"
},
"meta": [
{
"key": "owner",
"value": "\"[email protected]\""
},
{
"key": "pii",
"value": "true"
}
],
"packageName": "trial",
"rawSql": "/*\n Welcome to your first dbt model!\n Did you know that you can also configure models directly within SQL files?\n This will override configurations stated in dbt_project.yml\n\n Try changing \"table\" to \"view\" below\n*/\n\nwith source_data as (\n\n select 1 as id\n union all\n select null as id\n\n)\n\nselect *\nfrom source_data\n\n/*\n Uncomment the line below to remove records with null `id` values\n*/\n\n-- where id is not null",
"tests": [
Expand Down
10 changes: 10 additions & 0 deletions tests/dbt/data/trial_v9/expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,16 @@
"targetDataset": "DATASET~95F35FDE6E7C3F9E556D701A1B00CA23",
"type": "VIEW"
},
"meta": [
{
"key": "owner",
"value": "\"[email protected]\""
},
{
"key": "pii",
"value": "true"
}
],
"packageName": "trial",
"rawSql": "/*\n Welcome to your first dbt model!\n Did you know that you can also configure models directly within SQL files?\n This will override configurations stated in dbt_project.yml\n\n Try changing \"table\" to \"view\" below\n*/\n\nwith source_data as (\n\n select 1 as id\n union all\n select null as id\n\n)\n\nselect *\nfrom source_data\n\n/*\n Uncomment the line below to remove records with null `id` values\n*/\n\n-- where id is not null",
"tests": [
Expand Down
Loading