---
title: Databend 开源周报第 81 期
description: 阅读我们的新博客“使用 PGO 技术优化 Databend 构建”，以及学习如何创建和注册标量及聚合函数。
slug: category-weekly/databend-weekly-81
date: 2023-02-20
tags: [weekly]
category: Weekly

image: databend-weekly.png
authors:
  - DatabendLabs
---

# Databend 开源周报 第 81 期

> 英文版移步：https://www.databend.com/blog/2023-02-15-databend-weekly
>
> [Databend](https://github.com/databendlabs/databend) 是一款现代云数仓。专为弹性和高效设计，为您的大规模分析需求保驾护航。自由且开源。即刻体验云服务：[https://app.databend.cn](https://app.databend.cn) 。

{/* truncate */}

## What's New

探索 Databend 本周新进展，遇到更贴近你心意的 Databend。

### Accepted RFCs :airplane_departure:

- rfc: 查询结果缓存 ([#10014](https://github.com/databendlabs/databend/pull/10014))

### Features & Improvements :sparkles:

**Planner**

- 支持 `EXPLAIN ANALYZE` 语句以剖析查询执行 ([#10023](https://github.com/databendlabs/databend/pull/10023))
- 派生新过滤器并下推 ([#10021](https://github.com/databendlabs/databend/pull/10021))

**Query**

- 变更表支持增删列 ([#9851](https://github.com/databendlabs/databend/pull/9851))
- 新增表函数 `infer_schema` ([#9936](https://github.com/databendlabs/databend/pull/9936))
- 为 select 增加权限检查 ([#9924](https://github.com/databendlabs/databend/pull/9924))
- 改进带符号数值的键 ([#9978](https://github.com/databendlabs/databend/pull/9978))
- 支持解析 jwt 元数据并添加多重身份颁发者配置 ([#9971](https://github.com/databendlabs/databend/pull/9971))
- 支持创建文件格式 ([#10009](https://github.com/databendlabs/databend/pull/10009))

**Storage**

- 适配 OpenDAL 的原生 `scan` 支持 ([#9985](https://github.com/databendlabs/databend/pull/9985))
- 新增 `drop_table_by_id` API ([#9990](https://github.com/databendlabs/databend/pull/9990))

**Expression**

- 新增 decimal 类型相关运算支持 ([#9926](https://github.com/databendlabs/databend/pull/9926))

**Functions**

- 支持 `array_any` 函数 ([#9953](https://github.com/databendlabs/databend/pull/9953))
- 支持 `array_sort` 函数 ([#9941](https://github.com/databendlabs/databend/pull/9941))

**Sqllogictest**

- 为 alter table 增加 time travel 相关测试 ([#9939](https://github.com/databendlabs/databend/pull/9939))

### Code Refactoring :tada:

**Meta**

- 将应用层类型移动到 common-meta/app ([#9944](https://github.com/databendlabs/databend/pull/9944))
- 修复 ErrorCode 滥用 ([#10056](https://github.com/databendlabs/databend/pull/10056))

**Query**

- `transform_sort_merge` 使用 heap 来排序数据块 ([#10047](https://github.com/databendlabs/databend/pull/10047))

**Storage**

- 引入 FieldIndex 和 ColumnId 类型以区分使用 ([#10017](https://github.com/databendlabs/databend/pull/10017))

### Build/Testing/CI Infra Changes :electric_plug:

- 以 clickbench 结果格式返回基准测试结果 ([#10019](https://github.com/databendlabs/databend/pull/10019))
- 在 s3 & fs 上均运行基准测试 ([#10050](https://github.com/databendlabs/databend/pull/10050))

### Bug Fixes :wrench:

**Privilege**

- 为 PUBLIC 角色添加 SELECT 权限，以避免普通用户执行查询的权限问题 ([#10040](https://github.com/databendlabs/databend/pull/10040))

**Catalog**

- 修复 parts 的不均匀分布 ([#9951](https://github.com/databendlabs/databend/pull/9951))

**Planner**

- 修复子查询类型断言错误 ([#9937](https://github.com/databendlabs/databend/pull/9937))
- 启用 outer join 到 inner join 优化 ([#9943](https://github.com/databendlabs/databend/pull/9943))
- 修复 RulePushDownLimitOuterJoin ([#10043](https://github.com/databendlabs/databend/pull/10043))

**Query**

- 修复增列更新错误 ([#10037](https://github.com/databendlabs/databend/pull/10037))

**Storage**

- 修复：查询新增 tuple 列时，仅返回默认值 ([#9973](https://github.com/databendlabs/databend/pull/9973))
- 在 bloom filter 中，索引绑定 Column Id ([#10022](https://github.com/databendlabs/databend/pull/10022))

## What's On In Databend

请持续关注 Databend 的最新动态。

### RFC: 查询结果缓存

对于不经常更新的数据，缓存其查询结果可以大大减少响应时间。一旦建立缓存，再次运行查询可以在短时间返回结果。

**阅读下述材料以了解更多讯息**

- [Docs | RFC: Query Result Cache](https://docs.databend.cn/guides/performance/query-result-cache)
- [Tracking Issue | RFC: query result cache](https://github.com/databendlabs/databend/issues/10011)

### 如何编写新的标量/聚合函数

创建自定义的标量或聚合函数可以增强 Databend 的可用性。尽管看上去有一些复杂，但并不困难。

下面列出的两篇文档有助于 Databend 用户和 Rust 开发者创建新的函数，包括如何创建并注册函数的分步说明，以及用于示例的代码片段，以帮助你更好了解这一过程。

**阅读下述材料以了解更多讯息**

- [Docs | How to Write a Scalar Function](https://docs.databend.cn/sql/sql-commands/ddl/udf/ddl-create-function/)
- [Docs | How to Write an Aggregate Function](https://docs.databend.cn/sql/sql-functions/aggregate-functions/)

### Profile-Guided Optimization

Profile-guided optimization (PGO，有时会译作：概要分析指导的优化) 是一种编译器优化技术，可以在程序运行时收集执行数据，并针对冷/热代码路径进行优化。

这篇博客介绍了如何使用 PGO 技术优化 Databend 的二进制构建，并以 Databend 的 SQL 逻辑测试作为工作负载进行演示。

注意：PGO 总是要求使用在统计学上具有代表性的工作负载来生成 Perf 数据。然而，这种技术并不保证总能提高性能。是否使用这项技术需要取决于实际情况。

**阅读下述材料以了解更多讯息**

- [Blog | Optimizing Databend Binary Builds with Profile-guided Optimization](https://www.databend.com/blog/profile-guided-optimization)

## What's Up Next

我们始终对前沿技术和创新理念持开放态度，欢迎您加入社区，为 Databend 注入活力。

### 重构函数相关文档

为了使文档更清晰、易于理解，我们计划重组与函数相关的文档，新的内容组织遵循与 DuckDB 文档样式。

目前这项任务已经按函数类别分解成了一系列易于完成的子任务，如果你对改进 Databend 的文档感兴趣，不妨参与进来。

[Issue 10029: Tracking: re-org the functions doc](https://github.com/databendlabs/databend/issues/10029)

如果你对这个主题感兴趣，可以尝试解决其中的部分问题或者参与讨论和 PR review。或者，你可以点击 https://link.databend.com/i-m-feeling-lucky 来挑选一个随机问题，祝好运！

## Changelogs

前往查看 Databend 每日构建的变更日志，以了解开发的最新动态。

地址：https://github.com/databendlabs/databend/releases

## Contributors

非常感谢贡献者们在本周的卓越工作。

| [<img alt="andylokandy" src="https://avatars.githubusercontent.com/u/9637710?v=4&s=117" width="117" />](https://github.com/andylokandy) | [<img alt="b41sh" src="https://avatars.githubusercontent.com/u/1070352?v=4&s=117" width="117" />](https://github.com/b41sh) | [<img alt="Big-Wuu" src="https://avatars.githubusercontent.com/u/52322009?v=4&s=117" width="117" />](https://github.com/Big-Wuu) | [<img alt="BohuTANG" src="https://avatars.githubusercontent.com/u/172204?v=4&s=117" width="117" />](https://github.com/BohuTANG) | [<img alt="dantengsky" src="https://avatars.githubusercontent.com/u/22081156?v=4&s=117" width="117" />](https://github.com/dantengsky) | [<img alt="dependabot[bot]" src="https://avatars.githubusercontent.com/in/29110?v=4&s=117" width="117" />](https://github.com/apps/dependabot) |
| :-------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------: |
|                                              [andylokandy](https://github.com/andylokandy)                                              |                                              [b41sh](https://github.com/b41sh)                                              |                                              [Big-Wuu](https://github.com/Big-Wuu)                                               |                                             [BohuTANG](https://github.com/BohuTANG)                                              |                                              [dantengsky](https://github.com/dantengsky)                                               |                                             [dependabot[bot]](https://github.com/apps/dependabot)                                              |

| [<img alt="drmingdrmer" src="https://avatars.githubusercontent.com/u/44069?v=4&s=117" width="117" />](https://github.com/drmingdrmer) | [<img alt="everpcpc" src="https://avatars.githubusercontent.com/u/1808802?v=4&s=117" width="117" />](https://github.com/everpcpc) | [<img alt="flaneur2020" src="https://avatars.githubusercontent.com/u/129800?v=4&s=117" width="117" />](https://github.com/flaneur2020) | [<img alt="johnhaxx7" src="https://avatars.githubusercontent.com/u/12479235?v=4&s=117" width="117" />](https://github.com/johnhaxx7) | [<img alt="leiysky" src="https://avatars.githubusercontent.com/u/22445410?v=4&s=117" width="117" />](https://github.com/leiysky) | [<img alt="lichuang" src="https://avatars.githubusercontent.com/u/1998569?v=4&s=117" width="117" />](https://github.com/lichuang) |
| :-----------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------: |
|                                             [drmingdrmer](https://github.com/drmingdrmer)                                             |                                              [everpcpc](https://github.com/everpcpc)                                              |                                             [flaneur2020](https://github.com/flaneur2020)                                              |                                              [johnhaxx7](https://github.com/johnhaxx7)                                               |                                              [leiysky](https://github.com/leiysky)                                               |                                              [lichuang](https://github.com/lichuang)                                              |

| [<img alt="mergify[bot]" src="https://avatars.githubusercontent.com/in/10562?v=4&s=117" width="117" />](https://github.com/apps/mergify) | [<img alt="PsiACE" src="https://avatars.githubusercontent.com/u/36896360?v=4&s=117" width="117" />](https://github.com/PsiACE) | [<img alt="RinChanNOWWW" src="https://avatars.githubusercontent.com/u/33975039?v=4&s=117" width="117" />](https://github.com/RinChanNOWWW) | [<img alt="soyeric128" src="https://avatars.githubusercontent.com/u/106025534?v=4&s=117" width="117" />](https://github.com/soyeric128) | [<img alt="sundy-li" src="https://avatars.githubusercontent.com/u/3325189?v=4&s=117" width="117" />](https://github.com/sundy-li) | [<img alt="TCeason" src="https://avatars.githubusercontent.com/u/33082201?v=4&s=117" width="117" />](https://github.com/TCeason) |
| :--------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------: |
|                                             [mergify[bot]](https://github.com/apps/mergify)                                              |                                              [PsiACE](https://github.com/PsiACE)                                               |                                              [RinChanNOWWW](https://github.com/RinChanNOWWW)                                               |                                               [soyeric128](https://github.com/soyeric128)                                               |                                              [sundy-li](https://github.com/sundy-li)                                              |                                              [TCeason](https://github.com/TCeason)                                               |

| [<img alt="wubx" src="https://avatars.githubusercontent.com/u/320680?v=4&s=117" width="117" />](https://github.com/wubx) | [<img alt="Xuanwo" src="https://avatars.githubusercontent.com/u/5351546?v=4&s=117" width="117" />](https://github.com/Xuanwo) | [<img alt="xudong963" src="https://avatars.githubusercontent.com/u/41979257?v=4&s=117" width="117" />](https://github.com/xudong963) | [<img alt="xxchan" src="https://avatars.githubusercontent.com/u/37948597?v=4&s=117" width="117" />](https://github.com/xxchan) | [<img alt="youngsofun" src="https://avatars.githubusercontent.com/u/5782159?v=4&s=117" width="117" />](https://github.com/youngsofun) | [<img alt="yufan022" src="https://avatars.githubusercontent.com/u/30121694?v=4&s=117" width="117" />](https://github.com/yufan022) |
| :----------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------: |
|                                             [wubx](https://github.com/wubx)                                              |                                              [Xuanwo](https://github.com/Xuanwo)                                              |                                              [xudong963](https://github.com/xudong963)                                               |                                              [xxchan](https://github.com/xxchan)                                               |                                              [youngsofun](https://github.com/youngsofun)                                              |                                              [yufan022](https://github.com/yufan022)                                               |

| [<img alt="zhang2014" src="https://avatars.githubusercontent.com/u/8087042?v=4&s=117" width="117" />](https://github.com/zhang2014) | [<img alt="ZhiHanZ" src="https://avatars.githubusercontent.com/u/25170437?v=4&s=117" width="117" />](https://github.com/ZhiHanZ) | [<img alt="zhyass" src="https://avatars.githubusercontent.com/u/34016424?v=4&s=117" width="117" />](https://github.com/zhyass) |
| :---------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------: |
|                                              [zhang2014](https://github.com/zhang2014)                                              |                                              [ZhiHanZ](https://github.com/ZhiHanZ)                                               |                                              [zhyass](https://github.com/zhyass)                                               |

## Connect With Us

Databend 是一款开源、弹性、低成本，基于对象存储也可以做实时分析的新式数仓。期待您的关注，一起探索云原生数仓解决方案，打造新一代开源 Data Cloud。

- [Databend Website](https://docs.databend.cn)
- [GitHub Discussions](https://github.com/databendlabs/databend/discussions)
- [Twitter](https://twitter.com/Datafuse_Labs)
- [Slack Channel](https://link.databend.com/join-slack)
