From 19898df6f6db19a18676ade21100064bf68d1b36 Mon Sep 17 00:00:00 2001 From: Yasuhisa Yoshida Date: Mon, 8 Jan 2024 20:02:12 +0900 Subject: [PATCH] Read column metadata from catalog even if source is specified --- src/dbt_osmosis/core/osmosis.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/dbt_osmosis/core/osmosis.py b/src/dbt_osmosis/core/osmosis.py index cadf056..ca12d8a 100644 --- a/src/dbt_osmosis/core/osmosis.py +++ b/src/dbt_osmosis/core/osmosis.py @@ -350,13 +350,15 @@ def get_columns_meta(self, catalog_key: CatalogKey) -> Dict[str, ColumnMetadata] blacklist = self.config.vars.vars.get("dbt-osmosis", {}).get("_blacklist", []) # If we provide a catalog, we read from it if self.catalog: - matching_models: List[CatalogTable] = [ - model_values - for model, model_values in self.catalog.nodes.items() - if model.split(".")[-1] == catalog_key.name + matching_models_or_sources: List[CatalogTable] = [ + model_or_source_values + for model_or_source, model_or_source_values in dict( + **self.catalog.nodes, **self.catalog.sources + ).items() + if model_or_source.split(".")[-1] == catalog_key.name ] - if matching_models: - for col in matching_models[0].columns.values(): + if matching_models_or_sources: + for col in matching_models_or_sources[0].columns.values(): if any(re.match(pattern, col.name) for pattern in blacklist): continue columns[self.column_casing(col.name)] = ColumnMetadata(