This is an automated email from the ASF dual-hosted git repository.
lihaopeng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris-website.git
The following commit(s) were added to refs/heads/master by this push:
new a527ee71250 [doc](udf) update some doc about java-udf for UDWF (#2273)
a527ee71250 is described below
commit a527ee71250def74a08f65ed48eccd68ebe78651
Author: zhangstar333 <[email protected]>
AuthorDate: Tue Nov 11 17:02:48 2025 +0800
[doc](udf) update some doc about java-udf for UDWF (#2273)
## Versions
- [x] dev
- [x] 3.0
- [x] 2.1
- [ ] 2.0
## Languages
- [x] Chinese
- [x] English
## Docs Checklist
- [ ] Checked by AI
- [ ] Test Cases Built
---
docs/query-data/udf/java-user-defined-function.md | 37 +++++++++++++++++++--
.../query-data/udf/java-user-defined-function.md | 38 ++++++++++++++++++++--
.../query-data/udf/java-user-defined-function.md | 38 ++++++++++++++++++++--
.../query-data/udf/java-user-defined-function.md | 38 ++++++++++++++++++++--
.../query-data/udf/java-user-defined-function.md | 36 ++++++++++++++++++--
.../query-data/udf/java-user-defined-function.md | 37 +++++++++++++++++++--
.../query-data/udf/java-user-defined-function.md | 37 +++++++++++++++++++--
.../query-data/udf/java-user-defined-function.md | 37 +++++++++++++++++++--
8 files changed, 279 insertions(+), 19 deletions(-)
diff --git a/docs/query-data/udf/java-user-defined-function.md
b/docs/query-data/udf/java-user-defined-function.md
index c13d9fb25ff..927ecd9f3f2 100644
--- a/docs/query-data/udf/java-user-defined-function.md
+++ b/docs/query-data/udf/java-user-defined-function.md
@@ -1,6 +1,6 @@
---
{
-"title": "Java UDF, UDAF, UDTF",
+"title": "Java UDF, UDAF, UDWF, UDTF",
"language": "en"
}
---
@@ -13,7 +13,9 @@ Doris supports the use of Java to develop UDFs, UDAFs, and
UDTFs. Unless otherwi
2. Java UDAF: A Java UDAF is a user-defined aggregate function that aggregates
multiple input rows into a single output row. Common examples include MIN, MAX,
and COUNT.
-3. Java UDTF: A Java UDTF is a user-defined table function, where a single
input row can generate one or multiple output rows. In Doris, UDTFs must be
used with Lateral View to achieve row-to-column transformations. Common
examples include EXPLODE and EXPLODE_SPLIT. **Java UDTF is available from
version 3.0.0 and onwards.**
+3. Java UDWF: stands for User-Defined Window Function, which returns a
computed value for each row based on a window (one or multiple rows). Common
examples include ROW_NUMBER, RANK, and DENSE_RANK.
+
+4. Java UDTF: A Java UDTF is a user-defined table function, where a single
input row can generate one or multiple output rows. In Doris, UDTFs must be
used with Lateral View to achieve row-to-column transformations. Common
examples include EXPLODE and EXPLODE_SPLIT. **Java UDTF is available from
version 3.0.0 and onwards.**
## Type Correspondence
@@ -344,6 +346,37 @@ public class MedianUDAF {
+-----------------+
```
+### Introduction to Java-UDWF Example
+
+1. The implementation is similar to Java UDAF, but requires an additional
reset() method to clear the state.
+
+ ```JAVA
+ void reset(State state)
+ ```
+
+2. Register and create the Java-UDWF function same as UDAF in Doris. For more
syntax details, please refer to [CREATE
FUNCTION](../../sql-manual/sql-statements/function/CREATE-FUNCTION).
+
+ ```sql
+ CREATE AGGREGATE FUNCTION simple_demo_window(INT) RETURNS INT PROPERTIES (
+ "file"="file:///pathTo/java-udaf.jar",
+ "symbol"="org.apache.doris.udf.SimpleDemo",
+ "always_nullable"="true",
+ "type"="JAVA_UDF"
+ );
+ ```
+
+3. Java UDWF allows querying computed results within specific window frames.
For detailed syntax, refer to [Window Function](../window-function.md)
+
+ ```sql
+ select id, simple_demo_window(id) over(partition by id order by d1 rows
between 1 preceding and 1 following) as res from test_table;
+ +------+------+
+ | id | res |
+ +------+------+
+ | 1 | 1 |
+ | 6 | 6 |
+ +------+------+
+ ```
+
### Introduction to Java-UDTF Example
:::tip
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/query-data/udf/java-user-defined-function.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/query-data/udf/java-user-defined-function.md
index 14fb5a7d415..09988b33fbd 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/query-data/udf/java-user-defined-function.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/query-data/udf/java-user-defined-function.md
@@ -1,6 +1,6 @@
---
{
-"title": "Java UDF, UDAF, UDTF",
+"title": "Java UDF, UDAF, UDWF, UDTF",
"language": "zh-CN"
}
---
@@ -10,7 +10,8 @@ Java UDF 为用户提供使用 Java 编写 UDF 的接口,以方便用户使用
Doris 支持使用 JAVA 编写 UDF、UDAF 和 UDTF。下文如无特殊说明,使用 UDF 统称所有用户自定义函数。
1. Java UDF 是较为常见的自定义标量函数 (Scalar Function),即每输入一行数据,就会有一行对应的结果输出,较为常见的有
ABS,LENGTH 等。值得一提的是对于用户来讲,Hive UDF 是可以直接迁移至 Doris 的。
2. Java UDAF 即为自定义的聚合函数 (Aggregate Function),即在输入多行数据进行聚合后,仅输出一行对应的结果,较为常见的有
MIN,MAX,COUNT 等。
-3. JAVA UDTF 即为自定义的表函数 (Table Function),即每输一行数据,可以产生一行或多行的结果,在 Doris 中需要结合
Lateral View 使用可以达到行转列的效果,较为常见的有 EXPLODE,EXPLODE_SPLIT 等。**该功能自 Doris 3.0
版本起开始支持。**
+3. Java UDWF 即为自定义的窗口函数 (Window Function),它为每行返回的结果是在一个窗口内(一行或多行)计算的值,较为常见的有
ROW_NUMBER,RANK,DENSE_RANK 等。
+4. JAVA UDTF 即为自定义的表函数 (Table Function),即每输一行数据,可以产生一行或多行的结果,在 Doris 中需要结合
Lateral View 使用可以达到行转列的效果,较为常见的有 EXPLODE,EXPLODE_SPLIT 等。**该功能自 Doris 3.0
版本起开始支持。**
## 类型对应关系
@@ -303,7 +304,7 @@ public void destroy(State state) {
</details>
-2. 在 Doris 中注册创建 Java-UADF 函数。更多语法帮助可参阅 [CREATE
FUNCTION](../../sql-manual/sql-statements/function/CREATE-FUNCTION).
+2. 在 Doris 中注册创建 Java-UDAF 函数。更多语法帮助可参阅 [CREATE
FUNCTION](../../sql-manual/sql-statements/function/CREATE-FUNCTION).
```sql
CREATE AGGREGATE FUNCTION simple_demo(INT) RETURNS INT PROPERTIES (
@@ -335,6 +336,37 @@ public void destroy(State state) {
+-----------------+
```
+### Java-UDWF 实例介绍
+
+1. 首先编写对应的 Java UDWF 代码,打包生成 JAR 包,它与 Java UDAF 的代码编写是一致的,仅需要实现额外 reset
的接口,将所有的 state 状态置为初始值:
+
+ ```JAVA
+ void reset(State state)
+ ```
+
+2. 在 Doris 中注册创建 Java-UDWF 函数,与注册 Java-UDAF 一样。更多语法帮助可参阅 [CREATE
FUNCTION](../../sql-manual/sql-statements/function/CREATE-FUNCTION).
+
+ ```sql
+ CREATE AGGREGATE FUNCTION simple_demo_window(INT) RETURNS INT PROPERTIES (
+ "file"="file:///pathTo/java-udaf.jar",
+ "symbol"="org.apache.doris.udf.SimpleDemo",
+ "always_nullable"="true",
+ "type"="JAVA_UDF"
+ );
+ ```
+
+3. 使用 Java-UDWF, 可以查询在特定窗口内的计算结果,更多语法可以参考[窗口函数](../window-function.md):
+
+ ```sql
+ select id, simple_demo_window(id) over(partition by id order by d1 rows
between 1 preceding and 1 following) as res from test_table;
+ +------+------+
+ | id | res |
+ +------+------+
+ | 1 | 1 |
+ | 6 | 6 |
+ +------+------+
+ ```
+
### Java-UDTF 实例介绍
:::tip
UDTF 自 Doris 3.0 版本开始支持,
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/query-data/udf/java-user-defined-function.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/query-data/udf/java-user-defined-function.md
index 56a292de5ce..9b0a26f9340 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/query-data/udf/java-user-defined-function.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/query-data/udf/java-user-defined-function.md
@@ -1,6 +1,6 @@
---
{
-"title": "Java UDF, UDAF, UDTF",
+"title": "Java UDF, UDAF, UDWF, UDTF",
"language": "zh-CN"
}
---
@@ -10,7 +10,8 @@ Java UDF 为用户提供使用 Java 编写 UDF 的接口,以方便用户使用
Doris 支持使用 JAVA 编写 UDF、UDAF 和 UDTF。下文如无特殊说明,使用 UDF 统称所有用户自定义函数。
1. Java UDF 是较为常见的自定义标量函数 (Scalar Function),即每输入一行数据,就会有一行对应的结果输出,较为常见的有
ABS,LENGTH 等。值得一提的是对于用户来讲,Hive UDF 是可以直接迁移至 Doris 的。
2. Java UDAF 即为自定义的聚合函数 (Aggregate Function),即在输入多行数据进行聚合后,仅输出一行对应的结果,较为常见的有
MIN,MAX,COUNT 等。
-3. JAVA UDTF 即为自定义的表函数 (Table Function),即每输一行数据,可以产生一行或多行的结果,在 Doris 中需要结合
Lateral View 使用可以达到行转列的效果,较为常见的有 EXPLODE,EXPLODE_SPLIT 等。**该功能自 Doris 3.0
版本起开始支持。**
+3. Java UDWF 即为自定义的窗口函数 (Window Function),它为每行返回的结果是在一个窗口内(一行或多行)计算的值,较为常见的有
ROW_NUMBER,RANK,DENSE_RANK 等。
+4. JAVA UDTF 即为自定义的表函数 (Table Function),即每输一行数据,可以产生一行或多行的结果,在 Doris 中需要结合
Lateral View 使用可以达到行转列的效果,较为常见的有 EXPLODE,EXPLODE_SPLIT 等。**该功能自 Doris 3.0
版本起开始支持。**
## 类型对应关系
@@ -296,7 +297,7 @@ public void destroy(State state) {
</details>
-2. 在 Doris 中注册创建 Java-UADF 函数。更多语法帮助可参阅 [CREATE
FUNCTION](../../sql-manual/sql-statements/function/CREATE-FUNCTION).
+2. 在 Doris 中注册创建 Java-UDAF 函数。更多语法帮助可参阅 [CREATE
FUNCTION](../../sql-manual/sql-statements/function/CREATE-FUNCTION).
```sql
CREATE AGGREGATE FUNCTION simple_demo(INT) RETURNS INT PROPERTIES (
@@ -328,6 +329,37 @@ public void destroy(State state) {
+-----------------+
```
+### Java-UDWF 实例介绍
+
+1. 首先编写对应的 Java UDWF 代码,打包生成 JAR 包,它与 Java UDAF 的代码编写是一致的,仅需要实现额外 reset
的接口,将所有的 state 状态置为初始值:
+
+ ```JAVA
+ void reset(State state)
+ ```
+
+2. 在 Doris 中注册创建 Java-UDWF 函数,与注册 Java-UDAF 一样。更多语法帮助可参阅 [CREATE
FUNCTION](../../sql-manual/sql-statements/function/CREATE-FUNCTION).
+
+ ```sql
+ CREATE AGGREGATE FUNCTION simple_demo_window(INT) RETURNS INT PROPERTIES (
+ "file"="file:///pathTo/java-udaf.jar",
+ "symbol"="org.apache.doris.udf.SimpleDemo",
+ "always_nullable"="true",
+ "type"="JAVA_UDF"
+ );
+ ```
+
+3. 使用 Java-UDWF, 可以查询在特定窗口内的计算结果,更多语法可以参考[窗口函数](../window-function.md):
+
+ ```sql
+ select id, simple_demo_window(id) over(partition by id order by d1 rows
between 1 preceding and 1 following) as res from test_table;
+ +------+------+
+ | id | res |
+ +------+------+
+ | 1 | 1 |
+ | 6 | 6 |
+ +------+------+
+ ```
+
### Java-UDTF 实例介绍
:::tip
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/query-data/udf/java-user-defined-function.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/query-data/udf/java-user-defined-function.md
index 9ce68db2e67..66f313f3ccf 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/query-data/udf/java-user-defined-function.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.x/query-data/udf/java-user-defined-function.md
@@ -1,6 +1,6 @@
---
{
-"title": "Java UDF, UDAF, UDTF",
+"title": "Java UDF, UDAF, UDWF, UDTF",
"language": "zh-CN"
}
---
@@ -10,7 +10,8 @@ Java UDF 为用户提供使用 Java 编写 UDF 的接口,以方便用户使用
Doris 支持使用 JAVA 编写 UDF、UDAF 和 UDTF。下文如无特殊说明,使用 UDF 统称所有用户自定义函数。
1. Java UDF 是较为常见的自定义标量函数 (Scalar Function),即每输入一行数据,就会有一行对应的结果输出,较为常见的有
ABS,LENGTH 等。值得一提的是对于用户来讲,Hive UDF 是可以直接迁移至 Doris 的。
2. Java UDAF 即为自定义的聚合函数 (Aggregate Function),即在输入多行数据进行聚合后,仅输出一行对应的结果,较为常见的有
MIN,MAX,COUNT 等。
-3. JAVA UDTF 即为自定义的表函数 (Table Function),即每输一行数据,可以产生一行或多行的结果,在 Doris 中需要结合
Lateral View 使用可以达到行转列的效果,较为常见的有 EXPLODE,EXPLODE_SPLIT 等。**该功能自 Doris 3.0
版本起开始支持。**
+3. Java UDWF 即为自定义的窗口函数 (Window Function),它为每行返回的结果是在一个窗口内(一行或多行)计算的值,较为常见的有
ROW_NUMBER,RANK,DENSE_RANK 等。
+4. JAVA UDTF 即为自定义的表函数 (Table Function),即每输一行数据,可以产生一行或多行的结果,在 Doris 中需要结合
Lateral View 使用可以达到行转列的效果,较为常见的有 EXPLODE,EXPLODE_SPLIT 等。**该功能自 Doris 3.0
版本起开始支持。**
## 类型对应关系
@@ -302,7 +303,7 @@ public void destroy(State state) {
</details>
-2. 在 Doris 中注册创建 Java-UADF 函数。更多语法帮助可参阅 [CREATE
FUNCTION](../../sql-manual/sql-statements/function/CREATE-FUNCTION).
+2. 在 Doris 中注册创建 Java-UDAF 函数。更多语法帮助可参阅 [CREATE
FUNCTION](../../sql-manual/sql-statements/function/CREATE-FUNCTION).
```sql
CREATE AGGREGATE FUNCTION simple_demo(INT) RETURNS INT PROPERTIES (
@@ -334,6 +335,37 @@ public void destroy(State state) {
+-----------------+
```
+### Java-UDWF 实例介绍
+
+1. 首先编写对应的 Java UDWF 代码,打包生成 JAR 包,它与 Java UDAF 的代码编写是一致的,仅需要实现额外 reset
的接口,将所有的 state 状态置为初始值:
+
+ ```JAVA
+ void reset(State state)
+ ```
+
+2. 在 Doris 中注册创建 Java-UDWF 函数,与注册 Java-UDAF 一样。更多语法帮助可参阅 [CREATE
FUNCTION](../../sql-manual/sql-statements/function/CREATE-FUNCTION).
+
+ ```sql
+ CREATE AGGREGATE FUNCTION simple_demo_window(INT) RETURNS INT PROPERTIES (
+ "file"="file:///pathTo/java-udaf.jar",
+ "symbol"="org.apache.doris.udf.SimpleDemo",
+ "always_nullable"="true",
+ "type"="JAVA_UDF"
+ );
+ ```
+
+3. 使用 Java-UDWF, 可以查询在特定窗口内的计算结果,更多语法可以参考[窗口函数](../window-function.md):
+
+ ```sql
+ select id, simple_demo_window(id) over(partition by id order by d1 rows
between 1 preceding and 1 following) as res from test_table;
+ +------+------+
+ | id | res |
+ +------+------+
+ | 1 | 1 |
+ | 6 | 6 |
+ +------+------+
+ ```
+
### Java-UDTF 实例介绍
:::tip
UDTF 自 Doris 3.0 版本开始支持,
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/query-data/udf/java-user-defined-function.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/query-data/udf/java-user-defined-function.md
index 14fb5a7d415..43fcdddcc05 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/query-data/udf/java-user-defined-function.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/query-data/udf/java-user-defined-function.md
@@ -1,6 +1,6 @@
---
{
-"title": "Java UDF, UDAF, UDTF",
+"title": "Java UDF, UDAF, UDWF, UDTF",
"language": "zh-CN"
}
---
@@ -10,7 +10,8 @@ Java UDF 为用户提供使用 Java 编写 UDF 的接口,以方便用户使用
Doris 支持使用 JAVA 编写 UDF、UDAF 和 UDTF。下文如无特殊说明,使用 UDF 统称所有用户自定义函数。
1. Java UDF 是较为常见的自定义标量函数 (Scalar Function),即每输入一行数据,就会有一行对应的结果输出,较为常见的有
ABS,LENGTH 等。值得一提的是对于用户来讲,Hive UDF 是可以直接迁移至 Doris 的。
2. Java UDAF 即为自定义的聚合函数 (Aggregate Function),即在输入多行数据进行聚合后,仅输出一行对应的结果,较为常见的有
MIN,MAX,COUNT 等。
-3. JAVA UDTF 即为自定义的表函数 (Table Function),即每输一行数据,可以产生一行或多行的结果,在 Doris 中需要结合
Lateral View 使用可以达到行转列的效果,较为常见的有 EXPLODE,EXPLODE_SPLIT 等。**该功能自 Doris 3.0
版本起开始支持。**
+3. Java UDWF 即为自定义的窗口函数 (Window Function),它为每行返回的结果是在一个窗口内(一行或多行)计算的值,较为常见的有
ROW_NUMBER,RANK,DENSE_RANK 等。
+4. JAVA UDTF 即为自定义的表函数 (Table Function),即每输一行数据,可以产生一行或多行的结果,在 Doris 中需要结合
Lateral View 使用可以达到行转列的效果,较为常见的有 EXPLODE,EXPLODE_SPLIT 等。**该功能自 Doris 3.0
版本起开始支持。**
## 类型对应关系
@@ -335,6 +336,37 @@ public void destroy(State state) {
+-----------------+
```
+### Java-UDWF 实例介绍
+
+1. 首先编写对应的 Java UDWF 代码,打包生成 JAR 包,它与 Java UDAF 的代码编写是一致的,仅需要实现额外 reset
的接口,将所有的 state 状态置为初始值:
+
+ ```JAVA
+ void reset(State state)
+ ```
+
+2. 在 Doris 中注册创建 Java-UDWF 函数,与注册 Java-UDAF 一样。更多语法帮助可参阅 [CREATE
FUNCTION](../../sql-manual/sql-statements/function/CREATE-FUNCTION).
+
+ ```sql
+ CREATE AGGREGATE FUNCTION simple_demo_window(INT) RETURNS INT PROPERTIES (
+ "file"="file:///pathTo/java-udaf.jar",
+ "symbol"="org.apache.doris.udf.SimpleDemo",
+ "always_nullable"="true",
+ "type"="JAVA_UDF"
+ );
+ ```
+
+3. 使用 Java-UDWF, 可以查询在特定窗口内的计算结果,更多语法可以参考[窗口函数](../window-function.md):
+
+ ```sql
+ select id, simple_demo_window(id) over(partition by id order by d1 rows
between 1 preceding and 1 following) as res from test_table;
+ +------+------+
+ | id | res |
+ +------+------+
+ | 1 | 1 |
+ | 6 | 6 |
+ +------+------+
+ ```
+
### Java-UDTF 实例介绍
:::tip
UDTF 自 Doris 3.0 版本开始支持,
diff --git
a/versioned_docs/version-2.1/query-data/udf/java-user-defined-function.md
b/versioned_docs/version-2.1/query-data/udf/java-user-defined-function.md
index 7523281755d..480c7f11e51 100644
--- a/versioned_docs/version-2.1/query-data/udf/java-user-defined-function.md
+++ b/versioned_docs/version-2.1/query-data/udf/java-user-defined-function.md
@@ -1,6 +1,6 @@
---
{
-"title": "Java UDF, UDAF, UDTF",
+"title": "Java UDF, UDAF, UDWF, UDTF",
"language": "en"
}
---
@@ -13,7 +13,9 @@ Doris supports the use of Java to develop UDFs, UDAFs, and
UDTFs. Unless otherwi
2. Java UDAF: A Java UDAF is a user-defined aggregate function that aggregates
multiple input rows into a single output row. Common examples include MIN, MAX,
and COUNT.
-3. Java UDTF: A Java UDTF is a user-defined table function, where a single
input row can generate one or multiple output rows. In Doris, UDTFs must be
used with Lateral View to achieve row-to-column transformations. Common
examples include EXPLODE and EXPLODE_SPLIT. **Java UDTF is available from
version 3.0.0 and onwards.**
+3. Java UDWF: stands for User-Defined Window Function, which returns a
computed value for each row based on a window (one or multiple rows). Common
examples include ROW_NUMBER, RANK, and DENSE_RANK.
+
+4. Java UDTF: A Java UDTF is a user-defined table function, where a single
input row can generate one or multiple output rows. In Doris, UDTFs must be
used with Lateral View to achieve row-to-column transformations. Common
examples include EXPLODE and EXPLODE_SPLIT. **Java UDTF is available from
version 3.0.0 and onwards.**
## Type Correspondence
@@ -336,6 +338,37 @@ public class MedianUDAF {
+-----------------+
```
+### Introduction to Java-UDWF Example
+
+1. The implementation is similar to Java UDAF, but requires an additional
reset() method to clear the state.
+
+ ```JAVA
+ void reset(State state)
+ ```
+
+2. Register and create the Java-UDWF function same as UDAF in Doris. For more
syntax details, please refer to [CREATE
FUNCTION](../../sql-manual/sql-statements/function/CREATE-FUNCTION).
+
+ ```sql
+ CREATE AGGREGATE FUNCTION simple_demo_window(INT) RETURNS INT PROPERTIES (
+ "file"="file:///pathTo/java-udaf.jar",
+ "symbol"="org.apache.doris.udf.SimpleDemo",
+ "always_nullable"="true",
+ "type"="JAVA_UDF"
+ );
+ ```
+
+3. Java UDWF allows querying computed results within specific window frames.
For detailed syntax, refer to [Window Function](../window-function.md)
+
+ ```sql
+ select id, simple_demo_window(id) over(partition by id order by d1 rows
between 1 preceding and 1 following) as res from test_table;
+ +------+------+
+ | id | res |
+ +------+------+
+ | 1 | 1 |
+ | 6 | 6 |
+ +------+------+
+ ```
+
### Introduction to Java-UDTF Example
:::tip
diff --git
a/versioned_docs/version-3.x/query-data/udf/java-user-defined-function.md
b/versioned_docs/version-3.x/query-data/udf/java-user-defined-function.md
index eb6a414efdb..61e1e1b82ff 100644
--- a/versioned_docs/version-3.x/query-data/udf/java-user-defined-function.md
+++ b/versioned_docs/version-3.x/query-data/udf/java-user-defined-function.md
@@ -1,6 +1,6 @@
---
{
-"title": "Java UDF, UDAF, UDTF",
+"title": "Java UDF, UDAF, UDWF, UDTF",
"language": "en"
}
---
@@ -13,7 +13,9 @@ Doris supports the use of Java to develop UDFs, UDAFs, and
UDTFs. Unless otherwi
2. Java UDAF: A Java UDAF is a user-defined aggregate function that aggregates
multiple input rows into a single output row. Common examples include MIN, MAX,
and COUNT.
-3. Java UDTF: A Java UDTF is a user-defined table function, where a single
input row can generate one or multiple output rows. In Doris, UDTFs must be
used with Lateral View to achieve row-to-column transformations. Common
examples include EXPLODE and EXPLODE_SPLIT. **Java UDTF is available from
version 3.0.0 and onwards.**
+3. Java UDWF: stands for User-Defined Window Function, which returns a
computed value for each row based on a window (one or multiple rows). Common
examples include ROW_NUMBER, RANK, and DENSE_RANK.
+
+4. Java UDTF: A Java UDTF is a user-defined table function, where a single
input row can generate one or multiple output rows. In Doris, UDTFs must be
used with Lateral View to achieve row-to-column transformations. Common
examples include EXPLODE and EXPLODE_SPLIT. **Java UDTF is available from
version 3.0.0 and onwards.**
## Type Correspondence
@@ -343,6 +345,37 @@ public class MedianUDAF {
+-----------------+
```
+### Introduction to Java-UDWF Example
+
+1. The implementation is similar to Java UDAF, but requires an additional
reset() method to clear the state.
+
+ ```JAVA
+ void reset(State state)
+ ```
+
+2. Register and create the Java-UDWF function same as UDAF in Doris. For more
syntax details, please refer to [CREATE
FUNCTION](../../sql-manual/sql-statements/function/CREATE-FUNCTION).
+
+ ```sql
+ CREATE AGGREGATE FUNCTION simple_demo_window(INT) RETURNS INT PROPERTIES (
+ "file"="file:///pathTo/java-udaf.jar",
+ "symbol"="org.apache.doris.udf.SimpleDemo",
+ "always_nullable"="true",
+ "type"="JAVA_UDF"
+ );
+ ```
+
+3. Java UDWF allows querying computed results within specific window frames.
For detailed syntax, refer to [Window Function](../window-function.md)
+
+ ```sql
+ select id, simple_demo_window(id) over(partition by id order by d1 rows
between 1 preceding and 1 following) as res from test_table;
+ +------+------+
+ | id | res |
+ +------+------+
+ | 1 | 1 |
+ | 6 | 6 |
+ +------+------+
+ ```
+
### Introduction to Java-UDTF Example
:::tip
diff --git
a/versioned_docs/version-4.x/query-data/udf/java-user-defined-function.md
b/versioned_docs/version-4.x/query-data/udf/java-user-defined-function.md
index c13d9fb25ff..b8b681392ac 100644
--- a/versioned_docs/version-4.x/query-data/udf/java-user-defined-function.md
+++ b/versioned_docs/version-4.x/query-data/udf/java-user-defined-function.md
@@ -1,6 +1,6 @@
---
{
-"title": "Java UDF, UDAF, UDTF",
+"title": "Java UDF, UDAF, UDWF, UDTF",
"language": "en"
}
---
@@ -13,7 +13,9 @@ Doris supports the use of Java to develop UDFs, UDAFs, and
UDTFs. Unless otherwi
2. Java UDAF: A Java UDAF is a user-defined aggregate function that aggregates
multiple input rows into a single output row. Common examples include MIN, MAX,
and COUNT.
-3. Java UDTF: A Java UDTF is a user-defined table function, where a single
input row can generate one or multiple output rows. In Doris, UDTFs must be
used with Lateral View to achieve row-to-column transformations. Common
examples include EXPLODE and EXPLODE_SPLIT. **Java UDTF is available from
version 3.0.0 and onwards.**
+3. Java UDWF: stands for User-Defined Window Function, which returns a
computed value for each row based on a window (one or multiple rows). Common
examples include ROW_NUMBER, RANK, and DENSE_RANK.
+
+4. Java UDTF: A Java UDTF is a user-defined table function, where a single
input row can generate one or multiple output rows. In Doris, UDTFs must be
used with Lateral View to achieve row-to-column transformations. Common
examples include EXPLODE and EXPLODE_SPLIT. **Java UDTF is available from
version 3.0.0 and onwards.**
## Type Correspondence
@@ -346,6 +348,37 @@ public class MedianUDAF {
### Introduction to Java-UDTF Example
+### Introduction to Java-UDWF Example
+
+1. The implementation is similar to Java UDAF, but requires an additional
reset() method to clear the state.
+
+ ```JAVA
+ void reset(State state)
+ ```
+
+2. Register and create the Java-UDWF function same as UDAF in Doris. For more
syntax details, please refer to [CREATE
FUNCTION](../../sql-manual/sql-statements/function/CREATE-FUNCTION).
+
+ ```sql
+ CREATE AGGREGATE FUNCTION simple_demo_window(INT) RETURNS INT PROPERTIES (
+ "file"="file:///pathTo/java-udaf.jar",
+ "symbol"="org.apache.doris.udf.SimpleDemo",
+ "always_nullable"="true",
+ "type"="JAVA_UDF"
+ );
+ ```
+
+3. Java UDWF allows querying computed results within specific window frames.
For detailed syntax, refer to [Window Function](../window-function.md)
+
+ ```sql
+ select id, simple_demo_window(id) over(partition by id order by d1 rows
between 1 preceding and 1 following) as res from test_table;
+ +------+------+
+ | id | res |
+ +------+------+
+ | 1 | 1 |
+ | 6 | 6 |
+ +------+------+
+ ```
+
:::tip
UDTF is supported starting from Doris version 3.0.
:::
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]