计划查询Schedule a query

重要

此功能目前以公共预览版提供。This feature is in Public Preview. 请联系 Azure Databricks 代表,以申请访问权限。Contact your Azure Databricks representative to request access.

可使用计划的查询执行来使仪表板保持最新状态或启用例程警报。You can use scheduled query executions to keep your dashboards updated or to enable routine alerts. 默认情况下,你的查询没有计划。By default, your queries do not have a schedule.

设置计划:To set the schedule:

  1. 在查询编辑器的左下角In the bottom left corner of the query editor

    刷新设置Refresh settings

    单击“永不”链接以按计划间隔打开一个选取器。click the Never link to open a picker with schedule intervals.

    计划间隔Schedule interval

  2. 设置计划。Set the schedule.

    选取器滚动并允许你选择:The picker scrolls and allows you to choose:

    • 间隔:1-30 分钟、1-12 小时、1 或 30 天、1 或 2 周An interval: 1-30 minutes, 1-12 hours, 1 or 30 days, 1 or 2 weeks

    • 时间。A time. 只有时间间隔大于 1 天且选择天数大于 1 周时,时间选择器才会显示在选取器中。The time selector displays in the picker only when the interval is greater than 1 day and the day selection is greater than 1 week. 如果你安排了一个特定的时间,SQL Analytics 会在你的计算机的时区获取输入并将其转换为 UTC。When you schedule a specific time, SQL Analytics takes input in your computer’s timezone and converts it to UTC. 如果你希望查询在特定 UTC 时间运行,则必须按本地偏移量调整选取器。If you want a query to run at a certain time in UTC, you must adjust the picker by your local offset. 例如,如果希望每天 00:00 (UTC) 执行一次查询,但你的当前时区为 PDT (UTC-7),则应在选取器中选择 17:00For example, if you want a query to execute at 00:00 UTC each day, but your current timezone is PDT (UTC-7), you should select 17:00 in the picker:

      每周计划间隔Weekly schedule interval

  3. 单击 “确定”Click OK.

    查询将自动运行。Your query will run automatically.

    如果遇到计划的查询未按计划执行的情况,则应手动触发查询以确保查询不会失败。If you experience a scheduled query not executing according to its schedule, you should manually trigger the query to make sure it doesn’t fail. 但是,应注意下列事项:However, you should be aware of the following:

    • 如果你计划一个间隔(例如“每 15 分钟”),则该间隔是根据上一次成功执行计算得出的。If you schedule an interval—for example, “every 15 minutes”—the interval is calculated from the last successful execution. 如果你手动执行某个查询,则在间隔结束之前不会执行计划查询。If you manually execute a query, the scheduled query will not be executed until the interval has passed.
    • 如果计划某个时间,SQL Analytics 会等待结果“过时”。If you schedule a time, SQL Analytics will wait for the results to be “outdated”. 例如,如果将一个查询设置为每周四刷新,而你在周三手动执行了该查询,那么到周四,结果仍将被视为“有效”,因此不会为该查询安排新的执行。For example, if you have a query set to refresh every Thursday and you manually execute it on Wednesday, by Thursday the results will still be considered “valid”, so the query wouldn’t be scheduled for a new execution. 因此,当设置每周计划时,请检查上一次查询的执行时间,预计计划的查询将在执行一周后的选定日期执行。Thus, for example, when setting a weekly schedule, check the last query execution time and expect the scheduled query to be executed on the selected day after that execution is a week old. 请确保在此期间不手动执行查询。Make sure not to manually execute the query during this time.

    如果查询执行失败,则 SQL Analytics 将使用回退算法重试。If a query execution fails, SQL Analytics retries with a back-off algorithm. 失败次数越多,下次重试的间隔就越远(可能超过刷新间隔)。The more failures the further away the next retry will be (and it might be beyond the refresh interval).

查询失败报告Query failure reports

如果一个或多个查询失败,则 SQL Analytics 会每小时向查询所有者发送一次电子邮件。If one or more queries fails, SQL Analytics emails query owners once per hour. 这些电子邮件将持续发送,直到没有失败的查询为止。These emails continue until there are no more failures. 失败报告电子邮件在与实际查询计划无关的进程上运行。Failure report emails run on an independent process from the actual query schedules. 执行查询失败后,SQL Analytics 可能在最长一小时后才会发送失败报告。It may take up to an hour after a failed query execution before SQL Analytics sends the failure report.

如果在计划的查询失败时查询所有者没有收到通过电子邮件发送的失败报告,则表示管理员已为 SQL Analytics 实例禁用了它们If query owners do not receive emailed failure reports when scheduled queries fail, your administrator has disabled them for your SQL Analytics instance.