Skip to content

Commit c3bf0be

Browse files
committed
Add external_volume and catalog parameters to DATABASE object type, update tests
1 parent 0c3366c commit c3bf0be

File tree

22 files changed

+121
-15
lines changed

22 files changed

+121
-15
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## [0.63.1] - 2026-03-02
4+
5+
- Added `external_volume` and `catalog` parameters to `DATABASE` object type in order to support Iceberg tables on database level.
6+
37
## [0.63.0] - 2026-02-04
48

59
- Introduced support for `UUID` data type.

snowddl/blueprint/blueprint.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ class DatabaseBlueprint(AbstractBlueprint):
130130
is_sandbox: Optional[bool] = None
131131
is_transient: Optional[bool] = None
132132
retention_time: Optional[int] = None
133+
external_volume: Optional[Ident] = None
134+
catalog: Optional[Ident] = None
133135
owner_database_write: List[IdentPattern] = []
134136
owner_database_read: List[IdentPattern] = []
135137
owner_schema_write: List[IdentPattern] = []

snowddl/parser/database.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
"retention_time": {
2424
"type": "integer"
2525
},
26+
"external_volume": {
27+
"type": "string"
28+
},
29+
"catalog": {
30+
"type": "string",
31+
},
2632
"is_sandbox": {
2733
"type": "boolean"
2834
},
@@ -103,6 +109,8 @@ def load_blueprints(self):
103109
permission_model=database_permission_model_name,
104110
is_transient=database_params.get("is_transient", False),
105111
retention_time=database_params.get("retention_time", None),
112+
external_volume=Ident(database_params.get("external_volume")) if database_params.get("external_volume") else None,
113+
catalog=Ident(database_params.get("catalog")) if database_params.get("catalog") else None,
106114
is_sandbox=database_params.get("is_sandbox", False),
107115
owner_database_write=[IdentPattern(p) for p in database_params.get("owner_database_write", [])],
108116
owner_database_read=[IdentPattern(p) for p in database_params.get("owner_database_read", [])],

snowddl/parser/iceberg_table.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from snowddl.blueprint import IcebergTableBlueprint, Ident, SchemaObjectIdent
44
from snowddl.parser.abc_parser import AbstractParser, ParsedFile
5+
from snowddl.parser.database import database_json_schema
56
from snowddl.parser.schema import schema_json_schema
67

78

@@ -46,22 +47,30 @@ def load_blueprints(self):
4647
combined_params = {}
4748

4849
for database_name in self.get_database_names():
50+
database_params = self.parse_single_entity_file(f"{database_name}/params", database_json_schema)
4951
combined_params[database_name] = {}
5052

5153
for schema_name in self.get_schema_names_in_database(database_name):
5254
schema_params = self.parse_single_entity_file(f"{database_name}/{schema_name}/params", schema_json_schema)
53-
combined_params[database_name][schema_name] = schema_params
55+
56+
combined_params[database_name][schema_name] = {
57+
"is_transient": database_params.get("is_transient", False) or schema_params.get("is_transient", False),
58+
"retention_time": schema_params.get("retention_time"),
59+
"is_sandbox": schema_params.get("is_sandbox", database_params.get("is_sandbox", False)),
60+
"external_volume": schema_params.get("external_volume", database_params.get("external_volume")),
61+
"catalog": schema_params.get("catalog", database_params.get("catalog")),
62+
}
5463

5564
self.parse_schema_object_files(
5665
"iceberg_table", iceberg_table_json_schema, partial(self.process_table, combined_params=combined_params)
5766
)
5867

5968
def process_table(self, f: ParsedFile, combined_params: dict):
6069
if not combined_params[f.database][f.schema].get("external_volume"):
61-
raise ValueError("Iceberg table requires parameter [external_volume] to be defined on schema level")
70+
raise ValueError("Iceberg table requires parameter [external_volume] to be defined on database or schema level")
6271

6372
if not combined_params[f.database][f.schema].get("catalog"):
64-
raise ValueError("Iceberg table requires parameter [catalog] to be defined on schema level")
73+
raise ValueError("Iceberg table requires parameter [catalog] to be defined on database or schema level")
6574

6675
bp = IcebergTableBlueprint(
6776
full_name=SchemaObjectIdent(self.env_prefix, f.database, f.schema, f.name),

snowddl/parser/schema.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ def load_blueprints(self):
112112
"is_transient": database_params.get("is_transient", False) or schema_params.get("is_transient", False),
113113
"retention_time": schema_params.get("retention_time"),
114114
"is_sandbox": schema_params.get("is_sandbox", database_params.get("is_sandbox", False)),
115+
"external_volume": schema_params.get("external_volume", database_params.get("external_volume")),
116+
"catalog": schema_params.get("catalog", database_params.get("catalog")),
115117
}
116118

117119
# fmt: off
@@ -121,8 +123,8 @@ def load_blueprints(self):
121123
is_sandbox=combined_params.get("is_sandbox", False),
122124
is_transient=combined_params.get("is_transient", False),
123125
retention_time=combined_params.get("retention_time", None),
124-
external_volume=Ident(schema_params.get("external_volume")) if schema_params.get("external_volume") else None,
125-
catalog=Ident(schema_params.get("catalog")) if schema_params.get("catalog") else None,
126+
external_volume=Ident(combined_params.get("external_volume")) if combined_params.get("external_volume") else None,
127+
catalog=Ident(combined_params.get("catalog")) if combined_params.get("catalog") else None,
126128
owner_database_write=[IdentPattern(p) for p in schema_params.get("owner_database_write", [])],
127129
owner_database_read=[IdentPattern(p) for p in schema_params.get("owner_database_read", [])],
128130
owner_schema_write=[IdentPattern(p) for p in schema_params.get("owner_schema_write", [])],

snowddl/resolver/database_owner_role.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,25 @@ def get_blueprint_owner_role(self, database_bp: DatabaseBlueprint):
5959
)
6060
)
6161

62+
# Iceberg-related grants
63+
if database_bp.external_volume:
64+
grants.append(
65+
Grant(
66+
privilege="USAGE",
67+
on=ObjectType.VOLUME,
68+
name=database_bp.external_volume,
69+
)
70+
)
71+
72+
if database_bp.catalog:
73+
grants.append(
74+
Grant(
75+
privilege="USAGE",
76+
on=ObjectType.INTEGRATION,
77+
name=database_bp.catalog,
78+
)
79+
)
80+
6281
# Create grants
6382
for model_create_grant in database_permission_model.owner_create_grants:
6483
future_grants.append(

snowddl/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.63.0"
1+
__version__ = "0.63.1"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
permission_model: iceberg
1+
permission_model: iceberg_schema_owner_model
22

33
external_volume: test_external_volume_glue
44
catalog: test_catalog_glue
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
permission_model: iceberg
1+
permission_model: iceberg_schema_owner_model
22

33
external_volume: test_external_volume_glue
44
catalog: test_catalog_object_store
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
catalog_table_name: test_iceberg_table_1
2+
comment: abc

0 commit comments

Comments
 (0)