Repository navigation
Conversation
The temp table behind copy_into(qualify=True)/merge() was a regular table created over several connections, so a killed process left it behind in the schema, untagged. _merge now runs the whole load in one session and the staging table is TEMPORARY: only that session sees it and Snowflake discards it with the session. - Table.temporary adds TEMPORARY to create/qualify statements - a ContextVar shares the _merge session with the existing connect() sites - removes the manual drop-on-failure path Claude-Session: https://claude.ai/code/session_011PFLPuv77fp5M3JXdZvW1v
giamo
approved these changes
Oct 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #35 (review comment by @giamo): if the pod is killed while copying into
<table>_temp_<id>, nobody cleans the table up and it is untagged._mergenow runs the whole load in one Snowflake session and the staging table isTEMPORARY: only that session sees it and Snowflake discards it with the session. The manual drop-on-failure path is gone.Changes
Table.temporaryaddsTEMPORARYto the create-table and qualify statements (non-temporary SQL is unchanged)._mergeopens one connection and publishes it through aContextVar; the existingconnect()sites intable.pyreuse it, socopy_into,copy_custom,mergeandmerge_customneed no signature changes.Review notes
merge()path and schema evolution.https://claude.ai/code/session_011PFLPuv77fp5M3JXdZvW1v
Note
Medium Risk
Changes core load/merge connection lifecycle and staging table semantics; failures no longer explicitly drop temp tables but rely on Snowflake session expiry, and loads hold one connection for longer.
Overview
Qualified copy_into / merge staging no longer leaves orphaned
<table>_temp_<id>tables if a worker dies mid-load._mergenow holds one Snowflake session for copy → qualify → merge, and the staging table is created as a session-scopedTEMPORARYtable via a newTable.temporaryflag (DDL andqualifyemitTEMPORARYwhen set).A
ContextVarplus_connection()letsbulk_insert,_copy, and related paths reuse that session without API changes. The old manualDROPon failure path is removed; cleanup relies on session end. README documents the single-session temporary staging behavior. Tests assert temporary DDL, singleconnect(), and that failures close the session without merging.Reviewed by Cursor Bugbot for commit 756e413. Bugbot is set up for automated code reviews on this repo. Configure here.