Get scheduled query information and monitor the query

After you create a scheduled query you can access information about it in the scheduled_queries table of the Hive information schema. You can also use the information schema to monitor scheduled query execution.

  1. Query the information schema to get information about a schedule.
    SELECT *
    FROM information_schema.scheduled_queries
    WHERE schedule_name = 'scheduled_rebuild'; 
    The following information appears about the scheduled query:
    scheduled_query_id
    Unique numeric identifier for a scheduled query.
    schedule_name
    Name of the scheduled query.
    enabled
    Whether the scheduled query is currently enabled or not.
    cluster_namespace
    Namespace that the scheduled query belongs to.
    schedule
    Schedule described as a Quartz cron expression.
    user
    Owner of the scheduled query.
    query
    SQL query to be executed.
    next_execution
    When the next execution of this scheduled query is due.
  2. Monitor the most recent scheduled query execution.
    SELECT *
    FROM information_schema.scheduled_executions; 
    You can configure the retention period for this information in the Hive metastore.
    scheduled_execution_id
    Unique numeric identifier for a scheduled query execution.
    schedule_name
    Name of the scheduled query associated with this execution.
    executor_query_id
    Query ID assigned to the execution by HiveServer (HS2).
    state
    One of the following phases of execution.
    • STARTED. A scheduled query is due and a HiveServer instance has retrieved its information.
    • EXECUTING. HiveServer is executing the query and reporting progress in configurable intervals.
    • FAILED. The query execution was stopped due to an error or exception.
    • FINISHED. The query execution was successful.
    • TIMED_OUT. HiveServer did not provide an update on the query status for more than a configurable timeout.
    start_time
    Start time of execution.
    end_time
    End time of execution.
    elapsed
    Difference between start and end time.
    error_message
    If the scheduled query failed, it contains the error message associated with its failure.
    last_update_time
    Time of the last update of the query status by HiveServer.