...
EVERY 2 MINUTES
EVERY HOUR AT '0:07:30'
EVERY DAY AT '11:35:30'
Anchor | ||||
---|---|---|---|---|
|
...
ExecutedAs syntax
EXECUTED AS <user_name>
Scheduled queries are executed as the declaring user by default; but people with admin privileges might be able to change the executing user.
...
The “query” is a single statement expression to be scheduled for execution.
System tables/views
Informations about scheduled queries/executions can be obtain by using the information_schema or the sysdb - recommended way is to use the information_schema; sysdb is tables are there to build the information_schema level views - and for debugging.
information_schema.scheduled_queries
Suppose we have a scheduled query defined by:
...
Note |
---|
(schedule_name,cluster_namespace) is unique |
information_schema.scheduled_executions
This view can be used to get information about recent scheduled query executions.
...
Info | ||
---|---|---|
| ||
The scheduled query maintenance task removes older than metastore.scheduled.queries.execution.max.age entries. |
Configuration
Hive metastore related configuration
- metastore.scheduled.queries.enabled (default: true)
Controls the metastore side support for scheduled queries; forces all HMS scheduled query related endpoints to return with an error - metastore.scheduled.queries.execution.timeout (default: 2 minutes)
In case a scheduled execution is not updated for at least this amount of time; it’s state will be changed to TIMED_OUT by the cleaner task - metastore.scheduled.queries.execution.maint.task.frequency (default: 1 minute)
Interval of scheduled query maintenance task. Which removes executions above max age; and marks executions as TIMED_OUT if the condition is met - metastore.scheduled.queries.execution.max.age (default: 30 days)
Maximal age of a scheduled query execution entry before it is removed.
HiveServer2 related configuration
- hive.scheduled.queries.executor.enabled (default: true)
Controls whether HS2 will run scheduled query executor. - hive.scheduled.queries.namespace (default: "hive")
Sets the scheduled query namespace to be used. New scheduled queries are created in this namespace; and execution is also bound to the namespace - hive.scheduled.queries.executor.idle.sleep.time (default: 1 minute)
Time to sleep between querying for the presence of a scheduled query. - hive.scheduled.queries.executor.progress.report.interval (default: 1 minute)
While scheduled queries are in flight; a background update happens periodically to report the actual state of the query. - hive.scheduled.queries.create.as.enabled (default: true)
This option sets the default behaviour of newly created scheduled queries. - hive.security.authorization.scheduled.queries.supported (default: false)
Enable this if the configured authorizer is able to handle scheduled query related calls.
...
Examples
create table t (a integer);
...