Skip to content

Commit ec688e7

Browse files
authored
update gap_fill (#203)
* update gap_fill.md * Update downsampling.md
1 parent 2343229 commit ec688e7

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

zh_CN/development-guide/downsampling.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ CREATE TABLE sensor_info (
2525
with (ttl='10d');
2626
```
2727

28-
假设数据采集频率为 `1Hz`,在数据展示时我们希望查询 `sn = 1` 并且以 1分钟 的区间对数据进行聚合(获取一分钟以内 temperature 的平均值 ),则可使用时间函数对数据进行切割、云计算。SQL 语句如下:
28+
假设数据采集频率为 `1Hz`,在数据展示时我们希望查询 `sn = 1` 并且以 1分钟 的区间对数据进行聚合(获取一分钟以内 temperature 的平均值 ),则可使用时间函数对数据进行切割与计算。SQL 语句如下:
2929

3030
```sql
3131
SELECT date_bin('1 minutes', ts) as timepoint, avg(temperature) as temp from sensor_info where sn = 1 group by timepoint;
3232
```
3333

34-
假设数据采集频率为 `1Hz`,在数据展示时我们希望查询 `sn = 1` 并且以 1天 的区间对数据进行聚合(获取一天以内 temperature 的最大值 ),则可使用时间函数对数据进行切割、云计算。SQL 语句如下:
34+
假设数据采集频率为 `1Hz`,在数据展示时我们希望查询 `sn = 1` 并且以 1天 的区间对数据进行聚合(获取一天以内 temperature 的最大值 ),则可使用时间函数对数据进行切割与计算。SQL 语句如下:
3535

3636
```sql
3737
SELECT date_bin('1 day', ts) as timepoint, max(temperature) as temp from sensor_info where sn = 1 group by timepoint;

zh_CN/sql-reference/gap_fill.md

+12
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,18 @@ GROUP BY window
100100

101101
特别注意,如果 SQL 语句中包含时间戳列之外的分组列,那么插值会针对每个分组单独执行。这是考虑到不同分组的数据可能没有显著的关联,如果允许跨分组插值,可能得到异常点(Outlier)。
102102

103+
## date_bin、date_bin_gapfill 函数的起始时间
104+
105+
默认情况下,`date_bin``date_bin_gapfill` 的起始时间对齐参数 `origin` 是 ​UTC 时区的 1970-01-01T00:00:00​(Unix Epoch)。因此,如果函数中未显式指定 `origin`,窗口会从 ​UTC 时间的 0 点​ 开始对齐,而非本地时区的 0 点。
106+
107+
若数据时间戳为 2024-01-16T10:40:00+08:00(东八区),`date_bin('1 day', time)` 会将其对齐到 ​UTC 的 0 点​(即东八区的早上 8 点),而非东八区本地 0 点。
108+
若需从北京时间 0 点对齐,需显式指定 `origin` 如下:
109+
110+
``` sql
111+
date_bin('1 day', time, '2024-01-01T00:00:00+08:00')
112+
```
113+
114+
103115
## 其他注意事项
104116

105117
- `date_bin_gapfill` 只能作为投影列,且必须作为分组列。

0 commit comments

Comments
 (0)