Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9f99a99

Browse files
committedMar 28, 2025··
resolve rebasing artifacts
1 parent 4a13aba commit 9f99a99

File tree

5 files changed

+42
-44
lines changed

5 files changed

+42
-44
lines changed
 

‎dbt-adapters/.changes/unreleased/Features-20250219-093958.yaml

-6
This file was deleted.

‎dbt-snowflake/src/dbt/adapters/snowflake/catalogs/__init__.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,19 @@
88
from dbt.adapters.snowflake.catalogs._iceberg_rest import (
99
IcebergAWSGlueCatalogIntegration,
1010
IcebergRESTCatalogIntegration,
11+
IcebergRESTCatalogRelation,
1112
)
1213

1314

14-
SnowflakeCatalogRelation = Union[IcebergManagedCatalogRelation]
15-
SnowflakeCatalogIntegration = Union[IcebergManagedCatalogIntegration]
15+
SnowflakeCatalogRelation = Union[
16+
IcebergManagedCatalogRelation,
17+
IcebergRESTCatalogRelation,
18+
]
19+
SnowflakeCatalogIntegration = Union[
20+
IcebergAWSGlueCatalogIntegration,
21+
IcebergManagedCatalogIntegration,
22+
IcebergRESTCatalogIntegration,
23+
]
1624

1725

1826
CATALOG_INTEGRATIONS = [

‎dbt-snowflake/src/dbt/adapters/snowflake/catalogs/_iceberg_rest.py

+30-29
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
from dataclasses import dataclass, field
2-
from typing import Any, Dict, Optional, TYPE_CHECKING
3-
from typing_extensions import Self
2+
from typing import Any, Dict, Optional
43

54
from dbt.adapters.catalogs import CatalogIntegration, CatalogIntegrationConfig
6-
from dbt.adapters.relation_configs import RelationResults
7-
from dbt_common.exceptions import DbtInternalError
5+
from dbt.adapters.contracts.relation import RelationConfig
86

9-
if TYPE_CHECKING:
10-
import agate
7+
8+
@dataclass
9+
class IcebergRESTCatalogRelation:
10+
base_location: str
11+
catalog_name: str
12+
external_volume: Optional[str] = None
13+
table_format: str = "iceberg"
1114

1215

1316
@dataclass
@@ -60,36 +63,34 @@ class IcebergRESTCatalogIntegration(CatalogIntegration):
6063
- must be False
6164
"""
6265

66+
catalog_type: str = "iceberg_rest"
6367
table_format: str = "iceberg"
6468
allows_writes: bool = False
6569

6670
def __init__(self, config: CatalogIntegrationConfig) -> None:
6771
super().__init__(config)
68-
if self.catalog_type not in ["iceberg_rest", "aws_glue"]:
69-
raise DbtInternalError(
70-
f"Attempting to create IcebergREST catalog integration for catalog {self.name} with catalog type {config.catalog_type}."
71-
)
72-
if self.table_format and self.table_format != "iceberg":
73-
raise DbtInternalError(
74-
f"Unsupported table format for catalog {self.name}: {self.table_format}. Expected `iceberg` or unset."
75-
)
76-
7772
if config.adapter_properties:
7873
self.namespace = config.adapter_properties.get("namespace")
7974

80-
@classmethod
81-
def from_relation_results(cls, relation_results: RelationResults) -> Self:
82-
table: "agate.Row" = relation_results["table"][0]
83-
catalog: "agate.Row" = relation_results["catalog"][0]
75+
def build_relation(self, config: RelationConfig) -> IcebergRESTCatalogRelation:
76+
return IcebergRESTCatalogRelation(
77+
base_location=self.__base_location(config),
78+
external_volume=config.config.extra.get("external_volume", self.external_volume),
79+
catalog_name=self.catalog_name,
80+
)
81+
82+
@staticmethod
83+
def __base_location(config: RelationConfig) -> str:
84+
# If the base_location_root config is supplied, overwrite the default value ("_dbt/")
85+
prefix = config.config.extra.get("base_location_root", "_dbt")
8486

85-
adapter_properties = {}
86-
if namespace := catalog.get("namespace"):
87-
adapter_properties["namespace"] = namespace
87+
base_location = f"{prefix}/{config.schema}/{config.identifier}"
8888

89-
config = IcebergRESTCatalogIntegrationConfig(
90-
name=catalog.get("catalog_name"),
91-
catalog_type=catalog.get("catalog_type"),
92-
external_volume=table.get("external_volume_name"),
93-
adapter_properties=adapter_properties,
94-
)
95-
return cls(config)
89+
if subpath := config.config.extra.get("base_location_subpath"):
90+
base_location += f"/{subpath}"
91+
92+
return base_location
93+
94+
95+
class IcebergAWSGlueCatalogIntegration(IcebergRESTCatalogIntegration):
96+
catalog_type: str = "aws_glue"

‎dbt-snowflake/src/dbt/adapters/snowflake/impl.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from dbt.adapters.capability import CapabilityDict, CapabilitySupport, Support, Capability
77
from dbt.adapters.catalogs import CatalogRelation
88
from dbt.adapters.contracts.relation import RelationConfig
9-
from dbt.adapters.snowflake.catalogs import CATALOG_INTEGRATIONS
109
from dbt.adapters.sql import SQLAdapter
1110
from dbt.adapters.sql.impl import (
1211
LIST_SCHEMAS_MACRO_NAME,
@@ -62,7 +61,6 @@ class SnowflakeConfig(AdapterConfig):
6261
external_volume: Optional[str] = None
6362
base_location_root: Optional[str] = None
6463
base_location_subpath: Optional[str] = None
65-
catalog_name: Optional[str] = None
6664

6765

6866
class SnowflakeAdapter(SQLAdapter):
@@ -71,7 +69,8 @@ class SnowflakeAdapter(SQLAdapter):
7169
ConnectionManager = SnowflakeConnectionManager
7270

7371
AdapterSpecificConfigs = SnowflakeConfig
74-
CATALOG_INTEGRATIONS = CATALOG_INTEGRATIONS # type:ignore
72+
73+
CATALOG_INTEGRATIONS = CATALOG_INTEGRATIONS
7574
CONSTRAINT_SUPPORT = {
7675
ConstraintType.check: ConstraintSupport.NOT_SUPPORTED,
7776
ConstraintType.not_null: ConstraintSupport.ENFORCED,

‎dbt-snowflake/src/dbt/include/snowflake/macros/relations/table/create/standard.sql

-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
{%- set transient='' -%}
1111
{%- endif -%}
1212

13-
{%- set sql_header = config.get('sql_header', none) -%}
14-
15-
{%- set copy_grants = config.get('copy_grants', default=false) -%}
16-
1713
{%- set cluster_by_keys = config.get('cluster_by', default=none) -%}
1814
{%- set enable_automatic_clustering = config.get('automatic_clustering', default=false) -%}
1915
{%- set copy_grants = config.get('copy_grants', default=false) -%}

0 commit comments

Comments
 (0)
Please sign in to comment.