I Created TASK like below
CREATE OR REPLACE TASK test_task
WAREHOUSE = TEST_WH
SCHEDULE = '1 MINUTE'
AS
BEGIN
CALL SP_TASKEXECUTION('CREATE_TABLE_PROC_NAME');
END;
I see task created and in suspended state. Now i ran ALTER TASK test_task to RESUME the task. Now im seeing the task status as started. But it is not running. Also i tried to EXECUTE the task Still it is in started state
SP_TASKEXECUTION : This procedure takes another procedure name as input and execute.
CREATE_TABLE_PROC_NAME : This procedure contains create or replace table statment.
Both are working fine when i executes manually. but when it is scheduled through tasks it got stuck in started state .
My question is what can be the possible reasons and how to fix this?
I Created TASK like below
CREATE OR REPLACE TASK test_task
WAREHOUSE = TEST_WH
SCHEDULE = '1 MINUTE'
AS
BEGIN
CALL SP_TASKEXECUTION('CREATE_TABLE_PROC_NAME');
END;
I see task created and in suspended state. Now i ran ALTER TASK test_task to RESUME the task. Now im seeing the task status as started. But it is not running. Also i tried to EXECUTE the task Still it is in started state
SP_TASKEXECUTION : This procedure takes another procedure name as input and execute.
CREATE_TABLE_PROC_NAME : This procedure contains create or replace table statment.
Both are working fine when i executes manually. but when it is scheduled through tasks it got stuck in started state .
My question is what can be the possible reasons and how to fix this?
Share Improve this question edited Feb 3 at 14:30 TylerH 21.1k77 gold badges79 silver badges112 bronze badges asked Feb 3 at 10:10 phani437phani437 112 bronze badges 2- Hi, did you check if you are able to run the procedure CREATE_TABLE_PROC_NAME , without calling from a task ? – Himanshu Kandpal Commented Feb 3 at 14:58
- OP did mention that the procedures on their own works fine. Both are working fine when i executes manually – samhita Commented Feb 3 at 16:41
2 Answers
Reset to default 0If you are only checking TASK status using SHOW TASKS
, then it only has two state as per documentation.
‘started’ or ‘suspended’ based on the current state of the task.
I think you would want to check TASK_HISTORY
view which should show the previously executed tasks.
Sample query from documentation
SELECT query_text, completed_time
FROM snowflake.account_usage.task_history
ORDER BY completed_time DESC
LIMIT 10;
Note as per documentation :
Latency for the view may be up to 45 minutes.
SHOW tasks will show only 2 states ‘started’ or ‘suspended’. To view the past executions of task Realtime(without latency) task data of previous 7 days: https://docs.snowflake/en/sql-reference/functions/task_history
Task data for last 1 year with 45 minute latency: https://docs.snowflake/en/sql-reference/account-usage/task_history