Which query will show a list of the 20 most recent executions of a specified task, MYTASK, that have been scheduled within the last hour that have ended or are still running?
Which query will show a list of the 20 most recent executions of a specified task, MYTASK, that have been scheduled within the last hour that have ended or are still running?
To retrieve the 20 most recent executions of the specified task MYTASK that have been scheduled within the last hour and have ended or are currently running, the query must include a filter to ensure that only tasks that have already started are considered. This can be done by checking that the QUERY_ID is not null, as QUERY_ID is populated only when the task starts running. Without filtering on QUERY_ID, the results could include tasks that are scheduled but have not yet started. Additionally, the query should limit the results to the most recent 20 entries.
B To query only those tasks that have already completed or are currently running, include WHERE query_id IS NOT NULL as a filter. The QUERY_ID column in the TASK_HISTORY output is populated only when a task has started running. https://docs.snowflake.com/en/sql-reference/functions/task_history A - will give all the schedules even the ones that have not run yet C - A schedule could be skipped, cancelled so it won't give all the runs D - It won't return the most recent tasks.
This is a really a Bast*** Inside question, because all the stases are: SCHEDULED: scheduled for execution. EXECUTING: currently executing. SUCCEEDED: execution successful. FAILED: execution failed. FAILED_AND_AUTO_SUSPENDED: task failed, and was automatically suspended. CANCELLED: execution cancelled. SKIPPED
https://docs.snowflake.com/en/sql-reference/functions/task_history#examples Note To retrieve only tasks that are completed or still running, filter the query using WHERE query_id IS NOT NULL. Note that this filter is applied after RESULT_LIMIT already reduces the results returned, so the query could return 9 tasks if 1 task was scheduled but had not started yet.
B because of reason listed by @stopthisnow (c point)