Skip to content

Commit 564e642

Browse files
committed
warn on models not materialized
1 parent 0f52768 commit 564e642

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

dbt2looker/cli.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def get_manifest(prefix: str):
2828
with open(path, 'r') as f:
2929
raw_manifest = json.load(f)
3030
parser.validate_manifest(raw_manifest) # FIX
31-
logging.info(f'Detected valid manifest at {path}')
31+
logging.debug(f'Detected valid manifest at {path}')
3232
return raw_manifest
3333

3434

@@ -42,7 +42,7 @@ def get_catalog(prefix: str):
4242
with open(path, 'r') as f:
4343
raw_catalog = json.load(f)
4444
parser.validate_catalog(raw_catalog)
45-
logging.info(f'Detected valid catalog at {path}')
45+
logging.debug(f'Detected valid catalog at {path}')
4646
return raw_catalog
4747

4848

@@ -55,7 +55,7 @@ def get_dbt_project_config(prefix: str):
5555
raise SystemExit('Failed') from e
5656
with open(path, 'r') as f:
5757
project_config = yaml.load(f, Loader=Loader)
58-
logging.info(f'Detected valid dbt config at {path}')
58+
logging.debug(f'Detected valid dbt config at {path}')
5959
return project_config
6060

6161

dbt2looker/generator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@
110110

111111
def map_adapter_type_to_looker(adapter_type: models.SupportedDbtAdapters, column_type: str):
112112
looker_type = LOOKER_DTYPE_MAP[adapter_type].get(column_type)
113-
if looker_type is None:
114-
logging.warn(f'Column type {column_type} not supported for conversion from {adapter_type} to looker. No dimension will be created.')
113+
if (column_type is not None) and (looker_type is None):
114+
logging.warning(f'Column type {column_type} not supported for conversion from {adapter_type} to looker. No dimension will be created.')
115115
return looker_type
116116

117117

dbt2looker/parser.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import logging
12
from typing import Dict, Optional
23

34
from . import models
@@ -44,6 +45,14 @@ def parse_models(raw_manifest: dict, tag=None):
4445
def parse_typed_models(raw_manifest: dict, raw_catalog: dict, tag: Optional[str] = None):
4546
catalog_nodes = parse_catalog_nodes(raw_catalog)
4647
dbt_models = parse_models(raw_manifest, tag=tag)
48+
adapter_type = parse_adapter_type(raw_manifest)
49+
50+
# Check catalog for models
51+
for model in dbt_models:
52+
if model.unique_id not in catalog_nodes:
53+
logging.warning(
54+
f'Model {model.unique_id} not found in catalog. No looker view will be generated. '
55+
f'Check if model has materialized in {adapter_type} at {model.database}.{model.db_schema}.{model.name}')
4756

4857
# Update dbt models with data types from catalog
4958
dbt_typed_models = [
@@ -54,6 +63,7 @@ def parse_typed_models(raw_manifest: dict, raw_catalog: dict, tag: Optional[str]
5463
for column in model.columns.values()
5564
}})
5665
for model in dbt_models
66+
if model.unique_id in catalog_nodes
5767
]
5868
return dbt_typed_models
5969

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "dbt2looker"
3-
version = "0.6.1"
3+
version = "0.6.2"
44
description = "Generate lookml view files from dbt models"
55
authors = ["oliverlaslett <[email protected]>"]
66
license = "MIT"

0 commit comments

Comments
 (0)