Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/external catalog config #1215

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions dbt/adapters/snowflake/catalog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from dbt.adapters.base import BaseRelation
from dbt.adapters.base.catalog import ExternalCatalogIntegration


class SnowflakeExternalCatalogIntegration(ExternalCatalogIntegration):

def relation_exists(self, relation: BaseRelation) -> bool:
response, result = self._connection_manager.execute(f"DESCRIBE ICEBERG TABLE {relation.render()}")
if result and result.rows:
return True
return False

def _exists(self) -> bool:
if not self._exists:
response, result = self._connection_manager.execute(
f"DESCRIBE CATALOG INTEGRATION {self.external_catalog.name}")
if result and result.rows:
self._exists = True
else:
self._exists = False
return self._exists

def refresh_relation(self, relation: BaseRelation) -> None:
self._connection_manager.execute(f"ALTER ICEBERG TABLE {relation.render()} REFRESH")

def create_relation(self, relation: BaseRelation) -> None:
self._connection_manager.execute(f"CREATE ICEBERG TABLE {relation.render()}"
f"EXTERNAL_VOLUME '{self.external_catalog.configuration.external_volume.name}'"
f"CATALOG='{self.external_catalog.name}'")
2 changes: 2 additions & 0 deletions dbt/adapters/snowflake/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from dbt.adapters.base.impl import AdapterConfig, ConstraintSupport
from dbt.adapters.base.meta import available
from dbt.adapters.capability import CapabilityDict, CapabilitySupport, Support, Capability
from dbt.adapters.snowflake.catalog import SnowflakeExternalCatalogIntegration
from dbt.adapters.sql import SQLAdapter
from dbt.adapters.sql.impl import (
LIST_SCHEMAS_MACRO_NAME,
Expand Down Expand Up @@ -58,6 +59,7 @@ class SnowflakeAdapter(SQLAdapter):
Relation = SnowflakeRelation
Column = SnowflakeColumn
ConnectionManager = SnowflakeConnectionManager
ExternalCatalogIntegration = SnowflakeExternalCatalogIntegration

AdapterSpecificConfigs = SnowflakeConfig

Expand Down
Loading