Skip to content

Commit

Permalink
add catalog_name as key
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-rogers-dbt committed Dec 13, 2024
1 parent 4822c2e commit 98095f4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
11 changes: 9 additions & 2 deletions dbt/adapters/base/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
###
Expand Down
8 changes: 4 additions & 4 deletions dbt/adapters/clients/catalogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
4 changes: 2 additions & 2 deletions dbt/adapters/contracts/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions dbt/adapters/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class CatalogIntegrationProtocol(Protocol):


class CatalogIntegrationConfig(Protocol):
catalog_name: str
integration_name: str
table_format: str
catalog_type: str
Expand Down

0 comments on commit 98095f4

Please sign in to comment.