Skip to content

Commit

Permalink
docs: update range query time slot caculate (#726)
Browse files Browse the repository at this point in the history
  • Loading branch information
Taylor-lagrange authored Dec 25, 2023
1 parent dd8120a commit 2d1627c
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
Binary file modified docs/public/align_greater_than_range.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/public/align_less_than_range.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions docs/v0.4/en/reference/sql/range.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,18 +218,18 @@ SELECT ts, host, min(val) RANGE '1d' FROM host ALIGN '1d' TO '2023-01-01T00:00:0

If you want to query data for a specific time range, you can specify the timestamp using the `TO` keyword.
For example, to query the daily minimum value of `val` between `00:45` and `06:45`,
you can use `2023-01-01T06:45:00` as the `TO` option along with a `6h` range.
you can use `2023-01-01T00:45:00` as the `TO` option along with a `6h` range.

```sql
SELECT ts, host, min(val) RANGE '6h' FROM host ALIGN '1d' TO '2023-01-01T06:45:00';
SELECT ts, host, min(val) RANGE '6h' FROM host ALIGN '1d' TO '2023-01-01T00:45:00';
```

```sql
+---------------------+-------+----------------------------------+
| ts | host | MIN(host.val) RANGE 6h FILL NULL |
+---------------------+-------+----------------------------------+
| 2023-01-02 06:45:00 | host1 | 1 |
| 2023-01-02 06:45:00 | host2 | 3 |
| 2023-01-02 00:45:00 | host1 | 1 |
| 2023-01-02 00:45:00 | host2 | 3 |
+---------------------+-------+----------------------------------+
```

Expand Down
6 changes: 3 additions & 3 deletions docs/v0.4/en/user-guide/query-data/sql.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,14 @@ The Response is shown below:
The origin time range window steps forward and backward in the time series to generate all time range windows.
In the example above, the origin alignment time is set to `2023-12-01T00:00:00`, which is also the end time of the origin time window.

The `RANGE` option, along with the origin alignment time, defines the origin time range window that starts from `origin alignment timestamp - range` and ends at `origin alignment timestamp`.
The `RANGE` option, along with the origin alignment time, defines the origin time range window that starts from `origin alignment timestamp` and ends at `origin alignment timestamp + range`.

The `ALIGN` option defines the query resolution steps.
It determines the calculation steps from the origin time window to other time windows.
For example, with the origin alignment time `2023-12-01T00:00:00` and `ALIGN '5s'`, the alignment times are `2023-11-30T23:59:55`, `2023-12-01T00:00:00`, `2023-12-01T00:00:05`, `2023-12-01T00:00:10`, and so on.

These time windows are left-open and right-closed intervals
that satisfy the condition `(alignment timestamp - range, alignment timestamp]`.
These time windows are left-closed and right-open intervals
that satisfy the condition `[alignment timestamp, alignment timestamp + range)`.

The following images can help you understand the time range window more visually:

Expand Down
8 changes: 4 additions & 4 deletions docs/v0.4/zh/reference/sql/range.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,18 +216,18 @@ SELECT ts, host, min(val) RANGE '1d' FROM host ALIGN '1d' TO '2023-01-01T00:00:0

如果要查询特定时间范围内的数据,也可以使用 `TO` 关键字指定时间戳达到目的。
例如,要查询 `val``00:45``06:45` 之间的每日最小值,
你可以使用 `2023-01-01T06:45:00` 作为 `TO` 选项以及指定 `6h` 的查询范围。
你可以使用 `2023-01-01T00:45:00` 作为 `TO` 选项以及指定 `6h` 的查询范围。

```sql
SELECT ts, host, min(val) RANGE '6h' FROM host ALIGN '1d' TO '2023-01-01T06:45:00';
SELECT ts, host, min(val) RANGE '6h' FROM host ALIGN '1d' TO '2023-01-01T00:45:00';
```

```sql
+---------------------+-------+----------------------------------+
| ts | host | MIN(host.val) RANGE 6h FILL NULL |
+---------------------+-------+----------------------------------+
| 2023-01-02 06:45:00 | host1 | 1 |
| 2023-01-02 06:45:00 | host2 | 3 |
| 2023-01-02 00:45:00 | host1 | 1 |
| 2023-01-02 00:45:00 | host2 | 3 |
+---------------------+-------+----------------------------------+
```

Expand Down
4 changes: 2 additions & 2 deletions docs/v0.4/zh/user-guide/query-data/sql.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,11 @@ ALIGN '5s' TO '2023-12-01T00:00:00' BY (host);
将初始时间范围窗口在时间序列中向前和向后移动,就生成了所有时间范围窗口。
在上面的例子中,初始对齐时间被设置为 `2023-12-01T00:00:00`,这也是初始时间窗口的结束时间。

`RANGE` 选项和初始对齐时间定义了初始时间范围窗口,它从 `初始对齐时间 - RANGE` 开始,到 `初始对齐时间` 结束。
`RANGE` 选项和初始对齐时间定义了初始时间范围窗口,它从 `初始对齐时间` 开始,到 `初始对齐时间 + RANGE` 结束。
`ALIGN` 选项定义了查询的步频,决定了从初始时间窗口到其他时间窗口的计算步频。
例如,使用初始对齐时间 `2023-12-01T00:00:00``ALIGN '5s'`,时间窗口的对齐时间为 `2023-11-30T23:59:55``2023-12-01T00:00:00``2023-12-01T00:00:05``2023-12-01T00:00:10` 等。

这些时间窗口是左开右闭区间,满足条件 `(对齐时间 - 范围, 对齐时间]`
这些时间窗口是左闭右开区间,满足条件 `[对齐时间, 对齐时间 + 范围)`

下方的图片可以帮助你更直观的理解时间范围窗口:

Expand Down

0 comments on commit 2d1627c

Please sign in to comment.