Skip to content

Commit 0694dae

Browse files
authored
NO-SNOW: Fix non-determinism in TestCallIdentifierBinding::test_call_union and scoped object naming change (#4205)
1 parent c3cc950 commit 0694dae

2 files changed

Lines changed: 26 additions & 14 deletions

File tree

tests/integ/test_bind_variable.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,4 +536,7 @@ def test_call_union(self, session, proc_name):
536536
params=[proc_name, "tmpl2", "args2"],
537537
)
538538
result = df1.union_all(df2).collect()
539-
assert result == [Row("tmpl1 | args1"), Row("tmpl2 | args2")]
539+
assert sorted(result, key=lambda r: r[0]) == [
540+
Row("tmpl1 | args1"),
541+
Row("tmpl2 | args2"),
542+
]

tests/integ/test_scoped_temp_objects.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
# Copyright (c) 2012-2025 Snowflake Computing Inc. All rights reserved.
33
#
44

5+
from contextlib import contextmanager
56
import pytest
67

78
from snowflake.connector.errors import ProgrammingError
89
from snowflake.snowpark._internal.utils import (
910
TempObjectType,
1011
random_name_for_temp_object,
1112
)
13+
from tests.utils import IS_IN_STORED_PROC
1214

1315

1416
@pytest.mark.xfail(
@@ -43,30 +45,37 @@ def test_create_scoped_temp_objects_syntax(session):
4345
)
4446
assert "Unsupported feature 'SCOPED_TEMPORARY'." in str(exc)
4547

48+
# CREATE SCOPED TEMPORARY TABLE previously only worked if the name of the object began with
49+
# SNOWPARK_TEMP_. This was changed to only enforce the naming convention if the query is issued
50+
# from within a stored procedure.
51+
52+
@contextmanager
53+
def cm():
54+
if IS_IN_STORED_PROC:
55+
with pytest.raises(ProgrammingError) as exc:
56+
yield
57+
assert "Unsupported feature 'SCOPED_TEMPORARY'." in str(exc)
58+
else:
59+
yield
60+
4661
temp_table_name = "temp_table"
47-
with pytest.raises(ProgrammingError) as exc:
62+
with cm():
4863
session._run_query(f"create scoped temporary table {temp_table_name} (col int)")
49-
assert "Unsupported feature 'SCOPED_TEMPORARY'." in str(exc)
50-
with pytest.raises(ProgrammingError) as exc:
64+
with cm():
5165
session._run_query(
5266
f"create scoped temporary view temp_view as select * from {temp_table_name}"
5367
)
54-
assert "Unsupported feature 'SCOPED_TEMPORARY'." in str(exc)
55-
with pytest.raises(ProgrammingError) as exc:
68+
with cm():
5669
session._run_query("create scoped temporary stage temp_stage")
57-
assert "Unsupported feature 'SCOPED_TEMPORARY'." in str(exc)
58-
with pytest.raises(ProgrammingError) as exc:
70+
with cm():
5971
session._run_query(
6072
"create scoped temporary function temp_function (arg int) returns int"
6173
)
62-
assert "Unsupported feature 'SCOPED_TEMPORARY'." in str(exc)
63-
with pytest.raises(ProgrammingError) as exc:
74+
with cm():
6475
session._run_query(
65-
"create scoped temporary function temp_talbe_function (arg int) returns table(col int) as $$ select * from {temp_table_name} $$"
76+
f"create scoped temporary function temp_table_function (arg int) returns table(col int) as $$ select col from {temp_table_name} $$"
6677
)
67-
assert "Unsupported feature 'SCOPED_TEMPORARY'." in str(exc)
68-
with pytest.raises(ProgrammingError) as exc:
78+
with cm():
6979
session._run_query(
7080
"create scoped temporary file format temp_file_format type = csv"
7181
)
72-
assert "Unsupported feature 'SCOPED_TEMPORARY'." in str(exc)

0 commit comments

Comments
 (0)