0

TASK1 和 TASK2 定义

CREATE OR REPLACE TASK TASK1
  warehouse = 'WH'
  schedule = '5 minute'
as
CALL SCHEMA.MY_STORED_PROCEDURE1('ARG1');

CREATE OR REPLACE TASK TASK2
  warehouse = 'WH'
  after TASK1
as
CALL SCHEMA.MY_STORED_PROCEDURE2('ARG1');

我正在尝试将 TASK1 和 TASK2 的所有权转移给角色 ROLE1

grant ownership on task TASK1 to role ROLE1;

当我运行上面的命令时,它删除了 AFTER 关键字(在 TASK1 之后)行,并且 TASK1 和 TASK2 的定义如下所示

CREATE OR REPLACE TASK TASK1
  warehouse = 'WH'
  schedule = '5 minute'
as
CALL SCHEMA.MY_STORED_PROCEDURE1('ARG1');

CREATE OR REPLACE TASK TASK2
  warehouse = 'WH'
as
CALL SCHEMA.MY_STORED_PROCEDURE2('ARG1');

当我转移所有权时,我如何确保它也会添加依赖任务。我不想使用以下命令手动执行此操作

alter task TASK2 add after TASK1;
4

1 回答 1

0

任务不能有不具有相同所有者角色的前任:

use role accountadmin;
create or replace role test_role;
grant usage on procedure test_sp(varchar) to role test_role;
grant usage on warehouse gokhan_wh to role test_role;
grant usage on database gokhan_db to role test_role;
grant all on schema gokhan_db.public to role test_role;
grant role test_role to user gokhan;

CREATE OR REPLACE TASK TASK1
  warehouse = 'GOKHAN_WH'
  schedule = '5 minute'
as
CALL test_sp('ARG1');

use role test_role;

CREATE OR REPLACE TASK TASK2
  warehouse = 'GOKHAN_WH'
  after TASK2
as
CALL test_sp('ARG1');

第二个将因“指定了无效的前任 TASK1”而失败。

当您一一更改所有权时,您会破坏关系,因为它们属于不同的角色!为防止破坏关系,您可以更改架构中所有任务的所有权:

grant ownership on all TASKS in schema public to role ROLE1;

因此,就您而言,没有简单的解决方法。您可以考虑编写一个 JS 程序来自动重新连接这些任务。

于 2021-09-08T16:05:30.320 回答