This is an automated email from the ASF dual-hosted git repository.

luzhijing 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 04090bdf1e [doc](java-udtf) support java-udtf (#569)
04090bdf1e is described below

commit 04090bdf1e01d612b2b3f92676e1e14157ab9c84
Author: zhangstar333 <[email protected]>
AuthorDate: Tue Apr 23 10:10:05 2024 +0800

    [doc](java-udtf) support java-udtf (#569)
---
 docs/ecosystem/udf/java-user-defined-function.md   | 39 ++++++++++++++++++++-
 .../ecosystem/udf/java-user-defined-function.md    | 40 +++++++++++++++++++++-
 .../ecosystem/udf/java-user-defined-function.md    | 38 +++++++++++++++++++-
 .../ecosystem/udf/java-user-defined-function.md    | 39 ++++++++++++++++++++-
 4 files changed, 152 insertions(+), 4 deletions(-)

diff --git a/docs/ecosystem/udf/java-user-defined-function.md 
b/docs/ecosystem/udf/java-user-defined-function.md
index 1a95274b7f..eaf2e2f9b4 100644
--- a/docs/ecosystem/udf/java-user-defined-function.md
+++ b/docs/ecosystem/udf/java-user-defined-function.md
@@ -92,6 +92,15 @@ Instructions:
 5. `name`: A function belongs to a DB and name is of the 
form`dbName`.`funcName`. When `dbName` is not explicitly specified, the db of 
the current session is used`dbName`.
 
 Sample:
+
+```JAVA
+public class AddOne extends UDF {
+    public Integer evaluate(Integer value) {
+        return value == null ? null : value + 1;
+    }
+}
+```
+
 ```sql
 CREATE FUNCTION java_udf_add_one(int) RETURNS int PROPERTIES (
     "file"="file:///path/to/java-udf-demo-jar-with-dependencies.jar",
@@ -324,11 +333,39 @@ CREATE AGGREGATE FUNCTION middle_quantiles(DOUBLE,INT) 
RETURNS DOUBLE PROPERTIES
 );
 ```
 
+<version since="2.1">
+
+## Create UDTF
+<br/>
+UDTF functions, like UDF functions, require users to implement an `evaluate` 
method. However, the return value of a UDTF function must be of Array type.
+Additionally, in Doris, table functions behave differently depending on the 
_outer suffix. You can refer to the 
[OUTER-Combinator](../sql-manual/sql-functions/table-functions/explode-numbers-outer)
+
+```JAVA
+public class UDTFStringTest {
+    public ArrayList<String> evaluate(String value, String separator) {
+        if (value == null || separator == null) {
+            return null;
+        } else {
+            return new ArrayList<>(Arrays.asList(value.split(separator)));
+        }
+    }
+}
+```
+
+```sql
+CREATE TABLES FUNCTION java-utdf(string, string) RETURNS array<string> 
PROPERTIES (
+    "file"="file:///pathTo/java-udaf.jar",
+    "symbol"="org.apache.doris.udf.demo.UDTFStringTest",
+    "always_nullable"="true",
+    "type"="JAVA_UDF"
+);
+```
+
+<br/>
 
 * The implemented jar package can be stored at local or in a remote server and 
downloaded via http, And each BE node must be able to obtain the jar package;
 Otherwise, the error status message "Couldn't open file..." will be returned
 
-Currently, UDTF are not supported.
 
 <br/>
 
diff --git 
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/ecosystem/udf/java-user-defined-function.md
 
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/ecosystem/udf/java-user-defined-function.md
index 61cb0aff6f..ae0e35d61a 100644
--- 
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/ecosystem/udf/java-user-defined-function.md
+++ 
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/ecosystem/udf/java-user-defined-function.md
@@ -89,6 +89,15 @@ PROPERTIES (["key"="value"][,...])
 5. name: 
一个function是要归属于某个DB的,name的形式为`dbName`.`funcName`。当`dbName`没有明确指定的时候,就是使用当前session所在的db作为`dbName`。
 
 示例:
+
+```JAVA
+public class AddOne extends UDF {
+    public Integer evaluate(Integer value) {
+        return value == null ? null : value + 1;
+    }
+}
+```
+
 ```sql
 CREATE FUNCTION java_udf_add_one(int) RETURNS int PROPERTIES (
     "file"="file:///path/to/java-udf-demo-jar-with-dependencies.jar",
@@ -324,11 +333,40 @@ CREATE AGGREGATE FUNCTION middle_quantiles(DOUBLE,INT) 
RETURNS DOUBLE PROPERTIES
 );
 ```
 
+<version since="2.1">
+
+## 编写 UDTF 函数
+<br/>
+UDTF 和 UDF 函数一样,需要用户自主实现一个 `evaluate` 方法, 但是 UDTF 函数的返回值必须是 Array 类型。
+另外Doris中表函数会因为 _outer 后缀有不同的表现,可查看[OUTER 
组合器](../sql-manual/sql-functions/table-functions/explode-numbers-outer)
+
+
+```JAVA
+public class UDTFStringTest {
+    public ArrayList<String> evaluate(String value, String separator) {
+        if (value == null || separator == null) {
+            return null;
+        } else {
+            return new ArrayList<>(Arrays.asList(value.split(separator)));
+        }
+    }
+}
+```
+
+```sql
+CREATE TABLES FUNCTION java-utdf(string, string) RETURNS array<string> 
PROPERTIES (
+    "file"="file:///pathTo/java-udaf.jar",
+    "symbol"="org.apache.doris.udf.demo.UDTFStringTest",
+    "always_nullable"="true",
+    "type"="JAVA_UDF"
+);
+```
+
+<br/>
 
 * 实现的jar包可以放在本地也可以存放在远程服务端通过http下载,但必须让每个BE节点都能获取到jar包;
 否则将会返回错误状态信息"Couldn't open file ......".
 
-目前还暂不支持UDTF
 
 <br/>
 
diff --git 
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/ecosystem/udf/java-user-defined-function.md
 
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/ecosystem/udf/java-user-defined-function.md
index 61cb0aff6f..341778344e 100644
--- 
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/ecosystem/udf/java-user-defined-function.md
+++ 
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/ecosystem/udf/java-user-defined-function.md
@@ -74,6 +74,14 @@ Java UDF 为用户提供UDF编写的Java接口,以方便用户使用Java语言
 
 ## 创建 UDF
 
+```JAVA
+public class AddOne extends UDF {
+    public Integer evaluate(Integer value) {
+        return value == null ? null : value + 1;
+    }
+}
+```
+
 ```sql
 CREATE FUNCTION 
 name ([,...])
@@ -324,11 +332,39 @@ CREATE AGGREGATE FUNCTION middle_quantiles(DOUBLE,INT) 
RETURNS DOUBLE PROPERTIES
 );
 ```
 
+<version since="2.1">
+
+## 编写 UDTF 函数
+<br/>
+UDTF 和 UDF 函数一样,需要用户自主实现一个 `evaluate` 方法, 但是 UDTF 函数的返回值必须是 Array 类型。
+另外Doris中表函数会因为 _outer 后缀有不同的表现,可查看[OUTER 
组合器](../sql-manual/sql-functions/table-functions/explode-numbers-outer)
+
+```JAVA
+public class UDTFStringTest {
+    public ArrayList<String> evaluate(String value, String separator) {
+        if (value == null || separator == null) {
+            return null;
+        } else {
+            return new ArrayList<>(Arrays.asList(value.split(separator)));
+        }
+    }
+}
+```
+
+```sql
+CREATE TABLES FUNCTION java-utdf(string, string) RETURNS array<string> 
PROPERTIES (
+    "file"="file:///pathTo/java-udaf.jar",
+    "symbol"="org.apache.doris.udf.demo.UDTFStringTest",
+    "always_nullable"="true",
+    "type"="JAVA_UDF"
+);
+```
+
+<br/>
 
 * 实现的jar包可以放在本地也可以存放在远程服务端通过http下载,但必须让每个BE节点都能获取到jar包;
 否则将会返回错误状态信息"Couldn't open file ......".
 
-目前还暂不支持UDTF
 
 <br/>
 
diff --git 
a/versioned_docs/version-2.1/ecosystem/udf/java-user-defined-function.md 
b/versioned_docs/version-2.1/ecosystem/udf/java-user-defined-function.md
index 1a95274b7f..a3bf666258 100644
--- a/versioned_docs/version-2.1/ecosystem/udf/java-user-defined-function.md
+++ b/versioned_docs/version-2.1/ecosystem/udf/java-user-defined-function.md
@@ -77,6 +77,14 @@ It is worth mentioning that this example is not only the 
Java UDF supported by D
 
 ## Create UDF
 
+```JAVA
+ public class AddOne extends UDF {
+     public Integer evaluate(Integer value) {
+         return value == null ? null : value + 1;
+     }
+ }
+ ```
+
 ```sql
 CREATE FUNCTION 
 name ([,...])
@@ -324,11 +332,40 @@ CREATE AGGREGATE FUNCTION middle_quantiles(DOUBLE,INT) 
RETURNS DOUBLE PROPERTIES
 );
 ```
 
+<version since="2.1">
+
+## Create UDTF
+<br/>
+UDTF functions, like UDF functions, require users to implement an `evaluate` 
method. However, the return value of a UDTF function must be of Array type.
+Additionally, in Doris, table functions behave differently depending on the 
_outer suffix. You can refer to the 
[OUTER-Combinator](../sql-manual/sql-functions/table-functions/explode-numbers-outer)
+
+```JAVA
+public class UDTFStringTest {
+    public ArrayList<String> evaluate(String value, String separator) {
+        if (value == null || separator == null) {
+            return null;
+        } else {
+            return new ArrayList<>(Arrays.asList(value.split(separator)));
+        }
+    }
+}
+```
+
+```sql
+CREATE TABLES FUNCTION java-utdf(string, string) RETURNS array<string> 
PROPERTIES (
+    "file"="file:///pathTo/java-udaf.jar",
+    "symbol"="org.apache.doris.udf.demo.UDTFStringTest",
+    "always_nullable"="true",
+    "type"="JAVA_UDF"
+);
+```
+
+<br/>
 
 * The implemented jar package can be stored at local or in a remote server and 
downloaded via http, And each BE node must be able to obtain the jar package;
 Otherwise, the error status message "Couldn't open file..." will be returned
 
-Currently, UDTF are not supported.
+
 
 <br/>
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to