Skip to content

Commit 4457ac8

Browse files
committed
Introduce mapping for source_type returned from SHOW STREAMS; Add workaround for Snowflake bug possibly returning not fully qualified names for stages
1 parent 82e6f45 commit 4457ac8

File tree

3 files changed

+27
-9
lines changed

3 files changed

+27
-9
lines changed

CHANGELOG.md

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

3+
## [0.49.2] - 2025-04-23
4+
5+
- Introduced explicit `object_type` to `source_type` mapping for `STREAM`. It should help to reduce naming inconsistency presented in output of `SHOW STREAMS` command.
6+
- Added `STREAM` tests targeting `EXTERNAL_TABLE` and `STAGE` (directory table).
7+
- Added workaround for Snowflake bug related to `SHOW STREAMS` command returning not fully qualified names for `STAGE` targets.
8+
39
## [0.49.1] - 2025-04-23
410

511
- Added explicit `.rstrip(";")` call when reading `text` from `VIEW` and `MATERIALIZED_VIEW` metadata. Other object types should not be affected by trailing semicolon problem.

snowddl/resolver/stream.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33

44

55
class StreamResolver(AbstractSchemaObjectResolver):
6+
object_type_to_source_type_map = {
7+
ObjectType.EXTERNAL_TABLE: "External Table",
8+
ObjectType.EVENT_TABLE: "Table",
9+
ObjectType.STAGE: "Stage",
10+
ObjectType.TABLE: "Table",
11+
ObjectType.VIEW: "View",
12+
}
13+
614
def get_object_type(self) -> ObjectType:
715
return ObjectType.STREAM
816

@@ -22,8 +30,8 @@ def get_existing_objects_in_schema(self, schema: dict):
2230
"database": r["database_name"],
2331
"schema": r["schema_name"],
2432
"name": r["name"],
25-
"object_type": r["source_type"],
26-
"object_name": r["table_name"],
33+
"source_type": r["source_type"],
34+
"table_name": r["table_name"],
2735
"type": r["type"],
2836
"stale": r["stale"] == "true",
2937
"mode": r["mode"],
@@ -47,15 +55,19 @@ def compare_object(self, bp: StreamBlueprint, row: dict):
4755
if row["stale"]:
4856
replace_reasons.append("Stream is marked as stale")
4957

50-
if bp.object_type.singular != row["object_type"].upper():
58+
if self.object_type_to_source_type_map.get(bp.object_type) != row["source_type"]:
5159
replace_reasons.append(
52-
f"Source object type [{str(bp.object_type.name)}] in config does not match source type [{row['object_type']}] in Snowflake"
60+
f"Source object type [{str(bp.object_type.name)}] in config does not match source_type [{row['source_type']}] in Snowflake"
5361
)
5462

55-
if bp.object_name != row["object_name"]:
56-
replace_reasons.append(
57-
f"Source object name [{bp.object_name}] in config does not match source name [{row['object_name']}] in Snowflake"
58-
)
63+
if bp.object_name != row["table_name"]:
64+
if bp.object_type == ObjectType.STAGE and bp.object_name.name == row["table_name"]:
65+
# Snowflake bug: SHOW STREAMS may return not fully qualified name for stage
66+
pass
67+
else:
68+
replace_reasons.append(
69+
f"Source object name [{bp.object_name}] in config does not match table_name [{row['table_name']}] in Snowflake"
70+
)
5971

6072
if bp.append_only != ("APPEND_ONLY" in row["mode"]):
6173
replace_reasons.append(

snowddl/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.49.1"
1+
__version__ = "0.49.2"

0 commit comments

Comments
 (0)