|
60 | 60 | ### 2.1 Descriptions of parameters in CQ syntax |
61 | 61 |
|
62 | 62 | - `<cq_id>` specifies the globally unique id of CQ. |
63 | | -- `<every_interval>` specifies the query execution time interval. We currently support the units of ns, us, ms, s, m, h, d, w, and its value should not be lower than the minimum threshold configured by the user, which is `continuous_query_min_every_interval`. It's an optional parameter, default value is set to `group_by_interval` in group by clause. |
64 | | -- `<start_time_offset>` specifies the start time of each query execution as `now()-<start_time_offset>`. We currently support the units of ns, us, ms, s, m, h, d, w.It's an optional parameter, default value is set to `every_interval` in resample clause. |
65 | | -- `<end_time_offset>` specifies the end time of each query execution as `now()-<end_time_offset>`. We currently support the units of ns, us, ms, s, m, h, d, w.It's an optional parameter, default value is set to `0`. |
| 63 | +- `<every_interval>` specifies the query execution time interval. The supported units are ns, us, ms, s, m, h, d, w, `mo` (calendar month), and `y` (12 calendar months). Calendar units are evaluated in the CQ time zone and are not converted to a fixed number of days. Its value should not be lower than the minimum threshold configured by the user, which is `continuous_query_min_every_interval`. It's an optional parameter, default value is set to `group_by_interval` in group by clause. |
| 64 | +- `<start_time_offset>` specifies the start time of each query execution as `now()-<start_time_offset>`. The supported units are ns, us, ms, s, m, h, d, w, `mo`, and `y`. Calendar offsets are evaluated from the original execution boundary. It's an optional parameter, default value is set to `every_interval` in resample clause. |
| 65 | +- `<end_time_offset>` specifies the end time of each query execution as `now()-<end_time_offset>`. The supported units are ns, us, ms, s, m, h, d, w, `mo`, and `y`. It's an optional parameter, default value is set to `0`. |
66 | 66 | - `<execution_boundary_time>` is a date that represents the execution time of a certain cq task. |
67 | 67 | - `<execution_boundary_time>` can be earlier than, equals to, later than **current time**. |
68 | | - - This parameter is optional. If not specified, it is equal to `BOUNDARY 0`。 |
| 68 | + - This parameter is optional. For a calendar-based `EVERY` interval, an omitted boundary is `1970-01-01 00:00:00` in the CQ time zone. For fixed-only intervals it remains `BOUNDARY 0` (the Unix epoch). An explicitly supplied `BOUNDARY 0` always means the Unix epoch. |
69 | 69 | - **The start time of the first time window** is `<execution_boundary_time> - <start_time_offset>`. |
70 | 70 | - **The end time of the first time window** is `<execution_boundary_time> - <end_time_offset>`. |
71 | 71 | - The **time range** of the `i (1 <= i)th` window is `[<execution_boundary_time> - <start_time_offset> + (i - 1) * <every_interval>, <execution_boundary_time> - <end_time_offset> + (i - 1) * <every_interval>)`. |
72 | 72 | - If the **current time** is earlier than or equal to `execution_boundary_time`, then the first execution moment of the continuous query is `execution_boundary_time`. |
73 | 73 | - If the **current time** is later than `execution_boundary_time`, then the first execution moment of the continuous query is the first `execution_boundary_time + i * <every_interval>` that is later than or equal to the current time . |
74 | 74 |
|
| 75 | +For calendar durations, each occurrence and range endpoint is calculated from the original boundary. Calendar months are applied first and the fixed part is applied afterwards, so a schedule anchored on January 31 reaches February 29 (in a leap year), then March 31, instead of drifting to March 29. For example: |
| 76 | + |
| 77 | +```sql |
| 78 | +CREATE CONTINUOUS QUERY cq_monthly |
| 79 | +RESAMPLE EVERY 1mo RANGE 1mo |
| 80 | +BEGIN |
| 81 | + SELECT max_value(s) INTO root.result.d(max_s) |
| 82 | + FROM root.source.d |
| 83 | + GROUP BY(1mo) |
| 84 | +END; |
| 85 | +``` |
| 86 | + |
| 87 | +This CQ runs on calendar-month boundaries and its February window has the actual number of days in that February. |
| 88 | + |
75 | 89 | > - `<every_interval>`,`<start_time_offset>` and `<group_by_interval>` should all be greater than `0`. |
76 | 90 | > - The value of `<group_by_interval>` should be less than or equal to the value of `<start_time_offset>`, otherwise the system will throw an error. |
77 | 91 | > - Users should specify the appropriate `<start_time_offset>` and `<every_interval>` according to actual needs. |
@@ -589,4 +603,3 @@ SELECT avg(count_s1) from root.sg_count.d; |
589 | 603 | | :------------------------------------------ | ------------------------------------------------------------ | --------- | ------------- | |
590 | 604 | | `continuous_query_submit_thread_count` | The number of threads in the scheduled thread pool that submit continuous query tasks periodically | int32 | 2 | |
591 | 605 | | `continuous_query_min_every_interval_in_ms` | The minimum value of the continuous query execution time interval | duration | 1000 | |
592 | | - |
|
0 commit comments