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

gabriellee pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 55cae6202f [typo](docs)add udf doc and optimize udf regression test 
(#14000)
55cae6202f is described below

commit 55cae6202fd01464edb6674b71560c14a599d0d5
Author: Liqf <[email protected]>
AuthorDate: Thu Nov 10 09:24:45 2022 +0800

    [typo](docs)add udf doc and optimize udf regression test (#14000)
---
 .../ecosystem/udf/java-user-defined-function.md    |  7 +++---
 .../ecosystem/udf/java-user-defined-function.md    |  9 +++----
 .../{DateWindowRollup.java => DateCaseTest.java}   | 26 +++++++-------------
 .../suites/javaudf_p0/test_javaudf_case.groovy     | 14 +++++------
 .../{DateWindowRollup.java => DateCaseTest.java}   | 28 ++++++++--------------
 5 files changed, 35 insertions(+), 49 deletions(-)

diff --git a/docs/en/docs/ecosystem/udf/java-user-defined-function.md 
b/docs/en/docs/ecosystem/udf/java-user-defined-function.md
index aff3c7874f..b2f3572d73 100644
--- a/docs/en/docs/ecosystem/udf/java-user-defined-function.md
+++ b/docs/en/docs/ecosystem/udf/java-user-defined-function.md
@@ -176,8 +176,9 @@ When you no longer need UDF functions, you can delete a UDF 
function by the foll
 ## Example
 Examples of Java UDF are provided in the `samples/doris-demo/java-udf-demo/` 
directory. See the `README.md` in each directory for details on how to use it, 
Check it out 
[here](https://github.com/apache/incubator-doris/tree/master/samples/doris-demo/java-udf-demo)
 
-## Unsupported Use Case
-At present, Java UDF is still in the process of continuous development, so 
some features are **not completed**.
+## Instructions
 1. Complex data types (HLL, bitmap) are not supported.
-2. Memory management and statistics of JVM and Doris have not been unified.
+2. Currently, users are allowed to specify the maximum heap size of the JVM 
themselves. The configuration item is jvm_ max_ heap_ size.
+3. The udf of char type needs to use the String type when creating a function.
+4. Due to the problem that the jvm loads classes with the same name, do not 
use multiple classes with the same name as udf implementations at the same 
time. If you want to update the udf of a class with the same name, you need to 
restart be to reload the classpath.
 
diff --git a/docs/zh-CN/docs/ecosystem/udf/java-user-defined-function.md 
b/docs/zh-CN/docs/ecosystem/udf/java-user-defined-function.md
index 8cb870cc0b..41d91e6b38 100644
--- a/docs/zh-CN/docs/ecosystem/udf/java-user-defined-function.md
+++ b/docs/zh-CN/docs/ecosystem/udf/java-user-defined-function.md
@@ -175,8 +175,9 @@ UDF 的使用与普通的函数方式一致,唯一的区别在于,内置函
 ## 示例
 在`samples/doris-demo/java-udf-demo/` 
目录中提供了具体示例。具体使用方法见每个目录下的`README.md`,查看点击[这里](https://github.com/apache/incubator-doris/tree/master/samples/doris-demo/java-udf-demo)
 
-## 暂不支持的场景
-当前Java UDF仍然处在持续的开发过程中,所以部分功能**尚不完善**。包括:
-1. 不支持复杂数据类型(HLL,Bitmap)
-2. 尚未统一JVM和Doris的内存管理以及统计信息
+## 使用须知
+1. 不支持复杂数据类型(HLL,Bitmap)。
+2. 当前允许用户自己指定JVM最大堆大小,配置项是jvm_max_heap_size。
+3. char类型的udf在create function时需要使用String类型。
+4. 由于jvm加载同名类的问题,不要同时使用多个同名类作为udf实现,如果想更新某个同名类的udf,需要重启be重新加载classpath。
 
diff --git 
a/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/DateWindowRollup.java
 
b/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/DateCaseTest.java
similarity index 63%
rename from 
regression-test/java-udf-src/src/main/java/org/apache/doris/udf/DateWindowRollup.java
rename to 
regression-test/java-udf-src/src/main/java/org/apache/doris/udf/DateCaseTest.java
index 2dd44b651a..8e4d4f4972 100644
--- 
a/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/DateWindowRollup.java
+++ 
b/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/DateCaseTest.java
@@ -23,30 +23,22 @@ import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.List;
 
-public class DateWindowRollup extends UDF {
+public class DateCaseTest extends UDF {
 
-    /**
-     * @param startTime yyyy-MM-dd
-     * @param start    从startTime 前-start天
-     * @param end      至startTime 前-end天
-     * @return ${yyyy-MM-dd}+end 
,${yyyy-MM-dd}+(end+1),...,${yyyy-MM-dd}+(start)
-     */
-    public String evaluate(LocalDate startTime, Integer start, Integer end)  {
-        if (startTime == null || start == null || end == null){
+    public String evaluate(LocalDate startDate, Integer start, Integer end)  {
+        if (startDate == null || start == null || end == null){
             return null;
         }
         DateTimeFormatter formatter = 
DateTimeFormatter.ofPattern("yyyy-MM-dd");
         LocalDate yesterday = LocalDate.now().minusDays(1);
-        List<String> ret = new ArrayList<>();
+        List<String> result = new ArrayList<>();
         for (int i = start; i <= end - 1; i++) {
-            LocalDate groupDate = startTime.plusDays(i);
-            if (groupDate.isAfter(yesterday)) {
-                break;
-            }
-            String dateFormat = formatter.format(groupDate);
-            ret.add(dateFormat);
+            LocalDate oneDate = startDate.plusDays(i);
+            if (oneDate.isAfter(yesterday)) break;
+            String dateString = formatter.format(oneDate);
+            result.add(dateString);
         }
-        return String.join(",", ret);
+        return String.join(",", result);
     }
 
 }
diff --git a/regression-test/suites/javaudf_p0/test_javaudf_case.groovy 
b/regression-test/suites/javaudf_p0/test_javaudf_case.groovy
index fd7e5d0178..2e5d87747a 100644
--- a/regression-test/suites/javaudf_p0/test_javaudf_case.groovy
+++ b/regression-test/suites/javaudf_p0/test_javaudf_case.groovy
@@ -22,7 +22,7 @@ import java.nio.file.Files
 import java.nio.file.Paths
 
 suite("test_javaudf_case") {
-    def tableName = "test_javaudf_dateWindowRollup"
+    def tableName = "test_javaudf_datecasetest"
     def jarPath = 
"""${context.file.parent}/jars/java-udf-case-jar-with-dependencies.jar"""
 
     log.info("Jar path: ${jarPath}".toString())
@@ -50,18 +50,18 @@ suite("test_javaudf_case") {
             throw new IllegalStateException("""${jarPath} doesn't exist! """)
         }
 
-        sql """ CREATE FUNCTION java_udf_dateWindowRollup_test(date,int,int) 
RETURNS String PROPERTIES (
+        sql """ CREATE FUNCTION java_udf_dateCase_test(date,int,int) RETURNS 
String PROPERTIES (
             "file"="file://${jarPath}",
-            "symbol"="org.apache.doris.udf.DateWindowRollup",
+            "symbol"="org.apache.doris.udf.DateCaseTest",
             "type"="JAVA_UDF"
         ); """
 
-        qt_select """ SELECT java_udf_dateWindowRollup_test("2022-10-24",-7,0) 
as result; """
-        qt_select """ SELECT java_udf_dateWindowRollup_test(null,-7,0) as 
result ; """
-        qt_select """ SELECT 
starttime,java_udf_dateWindowRollup_test(starttime,start,end) as sum FROM 
${tableName} order by starttime; """
+        qt_select """ SELECT java_udf_dateCase_test("2022-10-24",-7,0) as 
result; """
+        qt_select """ SELECT java_udf_dateCase_test(null,-7,0) as result ; """
+        qt_select """ SELECT 
starttime,java_udf_dateCase_test(starttime,start,end) as sum FROM ${tableName} 
order by starttime; """
         
 
-        sql """ DROP FUNCTION java_udf_dateWindowRollup_test(date,int,int); """
+        sql """ DROP FUNCTION java_udf_dateCase_test(date,int,int); """
     } finally {
         try_sql("DROP TABLE IF EXISTS ${tableName}")
     }
diff --git 
a/samples/doris-demo/java-udf-demo/src/main/java/org/apache/doris/udf/DateWindowRollup.java
 
b/samples/doris-demo/java-udf-demo/src/main/java/org/apache/doris/udf/DateCaseTest.java
similarity index 64%
rename from 
samples/doris-demo/java-udf-demo/src/main/java/org/apache/doris/udf/DateWindowRollup.java
rename to 
samples/doris-demo/java-udf-demo/src/main/java/org/apache/doris/udf/DateCaseTest.java
index 76bb2c0e75..e3c42d81f4 100644
--- 
a/samples/doris-demo/java-udf-demo/src/main/java/org/apache/doris/udf/DateWindowRollup.java
+++ 
b/samples/doris-demo/java-udf-demo/src/main/java/org/apache/doris/udf/DateCaseTest.java
@@ -25,30 +25,22 @@ import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.List;
 
-public class DateWindowRollup extends UDF {
+public class DateCaseTest extends UDF {
 
-    /**
-     * @param startTime yyyy-MM-dd
-     * @param start    从startTime 前-start天
-     * @param end      至startTime 前-end天
-     * @return ${yyyy-MM-dd}+end 
,${yyyy-MM-dd}+(end+1),...,${yyyy-MM-dd}+(start)
-     */
-    public String evaluate(LocalDate startTime, Integer start, Integer end)  {
-        if (startTime == null || start == null || end == null){
+    public String evaluate(LocalDate startDate, Integer start, Integer end)  {
+        if (startDate == null || start == null || end == null){
             return null;
         }
         DateTimeFormatter formatter = 
DateTimeFormatter.ofPattern("yyyy-MM-dd");
         LocalDate yesterday = LocalDate.now().minusDays(1);
-        List<String> ret = new ArrayList<>();
+        List<String> result = new ArrayList<>();
         for (int i = start; i <= end - 1; i++) {
-            LocalDate groupDate = startTime.plusDays(i);
-            if (groupDate.isAfter(yesterday)) {
-                break;
-            }
-            String dateFormat = formatter.format(groupDate);
-            ret.add(dateFormat);
+            LocalDate oneDate = startDate.plusDays(i);
+            if (oneDate.isAfter(yesterday)) break;
+            String dateString = formatter.format(oneDate);
+            result.add(dateString);
         }
-        return String.join(",", ret);
+        return String.join(",", result);
     }
 
-}
\ No newline at end of file
+}


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

Reply via email to