morningman commented on a change in pull request #3760: URL: https://github.com/apache/incubator-doris/pull/3760#discussion_r443222828
########## File path: docs/zh-CN/extending-doris/user-defined-function.md ########## @@ -74,23 +93,154 @@ under the License. |Varchar|StringVal| |Decimal|DecimalVal| -## 编译UDF函数 + +## 编译 UDF 函数 + + 由于 UDF 实现中依赖了 Doris 的 UDF 框架 , 所以在编译 UDF 函数的时候首先要对 Doris 进行编译,也就是对 UDF 框架进行编译。 + + 编译完成后会生成,UDF 框架的静态库文件。之后引入 UDF 框架依赖,并编译 UDF 即可。 ### 编译Doris -在Doris根目录下执行`sh build.sh`就会在`output/udf/`生成对应`headers|libs` +在 Doris 根目录下执行 `sh build.sh` 就会在 `output/udf/` 生成 UDF 框架的静态库文件 `headers|libs` + +``` +├── output +│ └── udf +│ ├── include +│ │ ├── uda_test_harness.h +│ │ └── udf.h +│ └── lib +│ └── libDorisUdf.a + +``` + +### 编写 UDF 编译文件 + +1. 准备 third_party + + third_party 文件夹主要用于存放用户 UDF 函数依赖的第三方库,包括头文件及静态库。其中必须包含依赖的 Doris UDF 框架中 `udf.h` 和 `libDorisUdf.a` 这两个文件。 Review comment: ```suggestion thirdparty 文件夹主要用于存放用户 UDF 函数依赖的第三方库,包括头文件及静态库。其中必须包含依赖的 Doris UDF 框架中 `udf.h` 和 `libDorisUdf.a` 这两个文件。 ``` 其实 thirdparty 可以直接连起来写 ########## File path: docs/zh-CN/extending-doris/user-defined-function.md ########## @@ -26,18 +26,37 @@ under the License. # User Define Function -用户可以通过UDF机制来扩展Doris的能力。通过这篇文档,用户能够创建自己的UDF。 +UDF 主要适用于,用户需要的分析能力 Doris 并不具备的场景。用户可以自行根据自己的需求,实现自定义的函数,并且通过 UDF 框架注册到 Doris 中,来扩展 Doris 的能力,并解决用户分析需求。 + +UDF 能满足的分析需求分为两种:UDF 和 UDAF。本文中的 UDF 指的是二者的统称。 + +1. UDF: 用户自定义函数,这种函数会对单行进行操作,并且输出单行结果。当用户在查询时使用 UDF ,每行数据最终都会出现在结果集中。典型的 UDF 比如字符串操作 concat() 等。 +2. UDAF: 用户自定义的聚合函数,这种函数对多行进行操作,并且输出单行结果。当用户在查询时使用 UDAF,分组后的每组数据最后会计算出一个值并展结果集中。典型的 UDAF 比如集合操作 sum() 等。一般来说 UDAF 都会结合 group by 一起使用。 + +这篇文档主要讲述了,如何编写自定义的 UDF 函数,以及如何在 Doris 中使用它。 + +如果用户使用 UDF 功能并扩展了 Doris 的函数分析,并且希望将自己实现的 UDF 函数贡献回 Doris 社区给其他用户使用,这时候请看文档 [Contribute UDF to Doris](http://doris.apache.org/master/zh-CN/extending-doris/contribute_udf.html)。 Review comment: ```suggestion 如果用户使用 UDF 功能并扩展了 Doris 的函数分析,并且希望将自己实现的 UDF 函数贡献回 Doris 社区给其他用户使用,这时候请看文档 [Contribute UDF](./contribute_udf.md)。 ``` ########## File path: docs/zh-CN/extending-doris/contribute_udf.md ########## @@ -0,0 +1,124 @@ +--- +{ + "title": "贡献用户 UDF 函数到社区", Review comment: 贡献 UDF ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org