Skip to content

Commit cf75287

Browse files
committed
Handle snowflake table already exists
1 parent a6b8a94 commit cf75287

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

sqlmesh/core/engine_adapter/snowflake.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,9 +700,13 @@ def _record_execution_stats(
700700
# - [^"] matches any single character except a double-quote
701701
# - | or
702702
# - "" matches two sequential double-quotes
703-
is_ctas = re.match(
703+
is_created = re.match(
704704
r'Table ([a-zA-Z0-9_$]+|"(?:[^"]|"")+") successfully created\.', results_str
705705
)
706-
if is_ctas:
706+
is_already_exists = re.match(
707+
r'([a-zA-Z0-9_$]+|"(?:[^"]|"")+") already exists, statement succeeded\.',
708+
results_str,
709+
)
710+
if is_created or is_already_exists:
707711
return
708712
QueryExecutionTracker.record_execution(sql, rowcount, bytes_processed)

tests/core/engine_adapter/integration/test_integration.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2457,7 +2457,9 @@ def capture_execution_stats(
24572457
assert len(physical_layer_results.tables) == len(physical_layer_results.non_temp_tables) == 3
24582458

24592459
if ctx.engine_adapter.SUPPORTS_QUERY_EXECUTION_TRACKING:
2460-
assert actual_execution_stats["seed_model"].total_rows_processed == 7
2460+
assert actual_execution_stats["seed_model"].total_rows_processed == (
2461+
None if ctx.mark.startswith("snowflake") else 7
2462+
)
24612463
assert actual_execution_stats["incremental_model"].total_rows_processed == 7
24622464
# snowflake doesn't track rows for CTAS
24632465
assert actual_execution_stats["full_model"].total_rows_processed == (

0 commit comments

Comments
 (0)