# Greptime 双周精选 （3 月 13 日-3 月 26 日）｜支持通过 gRPC 执行 PromQL 查询

Source: https://greptime.cn/blogs/2023-04-03-biweekly

## 内容概述

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

以下是这段时间较为重要的 PR 总结：

- 支持通过 gRPC 执行 PromQL 查询

- 实现各组件优雅关闭功能

- 支持手动触发 Flush

- `COPY TO` 语句支持 `CONNECTION` 选项

- 增加一种私有 gRPC 协议以提高写入效率

## 社区贡献者名单

在过去的两周里，共有 **3 位贡献者**，累计 **12 个 PR 被成功合并**，还有很多待合并的 PR。

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

- @[etolbakov](https://github.com/etolbakov) ([db#1179](https://github.com/GreptimeTeam/greptimedb/pull/1179) [db#1186](https://github.com/GreptimeTeam/greptimedb/pull/1186))

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

- @[WenyXu](https://github.com/WenyXu) ([doc#257](https://github.com/GreptimeTeam/docs/pull/257/) [db#1121](https://github.com/GreptimeTeam/greptimedb/pull/1121) [db#1159](https://github.com/GreptimeTeam/greptimedb/pull/1159) [db#1160](https://github.com/GreptimeTeam/greptimedb/pull/1160) [db#1161](https://github.com/GreptimeTeam/greptimedb/pull/1161) [db#1163](https://github.com/GreptimeTeam/greptimedb/pull/1163) [db#1174](https://github.com/GreptimeTeam/greptimedb/pull/1174) [db#1197](https://github.com/GreptimeTeam/greptimedb/pull/1197) [db#1198](https://github.com/GreptimeTeam/greptimedb/pull/1198))

非常感谢你们慷慨且出色的贡献! GreptimeDB 能够变得更加出色离不开你们的帮助。让我们一起努力，建立一个更棒的社区！

## PR 亮点

### [db#1134](https://github.com/GreptimeTeam/greptimedb/pull/1134) [db#936](https://github.com/GreptimeTeam/greptimedb/pull/936) 支持通过 gRPC 执行 PromQL 查询

在过去，PromQL 查询仅能通过 HTTP API /v1/promql 进行执行。而现在，我们有了新的选择，可以通过 gRPC 服务来执行 PromQL 查询。这为我们带来了更高效的查询方式和更广泛的应用场景。

协议更新如下：

```sql
message QueryRequest {
  oneof query {
    string sql = 1;
    bytes logical_plan = 2;
    PromRangeQuery prom_range_query = 3; // <-- new
  }
}
```

### [db#1158](https://github.com/GreptimeTeam/greptimedb/pull/1158) 实现各组件优雅关闭功能

目前，GreptimeDB 的各个组件（Frontend、Datanode、Metasrv、Standalone）都已经实现了优雅关闭（graceful shutdown）功能。这意味着在关闭过程中，系统能够确保正在处理中的任务得以完成，从而降低数据丢失风险和提高系统的可靠性。这一改进将为用户带来更稳定、更安全的体验。

### [db#1121](https://github.com/GreptimeTeam/greptimedb/pull/1121) [db#1184](https://github.com/GreptimeTeam/greptimedb/pull/1184) 支持手动触发 Flush

我们已经实现了一个手动触发 Flush （将数据刷到磁盘或者远程存储） 的功能，它在 gRPC 层和 HTTP 层都得到了支持。例如，您可以使用 curl 工具来执行这个操作，如下所示：

```sql
# flush region 1 of table greptime.benchmark.tab

curl -XPOST 'localhost:4000/v1/admin/flush?catalog=greptime&db=benchmark&table=tab&region=1'# flush all regions of table greptime.benchmark.tab

curl -XPOST 'localhost:4000/v1/admin/flush?catalog=greptime&db=benchmark&table=tab'# flush all tables of table greptime.benchmark

curl -XPOST 'localhost:4000/v1/admin/flush?catalog=greptime&db=benchmark'
```

### [db#1163](https://github.com/GreptimeTeam/greptimedb/pull/1163) `COPY TO` 语句支持 `CONNECTION` 选项

`COPY TO` SQL 语句现已增加了 `CONNECTION` 选项的支持，这意味着不仅可以将数据备份到本地存储，还能方便地将数据备份到云存储上。这一改进提供了更多灵活性，使得数据备份更加高效、安全和可靠。

### [db#1196](https://github.com/GreptimeTeam/greptimedb/pull/1196) [db#1206](https://github.com/GreptimeTeam/greptimedb/pull/1206) 增加一种私有 gRPC 协议以提高写入效率

为了进一步优化写入性能，我们在 ArrowFlight 之外增加了一种私有 gRPC 协议。这一协议支持 Unary Call 和 Client Streaming Call，从而提高数据写入的效率。与此同时，原有的 ArrowFlight 则侧重于查询方面的性能表现。


## 新鲜事

- 最近我们在为开源数据采集框架 Vector 开发一个 GreptimeDB 的扩展，它可以将任意 Vector 源的数据写入到 GreptimeDB。我们将在开发完成后提交这个扩展到 Vector 仓库。

以上是本期《双周精选》的内容，欢迎关注公众号，我们会定期更新项目有关的进展，分享社区发生的新鲜事。同时，也可以通过各种方式参与 GreptimeDB 和其他相关项目。

## 关于 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/
