Repository navigation
Split task and alert updates into one ALTER per clause - #88
Conversation
update_task raised NotImplementedError when a delta combined as_, when, or state with any other field, so editing a task body and its comment in one apply failed. Snowflake rejects these clauses in one ALTER (001003), but accepts them as separate ALTERs on a started task. update_task now returns one ALTER per clause: MODIFY AS, MODIFY/REMOVE WHEN, the remaining fields via update__default, then RESUME/SUSPEND last so a resumed task starts with its new definition.
|
Nice refactor, replacing the One latent ordering bug: when a delta combines >>> update_task(urn, {"name": "NEW_TASK", "state": "STARTED"}, props)
['ALTER TASK DB.SCHEMA.MY_TASK RENAME TO NEW_TASK', 'ALTER TASK DB.SCHEMA.MY_TASK RESUME']The second statement targets a task name that no longer exists once the first one runs. This looks currently unreachable through the normal plan/apply path, since Ponytail-wise this diff is lean already, nothing to cut. |
update_task sent a rename to update__default alone and then appended RESUME/SUSPEND against the pre-rename name, so a delta with both name and state rendered a second statement for a task that no longer exists. Main refused that delta. Route any delta with name to update__default whole, which already refuses to combine RENAME TO with other fields. plan() rejects renames, but apply(session, plan=...) only warns on a supplied plan, so this path is reachable.
|
Thanks @noel, good catch. The rename + state ordering bug was real. Fixed in f616f5f. >>> update_task(urn, {"name": "NEW_TASK", "state": "STARTED"}, props)
NotImplementedError: update__default cannot combine 'name' (RENAME TO) with other fields ...The path is reachable, not only latent. Proof: |
|
Re-reviewed the latest commit ( A few more things found this round:
Ponytail/complexity pass: lean overall, one note. |
|
Re-reviewed the branch in a worktree. The rename plus state ordering fix from my last pass still holds, and the suite is green (2231 passed, 264 skipped, 1 xfailed). Two findings I missed last time, both in
Checked and cleared: |
|
@GClunies checking in, quiet since my Oct 19 re-review. The rename plus state-ordering fix from the earlier round still holds. What's open is finding 1, dropping the "cannot combine" guard lets Are you planning to pick these up? |
…ttps-github-com-datacoves-snowcap-p
Address review on datacoves#88: - Refuse a task delta with `after` before any SQL renders. ALTER TASK has no SET AFTER, so the other statements applied and then the apply failed. - Run SUSPEND first and RESUME last, so a task or alert never runs with part of its new definition. - Refuse an empty task body. A bare MODIFY AS is a syntax error. An empty WHEN renders REMOVE WHEN. - Send an owner change with other fields to update__default whole, so the error names the fields ("cannot combine 'owner'"). - Apply the same state order to alerts. Render condition and action as MODIFY CONDITION and MODIFY ACTION. Snowflake rejects SET IF(...) and SET THEN, and refuses any alert change while the alert is started. - Build update_task and update_alert on _update_with_separate_clauses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011dXsGJUx4ixC1Ti5vXcDh3
|
Thanks @noel. 3963911 addresses both rounds (Oct 13 and Oct 19), and merges Oct 19
Oct 13
Live
Unit suite: 2333 passed, 267 skipped, 1 xfailed. Not changed here: a started alert with no state change still fails on any other change (392005). It predates this PR. A fix must read the current state from |
What and why
A task or alert update can now change several fields in one apply. Before,
update_taskandupdate_alertraisedNotImplementedErrorwhenstate,as_, orwhencame with another field, so a common edit failed the whole plan:Snowflake rejects these clauses in one statement (
MODIFY AS SELECT 3 SET COMMENT = 'x'is syntax error 001003). Both functions now return oneALTERper clause, built on_update_with_separate_clauses:stateto SUSPENDEDSUSPENDSUSPENDMODIFY AS,MODIFY WHENorREMOVE WHENMODIFY CONDITION EXISTS (...),MODIFY ACTIONupdate__default(SET,UNSET)update__defaultstateto STARTEDRESUMERESUMEA suspend runs first and a resume runs last, so the object never runs with part of its new definition. Alerts need this order: Snowflake refuses every alert change while the alert is started (error 392005).
The delta must not half-apply, so these cases raise before any SQL renders:
afteron a task.ALTER TASKhas noSET AFTER.as_. A bareMODIFY ASis a syntax error. An emptywhenrendersREMOVE WHEN.nameorownerwith other fields. The error names the fields ("cannot combine 'name'" or "cannot combine 'owner'").Before, alert
conditionandthenrendered asSET IF(EXISTS(...))andSET THEN .... Snowflake rejects both.Validation
All on head commit 3963911, which has
mainmerged in.TestUpdateTaskand the alert tests intests/test_lifecycle.pyassert the exact ordered statements and each refusal. The 13 new cases failed before the fix. Full suite: 2333 passed, 267 skipped, 1 xfailed.make lintandmake typecheckare clean.Blueprintplan and apply on the snowcap test account. Each re-plan showed 0 changes:MODIFY AS,RESUMESET COMMENTMODIFY CONDITION,MODIFY ACTION,SET COMMENT,RESUMESUSPEND,MODIFY AS,SET COMMENTSUSPEND,MODIFY CONDITION,MODIFY ACTION,SET COMMENTafterSELECT 3How to review
Start at
_update_with_state_changeinsnowcap/lifecycle.py, thenupdate_taskandupdate_alertbelow it.Feedback wanted: is
SUSPENDfirst,RESUMElast the right order for a task in a DAG?Out of scope, each predates this PR:
afterand wrap the change inSUSPENDandRESUME.CREATE TASKfor a task declaredstate: STARTEDleaves it suspended until the next apply.afterchange still has no update path (see the FIXME aboveupdate_task).