Skip to content

Commit

Permalink
warn on models not materialized
Browse files Browse the repository at this point in the history
  • Loading branch information
owlas committed Apr 18, 2021
1 parent 0f52768 commit 564e642
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
6 changes: 3 additions & 3 deletions dbt2looker/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def get_manifest(prefix: str):
with open(path, 'r') as f:
raw_manifest = json.load(f)
parser.validate_manifest(raw_manifest) # FIX
logging.info(f'Detected valid manifest at {path}')
logging.debug(f'Detected valid manifest at {path}')
return raw_manifest


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


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


Expand Down
4 changes: 2 additions & 2 deletions dbt2looker/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@

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


Expand Down
10 changes: 10 additions & 0 deletions dbt2looker/parser.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
from typing import Dict, Optional

from . import models
Expand Down Expand Up @@ -44,6 +45,14 @@ def parse_models(raw_manifest: dict, tag=None):
def parse_typed_models(raw_manifest: dict, raw_catalog: dict, tag: Optional[str] = None):
catalog_nodes = parse_catalog_nodes(raw_catalog)
dbt_models = parse_models(raw_manifest, tag=tag)
adapter_type = parse_adapter_type(raw_manifest)

# Check catalog for models
for model in dbt_models:
if model.unique_id not in catalog_nodes:
logging.warning(
f'Model {model.unique_id} not found in catalog. No looker view will be generated. '
f'Check if model has materialized in {adapter_type} at {model.database}.{model.db_schema}.{model.name}')

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

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "dbt2looker"
version = "0.6.1"
version = "0.6.2"
description = "Generate lookml view files from dbt models"
authors = ["oliverlaslett <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit 564e642

Please sign in to comment.