add doc for using default unit of interval

This commit is contained in:
wangjiaming0909 2023-11-08 19:24:03 +08:00
parent 829ad64205
commit 7701943d31
2 changed files with 22 additions and 2 deletions

View File

@ -38,11 +38,21 @@ Aggregation by time window is supported in TDengine. For example, in the case wh
window_clause: {
SESSION(ts_col, tol_val)
| STATE_WINDOW(col)
| INTERVAL(interval [, offset]) [SLIDING sliding] [FILL({NONE | VALUE | PREV | NULL | LINEAR | NEXT})]
| INTERVAL(interval [, offset]) [SLIDING (interval)] [FILL({NONE | VALUE | PREV | NULL | LINEAR | NEXT})]
| EVENT_WINDOW START WITH start_trigger_condition END WITH end_trigger_condition
}
interval:
TK_NUMBER
| TK_STRING
| TK_DURATION
```
The parameters of INTERVAL(`interval` or `offset`) and SLIDING are time durations which have 3 forms of representation.
- `INTERVAL(1s, 500a) SLIDING(1s)`, the unit char should be one of `a (millisecond), b (nanosecond), d (day), h (hour), m (minute), n (month), s (second), u (microsecond), w (week), y (year)`.
- `INTERVAL(1000, 500) SLIDING(1000)`, the unit will the same as the database.
- `INTERVAL('1s', '500a') SLIDING('1s')`, or double quoted. Unit must be specified, no spaces allowed.
The following restrictions apply:
### Other Rules

View File

@ -39,11 +39,21 @@ TDengine 支持按时间窗口切分方式进行聚合结果查询,比如温
window_clause: {
SESSION(ts_col, tol_val)
| STATE_WINDOW(col)
| INTERVAL(interval_val [, interval_offset]) [SLIDING (sliding_val)] [FILL(fill_mod_and_val)]
| INTERVAL(interval_val [, interval_offset]) [SLIDING (interval_val)] [FILL(fill_mod_and_val)]
| EVENT_WINDOW START WITH start_trigger_condition END WITH end_trigger_condition
}
interval_val:
TK_NUMBER
| TK_STRING
| TK_DURATION
```
INTERVAL和SLIDING的参数都表示时间段, 有三种表示方式:
- `INTERVAL(1s, 500a) SLIDING(1s)`, 单位是单字符表示, 分别为: `a (毫秒), b (纳秒), d (天), h (小时), m (分钟), n (月), s (秒), u (微妙), w (周), y (年)`.
- `INTERVAL(1000, 500) SLIDING(1000)`, 不带单位的形式使用默认单位, 为表所在库的单位.
- `INTERVAL('1s', '500a') SLIDING('1s')`, 第一种形式也可用引号括起来. 必须指定单位, 内部不能有任何空格.
在上述语法中的具体限制如下
### 窗口子句的规则