Skip to content

Commit

Permalink
Merge pull request #164 from kokorin/fix/another-dbt-1.8-compatibilit…
Browse files Browse the repository at this point in the history
…y-issue

Fix: missing macro context generator in adapter
  • Loading branch information
z3z1ma authored Jun 17, 2024
2 parents fa940b5 + a29002b commit 6b17010
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/dbt_osmosis/vendored/dbt_core_interface/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
28 changes: 28 additions & 0 deletions tests/test_yaml_manager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from pathlib import Path

import pytest
from dbt.contracts.results import CatalogKey

from dbt_osmosis.core.osmosis import DbtYamlManager

Expand Down Expand Up @@ -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",
}

0 comments on commit 6b17010

Please sign in to comment.