Skip to content

Commit 2cfb72c

Browse files
Catalog Integration Config Standardization (#1134)
1 parent cc5c590 commit 2cfb72c

File tree

22 files changed

+120
-22
lines changed

22 files changed

+120
-22
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: Features
2+
body: Add constant defining name of logical catalog in model config
3+
time: 2025-05-30T15:39:38.251541-07:00
4+
custom:
5+
Author: colin-rogers-dbt
6+
Issue: "1134"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: Under the Hood
2+
body: populate file_format from top level integration config field
3+
time: 2025-05-29T11:44:48.898354-07:00
4+
custom:
5+
Author: colin-rogers-dbt
6+
Issue: "1129"

dbt-adapters/src/dbt/adapters/base/impl.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@
107107
if TYPE_CHECKING:
108108
import agate
109109

110-
111110
GET_CATALOG_MACRO_NAME = "get_catalog"
112111
GET_CATALOG_RELATIONS_MACRO_NAME = "get_catalog_relations"
113112
FRESHNESS_MACRO_NAME = "collect_freshness"

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@
99
CatalogIntegrationConfig,
1010
CatalogRelation,
1111
)
12+
13+
from dbt.adapters.catalogs._constants import CATALOG_INTEGRATION_MODEL_CONFIG_NAME
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CATALOG_INTEGRATION_MODEL_CONFIG_NAME = "catalog_name"

dbt-adapters/src/dbt/adapters/catalogs/_integration.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@ class CatalogIntegrationConfig(Protocol):
4040
catalog_name: Optional[str]
4141
table_format: Optional[str]
4242
external_volume: Optional[str]
43+
file_format: Optional[str]
4344
adapter_properties: Dict[str, Any]
4445

4546

4647
class CatalogRelation(Protocol):
4748
catalog_name: Optional[str]
4849
table_format: Optional[str]
4950
external_volume: Optional[str]
51+
file_format: Optional[str]
5052

5153

5254
class CatalogIntegration(abc.ABC):
@@ -78,16 +80,17 @@ class CatalogIntegration(abc.ABC):
7880

7981
catalog_type: str
8082
table_format: Optional[str] = None
83+
file_format: Optional[str] = None
8184
allows_writes: bool = False
8285

8386
def __init__(self, config: CatalogIntegrationConfig) -> None:
8487
# table_format is often fixed for a catalog type, allow it to be defined at the class level
8588
if config.table_format is not None:
8689
self.table_format = config.table_format
87-
8890
self.name: str = config.name
8991
self.catalog_name: Optional[str] = config.catalog_name
9092
self.external_volume: Optional[str] = config.external_volume
93+
self.file_format: Optional[str] = config.file_format
9194

9295
def build_relation(self, config: RelationConfig) -> CatalogRelation:
9396
"""

dbt-adapters/tests/unit/test_catalogs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717

1818

1919
@dataclass
20-
class FakeCatalogIntegrationConfig:
20+
class FakeCatalogIntegrationConfig(CatalogIntegrationConfig):
2121
name: str
2222
catalog_type: str
2323
catalog_name: Optional[str] = None
2424
table_format: Optional[str] = None
2525
external_volume: Optional[str] = None
26+
file_format: Optional[str] = None
2627
adapter_properties: Optional[Dict[str, Any]] = None
2728

2829

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: Breaking Changes
2+
body: rename 'catalog' model config value to 'catalog_name'
3+
time: 2025-05-30T15:44:38.10309-07:00
4+
custom:
5+
Author: colin-rogers-dbt
6+
Issue: "1134"

dbt-bigquery/src/dbt/adapters/bigquery/catalogs/_generic.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
from dataclasses import dataclass
22
from typing import Optional
33

4-
from dbt.adapters.catalogs import (
5-
CatalogIntegration,
6-
CatalogIntegrationConfig,
7-
)
4+
from dbt.adapters.catalogs import CatalogIntegration
85
from dbt.adapters.contracts.relation import RelationConfig
96

107
from dbt.adapters.bigquery import constants, parse_model
@@ -31,12 +28,6 @@ class BigQueryCatalogIntegration(CatalogIntegration):
3128
catalog_type = constants.GENERIC_CATALOG_TYPE
3229
allows_writes = True
3330

34-
def __init__(self, config: CatalogIntegrationConfig) -> None:
35-
super().__init__(config)
36-
self.file_format: Optional[str] = config.adapter_properties.get(
37-
"file_format", constants.INFO_SCHEMA_FILE_FORMAT
38-
)
39-
4031
@property
4132
def storage_uri(self) -> Optional[str]:
4233
return self.external_volume

dbt-bigquery/src/dbt/adapters/bigquery/constants.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,13 @@
2121
catalog_type=GENERIC_CATALOG_TYPE,
2222
table_format=INFO_SCHEMA_TABLE_FORMAT,
2323
external_volume=None,
24-
adapter_properties={
25-
"file_format": INFO_SCHEMA_FILE_FORMAT,
26-
},
24+
file_format=INFO_SCHEMA_FILE_FORMAT,
2725
)
2826
DEFAULT_ICEBERG_CATALOG = SimpleNamespace(
2927
name="managed_iceberg",
3028
catalog_name="managed_iceberg",
3129
catalog_type=GENERIC_CATALOG_TYPE,
3230
table_format=ICEBERG_TABLE_FORMAT,
3331
external_volume=None,
34-
adapter_properties={
35-
"file_format": PARQUET_FILE_FORMAT,
36-
},
32+
file_format=PARQUET_FILE_FORMAT,
3733
)

0 commit comments

Comments
 (0)