diff --git a/src/dbt_osmosis/vendored/dbt_core_interface/project.py b/src/dbt_osmosis/vendored/dbt_core_interface/project.py index b604e08..11af478 100644 --- a/src/dbt_osmosis/vendored/dbt_core_interface/project.py +++ b/src/dbt_osmosis/vendored/dbt_core_interface/project.py @@ -435,6 +435,13 @@ def initialize_adapter(self) -> None: self.adapter = self.get_adapter_cls()(self.config, get_mp_context()) + try: + from dbt.context.providers import generate_runtime_macro_context + + self.adapter.set_macro_context_generator(generate_runtime_macro_context) + except Exception: + pass + @property def adapter(self) -> "BaseAdapter": """dbt-core adapter with TTL and automatic reinstantiation. diff --git a/tests/test_yaml_manager.py b/tests/test_yaml_manager.py index f7d9180..7d97e45 100644 --- a/tests/test_yaml_manager.py +++ b/tests/test_yaml_manager.py @@ -1,4 +1,7 @@ +from pathlib import Path + import pytest +from dbt.contracts.results import CatalogKey from dbt_osmosis.core.osmosis import DbtYamlManager @@ -50,3 +53,28 @@ def test_commit_project_restructure_to_disk(yaml_manager: DbtYamlManager): def test_propagate_documentation_downstream(yaml_manager: DbtYamlManager): yaml_manager.propagate_documentation_downstream() + + +def _customer_column_types(yaml_manager: DbtYamlManager) -> dict[str, str]: + node = next(n for n in yaml_manager.manifest.nodes.values() if n.name == "customers") + assert node + + catalog_key = yaml_manager.get_catalog_key(node) + columns = yaml_manager.get_columns_meta(catalog_key) + assert columns + + column_types = dict({name: meta.type for name, meta in columns.items()}) + assert column_types + return column_types + + +def test_get_columns_meta(yaml_manager: DbtYamlManager): + assert _customer_column_types(yaml_manager) == { + "customer_id": "INTEGER", + "customer_lifetime_value": "DOUBLE", + "first_name": "character varying(256)", + "first_order": "DATE", + "last_name": "character varying(256)", + "most_recent_order": "DATE", + "number_of_orders": "BIGINT", + }