-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update to add catalog integration client
- Loading branch information
1 parent
41bc4a4
commit 8386b5f
Showing
11 changed files
with
118 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from dbt.adapters.contracts.catalog import CatalogIntegration | ||
|
||
|
||
class CatalogIntegrations: | ||
def get(self, name: str) -> CatalogIntegration: | ||
return self.integrations[name] | ||
|
||
@property | ||
def integrations(self) -> dict[str, CatalogIntegration]: | ||
return self.integrations | ||
|
||
def add_integration(self, integration: CatalogIntegration): | ||
self.integrations[integration.name] = integration | ||
|
||
|
||
_CATALOG_CLIENT = CatalogIntegrations() | ||
|
||
|
||
def get_catalog(integration_name: str) -> CatalogIntegration: | ||
return _CATALOG_CLIENT.get(integration_name) | ||
|
||
|
||
def add_catalog(integration: CatalogIntegration): | ||
_CATALOG_CLIENT.add_integration(integration) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import abc | ||
from enum import Enum | ||
from typing import Optional | ||
|
||
from dbt.adapters.protocol import CatalogIntegrationConfig | ||
from dbt.adapters.relation_configs.formats import TableFormat | ||
|
||
|
||
class CatalogIntegrationType(Enum): | ||
iceberg_rest = 'iceberg_rest' | ||
glue = 'glue' | ||
unity = 'unity' | ||
|
||
|
||
class CatalogIntegration(abc.ABC): | ||
""" | ||
An external catalog integration is a connection to an external catalog that can be used to | ||
interact with the catalog. This class is an abstract base class that should be subclassed by | ||
specific integrations in the adapters. | ||
""" | ||
name: str | ||
table_format: TableFormat | ||
type: CatalogIntegrationType | ||
external_volume: Optional[str] = None | ||
namespace: Optional[str] = None | ||
|
||
def __init__( | ||
self, integration_config: CatalogIntegrationConfig | ||
): | ||
self.name = integration_config.name | ||
self.table_format = TableFormat(integration_config.table_format) | ||
self.type = CatalogIntegrationType(integration_config.type) | ||
self.external_volume = integration_config.external_volume | ||
self.namespace = integration_config.namespace | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from dbt_common.dataclass_schema import StrEnum # doesn't exist in standard library until py3.11 | ||
from typing_extensions import Self | ||
|
||
|
||
class TableFormat(StrEnum): | ||
""" | ||
Some platforms may refer to this 'Object' or 'File Format'. | ||
Data practitioners and interfaces refer to this as 'Table Format's, hence the term's use here. | ||
""" | ||
|
||
DEFAULT = "default" | ||
ICEBERG = "iceberg" | ||
|
||
@classmethod | ||
def default(cls) -> Self: | ||
return cls("default") | ||
|
||
def __str__(self): | ||
return self.value |