@@ -13,9 +13,10 @@ re-runs one `SELECT` into its own backing table, a task runs any statement the e
1313plan — typically an ` INSERT ` that appends only what changed, which is what makes it
1414suitable for tables too large to rebuild.
1515
16- A task runs as its owner, so creating one is not merely registering some SQL: it creates
17- something that executes with an identity. What you may define is therefore bounded by what
18- you could already run yourself — see [ Notes] ( #notes ) .
16+ A task carries no identity of its own. Running one with [ EXECUTE] ( execute ) runs it as
17+ ** you** , gated by your own permissions at that moment; an unattended run carries the
18+ identity of the [ trigger] ( create-trigger ) that fired it. Creating a task therefore
19+ confers no authority — see [ Notes] ( #notes ) .
1920
2021## Syntax
2122
@@ -37,7 +38,8 @@ CREATE [ OR REPLACE ] TASK <task_name>
3738- ** ` <statement> ` ** — the SQL the task runs. It may contain ` :name ` placeholders, which are
3839 supplied when the task is executed rather than now.
3940- ` OR REPLACE ` — redefine an existing task instead of refusing. The previous statement is
40- kept as an earlier version, and the task's owner is ** not** changed.
41+ kept as an earlier version, and triggers pointing at the task are untouched — including
42+ whose identity they run it as.
4143
4244## Examples
4345
@@ -78,16 +80,14 @@ CREATE OR REPLACE TASK my_workspace.ops.ingest_events AS
7880
7981## Notes
8082
81- - ** You may only create a task you could run yourself.** Creating one requires ` reader ` on
82- everything the statement reads and ` writer ` where it writes, checked against you at the
83- time you create it and again every time you redefine it. Without that, a task would let
84- anyone define work over data they cannot see and have a privileged identity run it.
85- - ** The task runs as you.** There is no syntax for naming another principal — an argument
86- that could is the escalation above, written out. Ownership survives ` OR REPLACE ` , so
87- editing a task never quietly transfers whose authority it runs with.
88- - ** Platform identities cannot own tasks.** They can read a great deal but have no billing
89- account, so a task pinned to one would run on a schedule forever and land on nobody's
90- bill. Own a task as a user or a service account.
83+ - ** Creating a task checks nothing but the name.** A task is stored SQL: its statement is
84+ gated when it * runs* , against whoever the run actually is — you, for ` EXECUTE ` ; the
85+ trigger's owner, for a fired run. A creation-time copy of those checks would be checked
86+ against the wrong principal the moment anyone else ran it.
87+ - ** ` ON <table> ` is the exception** , because it creates a trigger — and a trigger's
88+ unattended runs execute as its owner, pinned to you. So the ` ON ` form additionally
89+ requires ` writer ` on that table and that you are an identity that can be billed, the
90+ same gates [ CREATE TRIGGER] ( create-trigger ) applies.
9191- The statement is parsed when the task is created, so SQL that could never run is refused
9292 now rather than discovered when it fires. It is not fully planned — a task's placeholders
9393 have no values yet, and planning would demand them.
0 commit comments