Skip to content

Commit c5f1816

Browse files
authored
SNOW-2747170: Fix temporary object cleanup using incorrect identifiers (#4000)
1 parent 3a68b76 commit c5f1816

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949
- `square`
5050
- `width_bucket`
5151

52+
#### Bug Fixes
53+
54+
- Fixed a bug where automatically-generated temporary objects were not properly cleaned up.
55+
5256
#### Improvements
5357

5458
- Enhanced `DataFrame.sort()` to support `ORDER BY ALL` when no columns are specified.

src/snowflake/snowpark/_internal/compiler/plan_compiler.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,10 @@ def replace_temp_obj_placeholders(
216216
placeholder_name,
217217
temp_obj_type,
218218
) = query.temp_obj_name_placeholder
219-
placeholders[placeholder_name] = random_name_for_temp_object(
220-
temp_obj_type
221-
)
222-
219+
if placeholder_name not in placeholders:
220+
placeholders[placeholder_name] = random_name_for_temp_object(
221+
temp_obj_type
222+
)
223223
copied_query = copy.copy(query)
224224
for placeholder_name, target_temp_name in placeholders.items():
225225
# Copy the original query and replace all the placeholder names with the

tests/integ/test_multithreading.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,7 @@ def process_data(df_, thread_id):
848848
len(unique_create_table_queries) == expected_num_queries
849849
), queries_sent
850850
assert len(unique_drop_table_queries) == expected_num_queries, queries_sent
851+
assert unique_create_table_queries == unique_drop_table_queries
851852

852853
finally:
853854
analyzer.ARRAY_BIND_THRESHOLD = original_value
@@ -913,6 +914,7 @@ def process_data(df_, thread_id):
913914

914915
assert len(unique_create_file_format_queries) == 10
915916
assert len(unique_drop_file_format_queries) == 10
917+
assert unique_create_file_format_queries == unique_drop_file_format_queries
916918

917919

918920
@pytest.mark.xfail(

0 commit comments

Comments
 (0)