# Greptime 双周精选 （10.16-10.28）｜ 全新升级工具带你无缝切换新版本

Source: https://greptime.cn/blogs/2023-11-01-biweekly

## 内容概述

作为一个成长中的开源项目，GreptimeDB 的进展离不开来自全球的社区贡献者们，感谢各位！

在过去两周中，我们继 GreptimeDB v0.4 正式发布后迭代了两个小版本 v0.4.1 和 v0.4.2。以下是这段时间的总结：

- 实现了对 Prometheus 的 Histogram 的支持；

- 优化了 OpenTSDB 协议；

- 查询支持了嵌套 Range 表达式，这非常有用；

- 修复了不同的 KvBackend 实现时 Range 实现行为不完全一致的 bug；

- 提供了一个内置工具帮助用户完成 v0.3 到 v0.4 的升级，可参考官方文档 https://docs.greptime.cn/user-guide/upgrade。

## 社区贡献者名单

在过去的两周里，GreptimeDB 共合并了 76 个 PR，其中有 6 位独立贡献者，累计 8 个 PR 被成功合并，还有很多待合并的 PR。

祝贺以下各位在过去 2 周内成为我们活跃的贡献者：

- @[AbhineshJha](https://github.com/AbhineshJha) ([db#2656](https://github.com/GreptimeTeam/greptimedb/pull/2656))

- @[Lilit0x](https://github.com/Lilit0x) ([db#2623](https://github.com/GreptimeTeam/greptimedb/pull/2623))

- @[NiwakaDev](https://github.com/NiwakaDev) ([db#2621](https://github.com/GreptimeTeam/greptimedb/pull/2621))

- @[shoothzj](https://github.com/shoothzj) ([docs#651](https://github.com/GreptimeTeam/docs/pull/651)  [db#2606](https://github.com/GreptimeTeam/greptimedb/pull/2606))

- @[tisonkun](https://github.com/tisonkun) ([db#2653](https://github.com/GreptimeTeam/greptimedb/pull/2653))

- @[Yun Chen](https://github.com/masonyc) ([db#2609](https://github.com/GreptimeTeam/greptimedb/pull/2609) [docs#652](https://github.com/GreptimeTeam/docs/pull/652))

🎉 热烈欢迎 @[AbhineshJha](https://github.com/AbhineshJha) @[shoothzj](https://github.com/shoothzj) @[tisonkun](https://github.com/tisonkun) 作为新的贡献者加入社区并成功合并了首个 PR，还有更多来自其他独立贡献者的 PR 正在等待合并。

同时衷心感谢我们所有的成员和贡献者！是你们的付出让我们的项目得以成功，也是你们让 GreptimeDB 成为一个更优质的产品。让我们一起努力，建立一个更棒的社区！

## PR 亮点

### [db#2626](https://github.com/GreptimeTeam/greptimedb/pull/2626) [db#2651](https://github.com/GreptimeTeam/greptimedb/pull/2651)  实现 PromQL 的 [`histogram_quantile` 函数](https://prometheus.io/docs/prometheus/latest/querying/functions/#histogram_quantile)

这是对于 Prometheus 四种数据类型中 Histogram 类型最常用的计算函数，能够计算 φ-quantile (0 ≤ φ ≤ 1)。例如 `histogram_quantile(0.9, rate(http_request_duration_seconds_bucket[10m]))`。

### [db#2653](https://github.com/GreptimeTeam/greptimedb/pull/2653) 优化了 OpenTSDB 写入，支持批量解析数据并插入

### [db#2557](https://github.com/GreptimeTeam/greptimedb/pull/2557) 支持嵌套 Range 表达式

像 `max(a+1) Range '5m' FILL NULL` 这样的 Range 表达式可以嵌套在任何表达式中。比如下面的一个嵌套 Range 查询：

```sql
Select
    round(max(a+1) Range '5m' FILL NULL),
    sin((max(a) + 1) Range '5m' FILL NULL)，
from
    test
ALIGN '1h' by (b) FILL NULL;
```

该 SQL 查询在语义上等价于：

```sql
Select round(x), sin(y + 1) from
    (
        select max(a+1) Range '5m' FILL NULL as x, max(a) Range '5m' FILL NULL as y
            from
        test
            ALIGN '1h' by (b) FILL NULL;
    )
;
```

无效示例：Range 表达式不能够嵌套 Range 表达式，像 `SELECT min(max(val) RANGE '20s') RANGE '20s' FROM host ALIGN '10s';` 这样的查询是不合法的。

范围查询现在支持以下填充选项，用于填充聚合后的 `null` 值：

- `NULL`：保持空值不变；

- `PREV`：用时间线上排序的前一个值填充空值；

- `LINEAR`：用时间线上排序的前后两个值的平均值填充空值；

- `x`：用常量 `x` 填充所有空值；

使用 LINEAR 填充策略会将整数隐式转换为浮点类型。

⚠️ Range 查询的具体语法请参考用户文档：https://docs.greptime.cn/reference/sql/range

## Good First Issue

### [db#2500 修复 `redact_sql_secrets` 函数不能正常处理特殊字符的问题](https://github.com/GreptimeTeam/greptimedb/issues/2500)  

困难指数：🌟🌟

### [db#2877 减少技术债务](https://github.com/GreptimeTeam/greptimedb/issues/2877)

困难指数：🌟

### [db#1540 完善 Prometheus 兼容性，支持格式化 PromQL 表达式](https://github.com/GreptimeTeam/greptimedb/issues/1540)

困难指数：🌟🌟

### [db#1529 从 tokio-console 导出 tokio 运行时指标](https://github.com/GreptimeTeam/greptimedb/issues/1529)

困难指数：🌟🌟🌟

### [db#2595 修复非法的 SchemaNameKey 格式](https://github.com/GreptimeTeam/greptimedb/issues/2595)

困难指数：🌟🌟🌟

## 关于 Greptime

[Greptime 格睿科技](https://greptime.cn/)专注于为可观测、物联网及车联网等领域提供实时、高效的数据存储和分析服务，帮助客户挖掘数据的深层价值。目前基于云原生的时序数据库 [GreptimeDB](https://github.com/GreptimeTeam/greptimedb) 已经衍生出多款适合不同用户的解决方案，更多信息或 demo 展示请联系下方小助手（微信号：greptime）。

欢迎对开源感兴趣的朋友们参与贡献和讨论，从带有 good first issue 标签的 issue 开始你的开源之旅吧～期待在开源社群里遇见你！添加小助手微信即可加入“技术交流群”与志同道合的朋友们面对面交流哦~

Star us on GitHub Now: https://github.com/GreptimeTeam/greptimedb

官网：https://greptime.cn/

文档：https://docs.greptime.cn/

Twitter: https://twitter.com/Greptime

Slack: https://greptime.com/slack

LinkedIn: https://www.linkedin.com/company/greptime/
