From 98095f4eb34676f8d04604832edb430a71d25e2a Mon Sep 17 00:00:00 2001 From: Colin Date: Fri, 13 Dec 2024 11:55:24 -0800 Subject: [PATCH] add catalog_name as key --- dbt/adapters/base/impl.py | 11 +++++++++-- dbt/adapters/clients/catalogs.py | 8 ++++---- dbt/adapters/contracts/catalog.py | 4 ++-- dbt/adapters/protocol.py | 1 + 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/dbt/adapters/base/impl.py b/dbt/adapters/base/impl.py index 4972a3bc..cb5fd08c 100644 --- a/dbt/adapters/base/impl.py +++ b/dbt/adapters/base/impl.py @@ -299,8 +299,15 @@ def __init__(self, config, mp_context: SpawnContext) -> None: def add_catalog_integrations(self, catalog_integrations: Optional[List[CatalogIntegrationConfig]]) -> None: if catalog_integrations: for integration_config in catalog_integrations: - integration = self.CatalogIntegrations[integration_config.type](integration_config) - catalogs_client.add_catalog(integration) + catalog_type = integration_config.catalog_type + if catalog_type not in self.CatalogIntegrations: + raise DbtValidationError(f"{catalog_type} is not supported!!! - <3 Colin") + integration = self.CatalogIntegrations[catalog_type](integration_config) + catalogs_client.add_catalog(integration, integration_config.catalog_name) + + @available + def get_catalog_integration(self, integration_name) -> CatalogIntegration: + return catalogs_client.get_catalog(integration_name) ### # Methods to set / access a macro resolver ### diff --git a/dbt/adapters/clients/catalogs.py b/dbt/adapters/clients/catalogs.py index d5cbe65a..4b466a94 100644 --- a/dbt/adapters/clients/catalogs.py +++ b/dbt/adapters/clients/catalogs.py @@ -9,8 +9,8 @@ def get(self, name: str) -> CatalogIntegration: def integrations(self) -> dict[str, CatalogIntegration]: return self.integrations - def add_integration(self, integration: CatalogIntegration): - self.integrations[integration.name] = integration + def add_integration(self, integration: CatalogIntegration, catalog_name: str): + self.integrations[catalog_name] = integration _CATALOG_CLIENT = CatalogIntegrations() @@ -20,5 +20,5 @@ def get_catalog(integration_name: str) -> CatalogIntegration: return _CATALOG_CLIENT.get(integration_name) -def add_catalog(integration: CatalogIntegration): - _CATALOG_CLIENT.add_integration(integration) +def add_catalog(integration: CatalogIntegration, catalog_name: str): + _CATALOG_CLIENT.add_integration(integration, catalog_name) diff --git a/dbt/adapters/contracts/catalog.py b/dbt/adapters/contracts/catalog.py index 31da0420..08a52f65 100644 --- a/dbt/adapters/contracts/catalog.py +++ b/dbt/adapters/contracts/catalog.py @@ -19,9 +19,9 @@ class CatalogIntegration(abc.ABC): specific integrations in the adapters. """ - name: str + integration_name: str table_format: TableFormat - type: CatalogIntegrationType + integration_type: CatalogIntegrationType external_volume: Optional[str] = None namespace: Optional[str] = None diff --git a/dbt/adapters/protocol.py b/dbt/adapters/protocol.py index ce991736..b70120bb 100644 --- a/dbt/adapters/protocol.py +++ b/dbt/adapters/protocol.py @@ -47,6 +47,7 @@ class CatalogIntegrationProtocol(Protocol): class CatalogIntegrationConfig(Protocol): + catalog_name: str integration_name: str table_format: str catalog_type: str