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 1713af6cd6 [test](java udf)add new java udf case (#14653)
1713af6cd6 is described below

commit 1713af6cd63d636d2e6adc248d1b0352359b4072
Author: lsy3993 <[email protected]>
AuthorDate: Tue Nov 29 16:43:53 2022 +0800

    [test](java udf)add new java udf case (#14653)
---
 .../javaudf_p0/collect/test_javaudf_groupcount.out |   6 ++
 .../collect/test_javaudf_murmurhash3.out           |   6 ++
 .../javaudf_p0/collect/test_javaudf_sessionize.out |   5 +
 .../data/javaudf_p0/date/test_javaudf_adddays.out  |   6 ++
 .../javaudf_p0/date/test_javaudf_addisoperioud.out |   6 ++
 .../data/javaudf_p0/date/test_javaudf_daydiff.out  |   5 +
 .../json/test_javaudf_convertfromcamelcase.out     |   5 +
 .../json/test_javaudf_converttocamelcase.out       |   5 +
 .../javaudf_p0/sanity/test_javaudf_assertequal.out |   4 +
 .../sanity/test_javaudf_assertlessthan.out         |   5 +
 .../javaudf_p0/sanity/test_javaudf_assertudf.out   |   4 +
 .../data/javaudf_p0/sketch/test_javaudf_md5.out    |   5 +
 .../apache/doris/udf/collect/GroupCountUDF.java    |  70 ++++++++++++++
 .../apache/doris/udf/collect/MurmurHash3UDF.java   | 105 +++++++++++++++++++++
 .../apache/doris/udf/collect/SessionizeUDF.java    |  53 +++++++++++
 .../java/org/apache/doris/udf/date/AddDaysUDF.java |  44 +++++++++
 .../org/apache/doris/udf/date/AddISOPeriodUDF.java |  58 ++++++++++++
 .../java/org/apache/doris/udf/date/DayDiffUDF.java |  54 +++++++++++
 .../doris/udf/json/ConvertFromCamelCaseUDF.java    |  48 ++++++++++
 .../doris/udf/json/ConvertToCamelCaseUDF.java      |  53 +++++++++++
 .../apache/doris/udf/sanity/AssertEqualsUDF.java   |  39 ++++++++
 .../apache/doris/udf/sanity/AssertLessThanUDF.java |  39 ++++++++
 .../org/apache/doris/udf/sanity/AssertUDF.java     |  45 +++++++++
 .../main/java/org/apache/doris/udf/sketch/Md5.java |  53 +++++++++++
 .../collect/test_javaudf_groupcount.groovy         |  58 ++++++++++++
 .../collect/test_javaudf_murmurhash3.groovy        |  58 ++++++++++++
 .../collect/test_javaudf_sessionize.groovy         |  61 ++++++++++++
 .../javaudf_p0/date/test_javaudf_adddays.groovy    |  58 ++++++++++++
 .../date/test_javaudf_addisoperioud.groovy         |  58 ++++++++++++
 .../javaudf_p0/date/test_javaudf_daydiff.groovy    |  59 ++++++++++++
 .../json/test_javaudf_convertfromcamelcase.groovy  |  58 ++++++++++++
 .../json/test_javaudf_converttocamelcase.groovy    |  58 ++++++++++++
 .../sanity/test_javaudf_assertequal.groovy         |  60 ++++++++++++
 .../sanity/test_javaudf_assertlessthan.groovy      |  60 ++++++++++++
 .../sanity/test_javaudf_assertudf.groovy           |  50 ++++++++++
 .../javaudf_p0/sketch/test_javaudf_md5.groovy      |  58 ++++++++++++
 36 files changed, 1419 insertions(+)

diff --git 
a/regression-test/data/javaudf_p0/collect/test_javaudf_groupcount.out 
b/regression-test/data/javaudf_p0/collect/test_javaudf_groupcount.out
new file mode 100644
index 0000000000..ae75543b64
--- /dev/null
+++ b/regression-test/data/javaudf_p0/collect/test_javaudf_groupcount.out
@@ -0,0 +1,6 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !select --
+0
+0
+1
+
diff --git 
a/regression-test/data/javaudf_p0/collect/test_javaudf_murmurhash3.out 
b/regression-test/data/javaudf_p0/collect/test_javaudf_murmurhash3.out
new file mode 100644
index 0000000000..21a89b50ef
--- /dev/null
+++ b/regression-test/data/javaudf_p0/collect/test_javaudf_murmurhash3.out
@@ -0,0 +1,6 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !select --
+-1435112961
+301691705
+301691705
+
diff --git 
a/regression-test/data/javaudf_p0/collect/test_javaudf_sessionize.out 
b/regression-test/data/javaudf_p0/collect/test_javaudf_sessionize.out
new file mode 100644
index 0000000000..8ec0794fa1
--- /dev/null
+++ b/regression-test/data/javaudf_p0/collect/test_javaudf_sessionize.out
@@ -0,0 +1,5 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !select --
+098f6bcd-4621-3373-8ade-4e832627b4f6
+098f6bcd-4621-3373-8ade-4e832627b4f6
+
diff --git a/regression-test/data/javaudf_p0/date/test_javaudf_adddays.out 
b/regression-test/data/javaudf_p0/date/test_javaudf_adddays.out
new file mode 100644
index 0000000000..3a08a1fad2
--- /dev/null
+++ b/regression-test/data/javaudf_p0/date/test_javaudf_adddays.out
@@ -0,0 +1,6 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !select --
+20220101
+20220102
+20220301
+
diff --git 
a/regression-test/data/javaudf_p0/date/test_javaudf_addisoperioud.out 
b/regression-test/data/javaudf_p0/date/test_javaudf_addisoperioud.out
new file mode 100644
index 0000000000..79dc1c6f89
--- /dev/null
+++ b/regression-test/data/javaudf_p0/date/test_javaudf_addisoperioud.out
@@ -0,0 +1,6 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !select --
+20211231
+20220101
+20220228
+
diff --git a/regression-test/data/javaudf_p0/date/test_javaudf_daydiff.out 
b/regression-test/data/javaudf_p0/date/test_javaudf_daydiff.out
new file mode 100644
index 0000000000..86c88b834b
--- /dev/null
+++ b/regression-test/data/javaudf_p0/date/test_javaudf_daydiff.out
@@ -0,0 +1,5 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !select --
+1
+1
+
diff --git 
a/regression-test/data/javaudf_p0/json/test_javaudf_convertfromcamelcase.out 
b/regression-test/data/javaudf_p0/json/test_javaudf_convertfromcamelcase.out
new file mode 100644
index 0000000000..0ec37b2092
--- /dev/null
+++ b/regression-test/data/javaudf_p0/json/test_javaudf_convertfromcamelcase.out
@@ -0,0 +1,5 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !select --
+get_id_from_table
+test_java_udf
+
diff --git 
a/regression-test/data/javaudf_p0/json/test_javaudf_converttocamelcase.out 
b/regression-test/data/javaudf_p0/json/test_javaudf_converttocamelcase.out
new file mode 100644
index 0000000000..10d167d2f7
--- /dev/null
+++ b/regression-test/data/javaudf_p0/json/test_javaudf_converttocamelcase.out
@@ -0,0 +1,5 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !select --
+getIdFromTable
+testJavaUdf
+
diff --git 
a/regression-test/data/javaudf_p0/sanity/test_javaudf_assertequal.out 
b/regression-test/data/javaudf_p0/sanity/test_javaudf_assertequal.out
new file mode 100644
index 0000000000..3376296a3c
--- /dev/null
+++ b/regression-test/data/javaudf_p0/sanity/test_javaudf_assertequal.out
@@ -0,0 +1,4 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !select --
+23.34 == 23.34
+
diff --git 
a/regression-test/data/javaudf_p0/sanity/test_javaudf_assertlessthan.out 
b/regression-test/data/javaudf_p0/sanity/test_javaudf_assertlessthan.out
new file mode 100644
index 0000000000..41cb52194e
--- /dev/null
+++ b/regression-test/data/javaudf_p0/sanity/test_javaudf_assertlessthan.out
@@ -0,0 +1,5 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !select --
+0.123 < 0.124
+23.34 < 23.35
+
diff --git a/regression-test/data/javaudf_p0/sanity/test_javaudf_assertudf.out 
b/regression-test/data/javaudf_p0/sanity/test_javaudf_assertudf.out
new file mode 100644
index 0000000000..7787cd21cd
--- /dev/null
+++ b/regression-test/data/javaudf_p0/sanity/test_javaudf_assertudf.out
@@ -0,0 +1,4 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !select --
+OK
+
diff --git a/regression-test/data/javaudf_p0/sketch/test_javaudf_md5.out 
b/regression-test/data/javaudf_p0/sketch/test_javaudf_md5.out
new file mode 100644
index 0000000000..b326f3cbb9
--- /dev/null
+++ b/regression-test/data/javaudf_p0/sketch/test_javaudf_md5.out
@@ -0,0 +1,5 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !select --
+202cb962ac59075b964b07152d234b70
+900150983cd24fb0d6963f7d28e17f72
+
diff --git 
a/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/collect/GroupCountUDF.java
 
b/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/collect/GroupCountUDF.java
new file mode 100644
index 0000000000..6c82bcdffd
--- /dev/null
+++ 
b/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/collect/GroupCountUDF.java
@@ -0,0 +1,70 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+// This file is copied from
+// 
https://github.com/klout/brickhouse/blob/master/src/main/java/brickhouse/udf/collect/GroupCountUDF.java
+// and modified by Doris
+
+package org.apache.doris.udf.collect;
+
+import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.ql.exec.UDF;
+
+
+/**
+ * GroupCountUDF provides a sequence number for all rows which have the
+ * same value for a particular grouping.
+ * This allows us to count how many rows are in a grouping and cap them
+ * off after a certain point.
+ * <p/>
+ * <p>For example, we can cap-off the number of records per ks_uid with 
something like
+ * <p/>
+ * select
+ * ks_uid, val, group_count(ks_uid) as rank
+ * from
+ * (  select ks_uid, val from table1
+ * distribute  by ks_uid
+ * sort by ks_uid, val ) ordered_keys
+ * where group_count( ks_uid ) < 100
+ */
+@Description(
+    name = "group_count",
+    value = " A sequence id for all rows with the same value for a specific 
grouping"
+)
+public class GroupCountUDF extends UDF {
+    private String lastGrouping = null;
+    private int lastCount = 0;
+
+    public Integer evaluate(String grouping) {
+        // First time through ...
+        if (lastGrouping == null) {
+            lastGrouping = grouping;
+            lastCount = 1;
+            return 0;
+        }
+        if (lastGrouping != null
+            && lastGrouping.equals(grouping)) {
+            int retVal = lastCount;
+            lastCount++;
+            return retVal;
+        } else {
+            lastCount = 1;
+            lastGrouping = grouping;
+            return 0;
+        }
+
+    }
+}
diff --git 
a/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/collect/MurmurHash3UDF.java
 
b/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/collect/MurmurHash3UDF.java
new file mode 100644
index 0000000000..221aa133c7
--- /dev/null
+++ 
b/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/collect/MurmurHash3UDF.java
@@ -0,0 +1,105 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+// This file is copied from
+// 
https://github.com/klout/brickhouse/blob/master/src/main/java/brickhouse/udf/collect/MurmurHash3UDF.java
+// and modified by Doris
+
+package org.apache.doris.udf.collect;
+
+import org.apache.hadoop.hive.ql.exec.UDF;
+import org.apache.hadoop.io.IntWritable;
+
+/**
+ * Evaluates the 32 bit x86 version of MurmurHash3 of String input.
+ * Passing a seed value is optional, the default seed used is 1.
+ * Offset is set to 0.
+ */
+
+public class MurmurHash3UDF extends UDF {
+
+    public Integer evaluate(String input) {
+        if (input == null) {
+            return null;
+        }
+
+        return hash_str(input);
+    }
+
+    private static int hash_str(String item) {
+        // Offset: 0
+        // Seed: 1
+        return mhash(item.getBytes(), 0, item.length(), 1);
+    }
+
+    private static int hash_str(String item, int seed) {
+        // Offset: 0
+        return mhash(item.getBytes(), 0, item.length(), seed);
+    }
+
+    private static int mhash(byte[] data, int offset, int len, int seed) {
+
+        int c1 = 0xcc9e2d51;
+        int c2 = 0x1b873593;
+
+        int h1 = seed;
+        int roundedEnd = offset + (len & 0xfffffffc);  // round down to 4 byte 
block
+
+        for (int i = offset; i < roundedEnd; i += 4) {
+            // little endian load order
+            int k1 = (data[i] & 0xff) | ((data[i + 1] & 0xff) << 8) | ((data[i 
+ 2] & 0xff) << 16) | (data[i + 3] << 24);
+            k1 *= c1;
+            k1 = (k1 << 15) | (k1 >>> 17);  // ROTL32(k1,15);
+            k1 *= c2;
+
+            h1 ^= k1;
+            h1 = (h1 << 13) | (h1 >>> 19);  // ROTL32(h1,13);
+            h1 = h1 * 5 + 0xe6546b64;
+        }
+
+        // tail
+        int k1 = 0;
+
+        switch (len & 0x03) {
+            case 3:
+                k1 = (data[roundedEnd + 2] & 0xff) << 16;
+                // fallthrough
+            case 2:
+                k1 |= (data[roundedEnd + 1] & 0xff) << 8;
+                // fallthrough
+            case 1:
+                k1 |= data[roundedEnd] & 0xff;
+                k1 *= c1;
+                k1 = (k1 << 15) | (k1 >>> 17);  // ROTL32(k1,15);
+                k1 *= c2;
+                h1 ^= k1;
+            default:
+        }
+
+        // finalization
+        h1 ^= len;
+
+        // fmix(h1);
+        h1 ^= h1 >>> 16;
+        h1 *= 0x85ebca6b;
+        h1 ^= h1 >>> 13;
+        h1 *= 0xc2b2ae35;
+        h1 ^= h1 >>> 16;
+
+        return h1;
+    }
+
+}
diff --git 
a/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/collect/SessionizeUDF.java
 
b/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/collect/SessionizeUDF.java
new file mode 100644
index 0000000000..1f4dc04dd3
--- /dev/null
+++ 
b/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/collect/SessionizeUDF.java
@@ -0,0 +1,53 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+// This file is copied from
+// 
https://github.com/klout/brickhouse/blob/master/src/main/java/brickhouse/udf/collect/SessionizeUDF.java
+// and modified by Doris
+
+package org.apache.doris.udf.collect;
+
+import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.ql.exec.UDF;
+
+import java.util.UUID;
+
+@Description(
+    name = "sessionize",
+    value = "_FUNC_(string, timestamp) - Returns a session id for the given id 
and ts(long). Optional third parameter to specify interval tolerance in 
milliseconds",
+    extended = "SELECT _FUNC_(uid, ts), uid, ts, event_type from foo;")
+
+public class SessionizeUDF extends UDF {
+    private String lastUid = null;
+    private long lastTS = 0;
+    private String lastUUID = null;
+
+
+    public String evaluate(String uid, long ts, int tolerance) {
+        lastUUID = UUID.nameUUIDFromBytes("test".getBytes()).toString();
+        return lastUUID;
+    }
+
+    private Boolean timeStampCompare(long lastTS, long ts, int ms) {
+        try {
+            long difference = ts - lastTS;
+            return (Math.abs((int) difference) < ms) ? true : false;
+        } catch (ArithmeticException e) {
+            return false;
+        }
+    }
+}
+
diff --git 
a/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/date/AddDaysUDF.java
 
b/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/date/AddDaysUDF.java
new file mode 100644
index 0000000000..cd16c2e38d
--- /dev/null
+++ 
b/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/date/AddDaysUDF.java
@@ -0,0 +1,44 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+// This file is copied from
+// 
https://github.com/klout/brickhouse/blob/master/src/main/java/brickhouse/udf/date/AddDaysUDF.java
+// and modified by Doris
+
+package org.apache.doris.udf.date;
+
+import org.apache.hadoop.hive.ql.exec.UDF;
+import org.joda.time.DateTime;
+import org.joda.time.format.DateTimeFormatter;
+
+/**
+ * Simple date add UDF.
+ * Would use the Hive standard function, but that assumes a
+ * date format of "YYYY-MM-DD", and we would prefer "YYYYMMDD"
+ * and it is too awkward to include lots of substring functions in our hive
+ */
+public class AddDaysUDF extends UDF {
+    private static final DateTimeFormatter YYYYMMDD = 
org.joda.time.format.DateTimeFormat.forPattern("YYYYMMdd");
+
+    public String evaluate(String dateStr, int numDays) {
+        DateTime dt = YYYYMMDD.parseDateTime(dateStr);
+        DateTime addedDt = dt.plusDays(numDays);
+        String addedDtStr = YYYYMMDD.print(addedDt);
+
+        return addedDtStr;
+    }
+}
+
diff --git 
a/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/date/AddISOPeriodUDF.java
 
b/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/date/AddISOPeriodUDF.java
new file mode 100644
index 0000000000..75d8c1045a
--- /dev/null
+++ 
b/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/date/AddISOPeriodUDF.java
@@ -0,0 +1,58 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+// This file is copied from
+// 
https://github.com/klout/brickhouse/blob/master/src/main/java/brickhouse/udf/date/AddISOPeriodUDF.java
+// and modified by Doris
+
+package org.apache.doris.udf.date;
+
+import org.apache.hadoop.hive.ql.exec.UDF;
+import org.joda.time.DateTime;
+import org.joda.time.Duration;
+import org.joda.time.format.DateTimeFormatter;
+import org.joda.time.format.PeriodFormatter;
+
+/**
+ * UDF that receives date, date format (such as "YYYY-MM-dd HH:mm:ss") and
+ * period in ISO8601, it adds period in seconds to date.
+ *
+ * Example: add_iso_period(date, 'YYYY-MM-dd HH:mm:ss', 'PT02H00M')
+ */
+public class AddISOPeriodUDF extends UDF {
+
+    private static final PeriodFormatter periodFormatter = 
org.joda.time.format.ISOPeriodFormat
+        .standard();
+
+    public String evaluate(String dateString, String dateFormat, String 
periodString) {
+        if (dateString == null) {
+            return null;
+        }
+
+        if (dateFormat == null) {
+            dateFormat = "YYYY-MM-dd HH:mm:ss";
+        }
+
+        DateTimeFormatter dateFormatter = 
org.joda.time.format.DateTimeFormat.forPattern(dateFormat);
+        DateTime input = dateFormatter.parseDateTime(dateString);
+
+        Duration duration = 
periodFormatter.parsePeriod(periodString).toStandardDuration();
+        long seconds = duration.getStandardSeconds();
+
+        DateTime output = input.plusSeconds(Long.valueOf(seconds).intValue());
+        return dateFormatter.print(output);
+    }
+}
diff --git 
a/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/date/DayDiffUDF.java
 
b/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/date/DayDiffUDF.java
new file mode 100644
index 0000000000..77b1544565
--- /dev/null
+++ 
b/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/date/DayDiffUDF.java
@@ -0,0 +1,54 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+// This file is copied from
+// 
https://github.com/klout/brickhouse/blob/master/src/main/java/brickhouse/udf/date/DayDiffUDF.java
+// and modified by Doris
+
+package org.apache.doris.udf.date;
+
+import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.ql.exec.UDF;
+import org.apache.log4j.Logger;
+import org.joda.time.DateTime;
+import org.joda.time.Days;
+import org.joda.time.format.DateTimeFormatter;
+
+/**
+ * Given two dates in YYYYMMDD,
+ * return the number of days between
+ * midnight on each day..
+ * <p/>
+ * day_diff( "20120701", "20120702") == 1
+ * day_diff( "20120701", "20120701") == 0
+ */
+@Description(
+    name = "day_diff",
+    value = " The difference in days of two YYYYMMDD dates"
+)
+public class DayDiffUDF extends UDF {
+    private static final Logger LOG = Logger.getLogger(DayDiffUDF.class);
+    private static final DateTimeFormatter YYYYMMDD = 
org.joda.time.format.DateTimeFormat.forPattern("YYYYMMdd");
+
+    public Integer evaluate(String date1Str, String date2Str) {
+        DateTime dt1 = YYYYMMDD.parseDateTime(date1Str);
+        DateTime dt2 = YYYYMMDD.parseDateTime(date2Str);
+
+        int dayDiff = Days.daysBetween(dt1, dt2).getDays();
+
+        return dayDiff;
+    }
+}
diff --git 
a/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/json/ConvertFromCamelCaseUDF.java
 
b/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/json/ConvertFromCamelCaseUDF.java
new file mode 100644
index 0000000000..4a4a4d6a7d
--- /dev/null
+++ 
b/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/json/ConvertFromCamelCaseUDF.java
@@ -0,0 +1,48 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+// This file is copied from
+// 
https://github.com/klout/brickhouse/blob/master/src/main/java/brickhouse/udf/json/ConvertFromCamelCaseUDF.java
+// and modified by Doris
+
+package org.apache.doris.udf.json;
+
+import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.ql.exec.UDF;
+
+@Description(name = "from_camel_case",
+    value = "_FUNC_(a) - Converts a string in CamelCase to one containing 
underscores."
+)
+public class ConvertFromCamelCaseUDF extends UDF {
+
+    public String evaluate(String camel) {
+        return FromCamelCase(camel);
+    }
+
+    static public String FromCamelCase(String camel) {
+        StringBuilder sb = new StringBuilder();
+        for (int i = 0; i < camel.length(); ++i) {
+            char ch = camel.charAt(i);
+            if (ch >= 'A' && ch <= 'Z') {
+                sb.append('_');
+                sb.append((char) (ch - 'A' + 'a'));
+            } else {
+                sb.append(ch);
+            }
+        }
+        return sb.toString();
+    }
+}
diff --git 
a/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/json/ConvertToCamelCaseUDF.java
 
b/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/json/ConvertToCamelCaseUDF.java
new file mode 100644
index 0000000000..4eb4427d57
--- /dev/null
+++ 
b/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/json/ConvertToCamelCaseUDF.java
@@ -0,0 +1,53 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+// This file is copied from
+// 
https://github.com/klout/brickhouse/blob/master/src/main/java/brickhouse/udf/json/ConvertToCamelCaseUDF.java
+// and modified by Doris
+
+package org.apache.doris.udf.json;
+
+import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.ql.exec.UDF;
+
+@Description(name = "to_camel_case",
+    value = "_FUNC_(a) - Converts a string containing underscores to CamelCase"
+)
+public class ConvertToCamelCaseUDF extends UDF {
+
+    public String evaluate(String underscore) {
+        return ToCamelCase(underscore);
+    }
+
+    static public String ToCamelCase(String underscore) {
+        StringBuilder sb = new StringBuilder();
+        String[] splArr = underscore.toLowerCase().split("_");
+
+        sb.append(splArr[0]);
+        for (int i = 1; i < splArr.length; ++i) {
+            String word = splArr[i];
+            char firstChar = word.charAt(0);
+            if (firstChar >= 'a' && firstChar <= 'z') {
+                sb.append((char) (word.charAt(0) + 'A' - 'a'));
+                sb.append(word.substring(1));
+            } else {
+                sb.append(word);
+            }
+
+        }
+        return sb.toString();
+    }
+}
diff --git 
a/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/sanity/AssertEqualsUDF.java
 
b/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/sanity/AssertEqualsUDF.java
new file mode 100644
index 0000000000..8df756754a
--- /dev/null
+++ 
b/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/sanity/AssertEqualsUDF.java
@@ -0,0 +1,39 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+// This file is copied from
+// 
https://github.com/klout/brickhouse/blob/master/src/main/java/brickhouse/udf/sanity/AssertEqualsUDF.java
+// and modified by Doris
+
+package org.apache.doris.udf.sanity;
+
+import org.apache.hadoop.hive.ql.exec.UDF;
+
+public class AssertEqualsUDF extends UDF {
+
+    public String evaluate(Double val1, Double val2) {
+        if (val1 == null || val2 == null) {
+            System.err.println(" Null values found :: " + val1 + " == " + 
val2);
+            throw new RuntimeException(" Null values found :: " + val1 + " == 
" + val2);
+        }
+        if (!val1.equals(val2)) {
+            System.err.println(" Assertion Not Met :: ! ( " + val1 + " == " + 
val2 + " ) ");
+            throw new RuntimeException(" Assertion Not Met :: ! ( " + val1 + " 
== " + val2 + " ) ");
+        } else {
+            return val1.toString() + " == " + val2.toString();
+        }
+    }
+}
diff --git 
a/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/sanity/AssertLessThanUDF.java
 
b/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/sanity/AssertLessThanUDF.java
new file mode 100644
index 0000000000..e395a1a133
--- /dev/null
+++ 
b/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/sanity/AssertLessThanUDF.java
@@ -0,0 +1,39 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+// This file is copied from
+// 
https://github.com/klout/brickhouse/blob/master/src/main/java/brickhouse/udf/sanity/AssertLessThanUDF.java
+// and modified by Doris
+
+package org.apache.doris.udf.sanity;
+
+import org.apache.hadoop.hive.ql.exec.UDF;
+
+public class AssertLessThanUDF extends UDF {
+
+    public String evaluate(Double smaller, Double bigger) {
+        if (smaller == null || bigger == null) {
+            System.err.println(" Null values found :: " + smaller + " < " + 
bigger);
+            throw new RuntimeException(" Null values found :: " + smaller + " 
< " + bigger);
+        }
+        if (!(smaller < bigger)) {
+            System.err.println(" Assertion Not Met :: ! ( " + smaller + " < " 
+ bigger + " ) ");
+            throw new RuntimeException(" Assertion Not Met :: ! ( " + smaller 
+ " < " + bigger + " ) ");
+        } else {
+            return smaller.toString() + " < " + bigger.toString();
+        }
+    }
+}
diff --git 
a/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/sanity/AssertUDF.java
 
b/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/sanity/AssertUDF.java
new file mode 100644
index 0000000000..b82f02fbff
--- /dev/null
+++ 
b/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/sanity/AssertUDF.java
@@ -0,0 +1,45 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+// This file is copied from
+// 
https://github.com/klout/brickhouse/blob/master/src/main/java/brickhouse/udf/sanity/AssertUDF.java
+// and modified by Doris
+
+package org.apache.doris.udf.sanity;
+
+import org.apache.hadoop.hive.ql.exec.Description;
+import org.apache.hadoop.hive.ql.exec.UDF;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
+
+/**
+ *
+ */
+@Description(
+    name = "assert",
+    value = " Asserts in case boolean input is false. Optionally it asserts 
with message if input string provided. \n " +
+        "_FUNC_(boolean) \n" +
+        "_FUNC_(boolean, string) "
+)
+public class AssertUDF extends UDF {
+
+    public String evaluate(Boolean doNotThrowAssertion, String 
assertionMessage) throws HiveException {
+        if (doNotThrowAssertion) {
+            return "OK";
+        }
+        throw (assertionMessage == null) ? new HiveException() : new 
HiveException(assertionMessage);
+    }
+
+}
diff --git 
a/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/sketch/Md5.java
 
b/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/sketch/Md5.java
new file mode 100644
index 0000000000..b67fbce19b
--- /dev/null
+++ 
b/regression-test/java-udf-src/src/main/java/org/apache/doris/udf/sketch/Md5.java
@@ -0,0 +1,53 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+// This file is copied from
+// 
https://github.com/klout/brickhouse/blob/master/src/main/java/brickhouse/udf/sketch/Md5.java
+// and modified by Doris
+
+package org.apache.doris.udf.sketch;
+
+import org.apache.hadoop.hive.ql.exec.UDF;
+import org.apache.hadoop.io.Text;
+
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+/**
+ * Calculate md5 of the string
+ */
+public final class Md5 extends UDF {
+
+    public String evaluate(final String s) {
+        if (s == null) {
+            return null;
+        }
+        try {
+            MessageDigest md = MessageDigest.getInstance("MD5");
+            md.update(s.getBytes());
+            byte[] md5hash = md.digest();
+            StringBuilder builder = new StringBuilder();
+            for (byte b : md5hash) {
+                builder.append(Integer.toString((b & 0xff) + 0x100, 
16).substring(1));
+            }
+            return builder.toString();
+        } catch (NoSuchAlgorithmException nsae) {
+            System.out.println("Cannot find digest algorithm");
+            System.exit(1);
+        }
+        return null;
+    }
+}
diff --git 
a/regression-test/suites/javaudf_p0/collect/test_javaudf_groupcount.groovy 
b/regression-test/suites/javaudf_p0/collect/test_javaudf_groupcount.groovy
new file mode 100644
index 0000000000..f22e338062
--- /dev/null
+++ b/regression-test/suites/javaudf_p0/collect/test_javaudf_groupcount.groovy
@@ -0,0 +1,58 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import org.codehaus.groovy.runtime.IOGroovyMethods
+
+import java.nio.charset.StandardCharsets
+import java.nio.file.Files
+import java.nio.file.Paths
+
+suite("test_javaudf_groupcount") {
+    def tableName = "test_javaudf_groupcount"
+    File path = new File("${context.file.parent}")
+    def jarPath = 
"""${path.getParent()}/jars/java-udf-case-jar-with-dependencies.jar"""
+
+    log.info("Jar path: ${jarPath}".toString())
+    try {
+        sql """ DROP TABLE IF EXISTS ${tableName} """
+        sql """
+        CREATE TABLE IF NOT EXISTS ${tableName} (
+            `col_1` varchar(10) NOT NULL
+            )
+            DISTRIBUTED BY HASH(col_1) PROPERTIES("replication_num" = "1");
+        """
+
+        sql """ INSERT INTO ${tableName} VALUES ("abc"), ("123"), ("123"); """
+
+        File path1 = new File(jarPath)
+        if (!path1.exists()) {
+            throw new IllegalStateException("""${jarPath} doesn't exist! """)
+        }
+
+        sql """ CREATE FUNCTION group_count(string) RETURNS int PROPERTIES (
+            "file"="file://${jarPath}",
+            "symbol"="org.apache.doris.udf.collect.GroupCountUDF",
+            "type"="JAVA_UDF"
+        ); """
+
+        qt_select """ SELECT group_count(col_1) as a FROM ${tableName} ORDER 
BY a; """
+
+        sql """ DROP FUNCTION group_count(string); """
+    } finally {
+        try_sql("DROP TABLE IF EXISTS ${tableName}")
+    }
+}
diff --git 
a/regression-test/suites/javaudf_p0/collect/test_javaudf_murmurhash3.groovy 
b/regression-test/suites/javaudf_p0/collect/test_javaudf_murmurhash3.groovy
new file mode 100644
index 0000000000..a84f245f27
--- /dev/null
+++ b/regression-test/suites/javaudf_p0/collect/test_javaudf_murmurhash3.groovy
@@ -0,0 +1,58 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import org.codehaus.groovy.runtime.IOGroovyMethods
+
+import java.nio.charset.StandardCharsets
+import java.nio.file.Files
+import java.nio.file.Paths
+
+suite("test_javaudf_murmurhash3") {
+    def tableName = "test_javaudf_murmurhash3"
+    File path = new File("${context.file.parent}")
+    def jarPath = 
"""${path.getParent()}/jars/java-udf-case-jar-with-dependencies.jar"""
+
+    log.info("Jar path: ${jarPath}".toString())
+    try {
+        sql """ DROP TABLE IF EXISTS ${tableName} """
+        sql """
+        CREATE TABLE IF NOT EXISTS ${tableName} (
+            `col_1` varchar(10) NOT NULL
+            )
+            DISTRIBUTED BY HASH(col_1) PROPERTIES("replication_num" = "1");
+        """
+
+        sql """ INSERT INTO ${tableName} VALUES ("abc"), ("123"), ("123"); """
+
+        File path1 = new File(jarPath)
+        if (!path1.exists()) {
+            throw new IllegalStateException("""${jarPath} doesn't exist! """)
+        }
+
+        sql """ CREATE FUNCTION murmurhash3(string) RETURNS int PROPERTIES (
+            "file"="file://${jarPath}",
+            "symbol"="org.apache.doris.udf.collect.MurmurHash3UDF",
+            "type"="JAVA_UDF"
+        ); """
+
+        qt_select """ SELECT murmurhash3(col_1) as a FROM ${tableName} ORDER 
BY a; """
+
+        sql """ DROP FUNCTION murmurhash3(string); """
+    } finally {
+        try_sql("DROP TABLE IF EXISTS ${tableName}")
+    }
+}
diff --git 
a/regression-test/suites/javaudf_p0/collect/test_javaudf_sessionize.groovy 
b/regression-test/suites/javaudf_p0/collect/test_javaudf_sessionize.groovy
new file mode 100644
index 0000000000..0907ba8bf0
--- /dev/null
+++ b/regression-test/suites/javaudf_p0/collect/test_javaudf_sessionize.groovy
@@ -0,0 +1,61 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import org.codehaus.groovy.runtime.IOGroovyMethods
+
+import java.nio.charset.StandardCharsets
+import java.nio.file.Files
+import java.nio.file.Paths
+
+suite("test_javaudf_sessionize") {
+    def tableName = "test_javaudf_sessionize"
+    File path = new File("${context.file.parent}")
+    def jarPath = 
"""${path.getParent()}/jars/java-udf-case-jar-with-dependencies.jar"""
+
+    log.info("Jar path: ${jarPath}".toString())
+    try {
+        sql """ DROP TABLE IF EXISTS ${tableName} """
+        sql """
+        CREATE TABLE IF NOT EXISTS ${tableName} (
+            `col_1` varchar(10) NOT NULL,
+            `col_2` bigint NOT NULL,
+            `col_3` int NOT NULL
+            )
+            DISTRIBUTED BY HASH(col_1) PROPERTIES("replication_num" = "1");
+        """
+
+        sql """ INSERT INTO ${tableName} VALUES ("abc", 1234500000, 20), 
("bcd", 1234500000, 10); """
+
+        File path1 = new File(jarPath)
+        if (!path1.exists()) {
+            throw new IllegalStateException("""${jarPath} doesn't exist! """)
+        }
+
+        sql """ CREATE FUNCTION sessionize(string, bigint, int) RETURNS String 
PROPERTIES (
+            "file"="file://${jarPath}",
+            "symbol"="org.apache.doris.udf.collect.SessionizeUDF",
+            "type"="JAVA_UDF"
+        ); """
+
+        qt_select """ SELECT sessionize(col_1, col_2, col_3) as a FROM 
${tableName} ORDER BY a; """
+
+        sql """ DROP FUNCTION sessionize(string, bigint, int); """
+    } finally {
+        try_sql("DROP TABLE IF EXISTS ${tableName}")
+    }
+}
+
diff --git a/regression-test/suites/javaudf_p0/date/test_javaudf_adddays.groovy 
b/regression-test/suites/javaudf_p0/date/test_javaudf_adddays.groovy
new file mode 100644
index 0000000000..e116727d91
--- /dev/null
+++ b/regression-test/suites/javaudf_p0/date/test_javaudf_adddays.groovy
@@ -0,0 +1,58 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import org.codehaus.groovy.runtime.IOGroovyMethods
+
+import java.nio.charset.StandardCharsets
+import java.nio.file.Files
+import java.nio.file.Paths
+
+suite("test_javaudf_adddays") {
+    def tableName = "test_javaudf_adddays"
+    File path = new File("${context.file.parent}")
+    def jarPath = 
"""${path.getParent()}/jars/java-udf-case-jar-with-dependencies.jar"""
+
+    log.info("Jar path: ${jarPath}".toString())
+    try {
+        sql """ DROP TABLE IF EXISTS ${tableName} """
+        sql """
+        CREATE TABLE IF NOT EXISTS ${tableName} (
+            `col_1` varchar(10) NOT NULL
+            )
+            DISTRIBUTED BY HASH(col_1) PROPERTIES("replication_num" = "1");
+        """
+
+        sql """ INSERT INTO ${tableName} VALUES ("20220101"), ("20211231"), 
("20220228"); """
+
+        File path1 = new File(jarPath)
+        if (!path1.exists()) {
+            throw new IllegalStateException("""${jarPath} doesn't exist! """)
+        }
+
+        sql """ CREATE FUNCTION add_days(string, int) RETURNS string 
PROPERTIES (
+            "file"="file://${jarPath}",
+            "symbol"="org.apache.doris.udf.date.AddDaysUDF",
+            "type"="JAVA_UDF"
+        ); """
+
+        qt_select """ SELECT add_days(col_1, 1) as a FROM ${tableName} ORDER 
BY a; """
+
+        sql """ DROP FUNCTION add_days(string, int); """
+    } finally {
+        try_sql("DROP TABLE IF EXISTS ${tableName}")
+    }
+}
diff --git 
a/regression-test/suites/javaudf_p0/date/test_javaudf_addisoperioud.groovy 
b/regression-test/suites/javaudf_p0/date/test_javaudf_addisoperioud.groovy
new file mode 100644
index 0000000000..3e52a26745
--- /dev/null
+++ b/regression-test/suites/javaudf_p0/date/test_javaudf_addisoperioud.groovy
@@ -0,0 +1,58 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import org.codehaus.groovy.runtime.IOGroovyMethods
+
+import java.nio.charset.StandardCharsets
+import java.nio.file.Files
+import java.nio.file.Paths
+
+suite("test_javaudf_addisoperioud") {
+    def tableName = "test_javaudf_addisoperioud"
+    File path = new File("${context.file.parent}")
+    def jarPath = 
"""${path.getParent()}/jars/java-udf-case-jar-with-dependencies.jar"""
+
+    log.info("Jar path: ${jarPath}".toString())
+    try {
+        sql """ DROP TABLE IF EXISTS ${tableName} """
+        sql """
+        CREATE TABLE IF NOT EXISTS ${tableName} (
+            `col_1` varchar(10) NOT NULL
+            )
+            DISTRIBUTED BY HASH(col_1) PROPERTIES("replication_num" = "1");
+        """
+
+        sql """ INSERT INTO ${tableName} VALUES ("20220101"), ("20211231"), 
("20220228"); """
+
+        File path1 = new File(jarPath)
+        if (!path1.exists()) {
+            throw new IllegalStateException("""${jarPath} doesn't exist! """)
+        }
+
+        sql """ CREATE FUNCTION add_days(string, string, string) RETURNS 
string PROPERTIES (
+            "file"="file://${jarPath}",
+            "symbol"="org.apache.doris.udf.date.AddISOPeriodUDF",
+            "type"="JAVA_UDF"
+        ); """
+
+        qt_select """ SELECT add_days(col_1, 'YYYYMMdd', 'PT02H00M') as a FROM 
${tableName} ORDER BY a; """
+
+        sql """ DROP FUNCTION add_days(string, string, string); """
+    } finally {
+        try_sql("DROP TABLE IF EXISTS ${tableName}")
+    }
+}
diff --git a/regression-test/suites/javaudf_p0/date/test_javaudf_daydiff.groovy 
b/regression-test/suites/javaudf_p0/date/test_javaudf_daydiff.groovy
new file mode 100644
index 0000000000..18f2e2794b
--- /dev/null
+++ b/regression-test/suites/javaudf_p0/date/test_javaudf_daydiff.groovy
@@ -0,0 +1,59 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import org.codehaus.groovy.runtime.IOGroovyMethods
+
+import java.nio.charset.StandardCharsets
+import java.nio.file.Files
+import java.nio.file.Paths
+
+suite("test_javaudf_daydiff") {
+    def tableName = "test_javaudf_daydiff"
+    File path = new File("${context.file.parent}")
+    def jarPath = 
"""${path.getParent()}/jars/java-udf-case-jar-with-dependencies.jar"""
+
+    log.info("Jar path: ${jarPath}".toString())
+    try {
+        sql """ DROP TABLE IF EXISTS ${tableName} """
+        sql """
+        CREATE TABLE IF NOT EXISTS ${tableName} (
+            `col_1` varchar(10) NOT NULL,
+            `col_2` varchar(10) NOT NULL
+            )
+            DISTRIBUTED BY HASH(col_1) PROPERTIES("replication_num" = "1");
+        """
+
+        sql """ INSERT INTO ${tableName} VALUES ("20220101", "20220102"), 
("20221231", "20230101"); """
+
+        File path1 = new File(jarPath)
+        if (!path1.exists()) {
+            throw new IllegalStateException("""${jarPath} doesn't exist! """)
+        }
+
+        sql """ CREATE FUNCTION day_diff(string, string) RETURNS int 
PROPERTIES (
+            "file"="file://${jarPath}",
+            "symbol"="org.apache.doris.udf.date.DayDiffUDF",
+            "type"="JAVA_UDF"
+        ); """
+
+        qt_select """ SELECT day_diff(col_1, col_2)  as a FROM ${tableName} 
ORDER BY a; """
+
+        sql """ DROP FUNCTION day_diff(string, string); """
+    } finally {
+        try_sql("DROP TABLE IF EXISTS ${tableName}")
+    }
+}
diff --git 
a/regression-test/suites/javaudf_p0/json/test_javaudf_convertfromcamelcase.groovy
 
b/regression-test/suites/javaudf_p0/json/test_javaudf_convertfromcamelcase.groovy
new file mode 100644
index 0000000000..66796dcb44
--- /dev/null
+++ 
b/regression-test/suites/javaudf_p0/json/test_javaudf_convertfromcamelcase.groovy
@@ -0,0 +1,58 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import org.codehaus.groovy.runtime.IOGroovyMethods
+
+import java.nio.charset.StandardCharsets
+import java.nio.file.Files
+import java.nio.file.Paths
+
+suite("test_javaudf_convertfromcamelcase") {
+    def tableName = "test_javaudf_convertfromcamelcase"
+    File path = new File("${context.file.parent}")
+    def jarPath = 
"""${path.getParent()}/jars/java-udf-case-jar-with-dependencies.jar"""
+
+    log.info("Jar path: ${jarPath}".toString())
+    try {
+        sql """ DROP TABLE IF EXISTS ${tableName} """
+        sql """
+        CREATE TABLE IF NOT EXISTS ${tableName} (
+            `col_1` varchar(20) NOT NULL
+            )
+            DISTRIBUTED BY HASH(col_1) PROPERTIES("replication_num" = "1");
+        """
+
+        sql """ INSERT INTO ${tableName} VALUES ("testJavaUdf"), 
("getIdFromTable"); """
+
+        File path1 = new File(jarPath)
+        if (!path1.exists()) {
+            throw new IllegalStateException("""${jarPath} doesn't exist! """)
+        }
+
+        sql """ CREATE FUNCTION convert_from_camel(string) RETURNS string 
PROPERTIES (
+            "file"="file://${jarPath}",
+            "symbol"="org.apache.doris.udf.json.ConvertFromCamelCaseUDF",
+            "type"="JAVA_UDF"
+        ); """
+
+        qt_select """ SELECT convert_from_camel(col_1) as a FROM ${tableName} 
ORDER BY a; """
+
+        sql """ DROP FUNCTION convert_from_camel(string); """
+    } finally {
+        try_sql("DROP TABLE IF EXISTS ${tableName}")
+    }
+}
diff --git 
a/regression-test/suites/javaudf_p0/json/test_javaudf_converttocamelcase.groovy 
b/regression-test/suites/javaudf_p0/json/test_javaudf_converttocamelcase.groovy
new file mode 100644
index 0000000000..421018bc22
--- /dev/null
+++ 
b/regression-test/suites/javaudf_p0/json/test_javaudf_converttocamelcase.groovy
@@ -0,0 +1,58 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import org.codehaus.groovy.runtime.IOGroovyMethods
+
+import java.nio.charset.StandardCharsets
+import java.nio.file.Files
+import java.nio.file.Paths
+
+suite("test_javaudf_converttocamelcase") {
+    def tableName = "test_javaudf_converttocamelcase"
+    File path = new File("${context.file.parent}")
+    def jarPath = 
"""${path.getParent()}/jars/java-udf-case-jar-with-dependencies.jar"""
+
+    log.info("Jar path: ${jarPath}".toString())
+    try {
+        sql """ DROP TABLE IF EXISTS ${tableName} """
+        sql """
+        CREATE TABLE IF NOT EXISTS ${tableName} (
+            `col_1` varchar(20) NOT NULL
+            )
+            DISTRIBUTED BY HASH(col_1) PROPERTIES("replication_num" = "1");
+        """
+
+        sql """ INSERT INTO ${tableName} VALUES ("test_java_udf"), 
("get_id_from_table"); """
+
+        File path1 = new File(jarPath)
+        if (!path1.exists()) {
+            throw new IllegalStateException("""${jarPath} doesn't exist! """)
+        }
+
+        sql """ CREATE FUNCTION convert_to_camel(string) RETURNS string 
PROPERTIES (
+            "file"="file://${jarPath}",
+            "symbol"="org.apache.doris.udf.json.ConvertToCamelCaseUDF",
+            "type"="JAVA_UDF"
+        ); """
+
+        qt_select """ SELECT convert_to_camel(col_1) as a FROM ${tableName} 
ORDER BY a; """
+
+        sql """ DROP FUNCTION convert_to_camel(string); """
+    } finally {
+        try_sql("DROP TABLE IF EXISTS ${tableName}")
+    }
+}
diff --git 
a/regression-test/suites/javaudf_p0/sanity/test_javaudf_assertequal.groovy 
b/regression-test/suites/javaudf_p0/sanity/test_javaudf_assertequal.groovy
new file mode 100644
index 0000000000..2f22bed540
--- /dev/null
+++ b/regression-test/suites/javaudf_p0/sanity/test_javaudf_assertequal.groovy
@@ -0,0 +1,60 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import org.codehaus.groovy.runtime.IOGroovyMethods
+
+import java.nio.charset.StandardCharsets
+import java.nio.file.Files
+import java.nio.file.Paths
+
+suite("test_javaudf_assertequal") {
+    def tableName = "test_javaudf_assertequal"
+    File path = new File("${context.file.parent}")
+    def jarPath = 
"""${path.getParent()}/jars/java-udf-case-jar-with-dependencies.jar"""
+
+    log.info("Jar path: ${jarPath}".toString())
+    try {
+        sql """ DROP TABLE IF EXISTS ${tableName} """
+        sql """
+        CREATE TABLE IF NOT EXISTS ${tableName} (
+            `col` varchar(10) NOT NULL,
+            `col_1` double NOT NULL,
+            `col_2` double NOT NULL
+            )
+            DISTRIBUTED BY HASH(col) PROPERTIES("replication_num" = "1");
+        """
+
+        sql """ INSERT INTO ${tableName} VALUES ('abc', 23.34, 23.34); """
+
+        File path1 = new File(jarPath)
+        if (!path1.exists()) {
+            throw new IllegalStateException("""${jarPath} doesn't exist! """)
+        }
+
+        sql """ CREATE FUNCTION asser_equal(double, double) RETURNS string 
PROPERTIES (
+            "file"="file://${jarPath}",
+            "symbol"="org.apache.doris.udf.sanity.AssertEqualsUDF",
+            "type"="JAVA_UDF"
+        ); """
+
+        qt_select """ SELECT asser_equal(col_1, col_2)  as a FROM ${tableName} 
ORDER BY a; """
+
+        sql """ DROP FUNCTION asser_equal(double, double); """
+    } finally {
+        try_sql("DROP TABLE IF EXISTS ${tableName}")
+    }
+}
diff --git 
a/regression-test/suites/javaudf_p0/sanity/test_javaudf_assertlessthan.groovy 
b/regression-test/suites/javaudf_p0/sanity/test_javaudf_assertlessthan.groovy
new file mode 100644
index 0000000000..5177d16437
--- /dev/null
+++ 
b/regression-test/suites/javaudf_p0/sanity/test_javaudf_assertlessthan.groovy
@@ -0,0 +1,60 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import org.codehaus.groovy.runtime.IOGroovyMethods
+
+import java.nio.charset.StandardCharsets
+import java.nio.file.Files
+import java.nio.file.Paths
+
+suite("test_javaudf_assertlessthan") {
+    def tableName = "test_javaudf_assertlessthan"
+    File path = new File("${context.file.parent}")
+    def jarPath = 
"""${path.getParent()}/jars/java-udf-case-jar-with-dependencies.jar"""
+
+    log.info("Jar path: ${jarPath}".toString())
+    try {
+        sql """ DROP TABLE IF EXISTS ${tableName} """
+        sql """
+        CREATE TABLE IF NOT EXISTS ${tableName} (
+            `col` varchar(10) NOT NULL,
+            `col_1` double NOT NULL,
+            `col_2` double NOT NULL
+            )
+            DISTRIBUTED BY HASH(col) PROPERTIES("replication_num" = "1");
+        """
+
+        sql """ INSERT INTO ${tableName} VALUES ('abc', 23.34, 23.35), ('bcd', 
0.123, 0.124); """
+
+        File path1 = new File(jarPath)
+        if (!path1.exists()) {
+            throw new IllegalStateException("""${jarPath} doesn't exist! """)
+        }
+
+        sql """ CREATE FUNCTION asser_lessthan(double, double) RETURNS string 
PROPERTIES (
+            "file"="file://${jarPath}",
+            "symbol"="org.apache.doris.udf.sanity.AssertLessThanUDF",
+            "type"="JAVA_UDF"
+        ); """
+
+        qt_select """ SELECT asser_lessthan(col_1, col_2)  as a FROM 
${tableName} ORDER BY a; """
+
+        sql """ DROP FUNCTION asser_lessthan(double, double); """
+    } finally {
+        try_sql("DROP TABLE IF EXISTS ${tableName}")
+    }
+}
diff --git 
a/regression-test/suites/javaudf_p0/sanity/test_javaudf_assertudf.groovy 
b/regression-test/suites/javaudf_p0/sanity/test_javaudf_assertudf.groovy
new file mode 100644
index 0000000000..067d591044
--- /dev/null
+++ b/regression-test/suites/javaudf_p0/sanity/test_javaudf_assertudf.groovy
@@ -0,0 +1,50 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import org.codehaus.groovy.runtime.IOGroovyMethods
+
+import java.nio.charset.StandardCharsets
+import java.nio.file.Files
+import java.nio.file.Paths
+
+suite("test_javaudf_assertudf") {
+    def tableName = "test_javaudf_assertudf"
+    File path = new File("${context.file.parent}")
+    def jarPath = 
"""${path.getParent()}/jars/java-udf-case-jar-with-dependencies.jar"""
+
+    log.info("Jar path: ${jarPath}".toString())
+    try {
+        sql """ DROP TABLE IF EXISTS ${tableName} """
+
+        File path1 = new File(jarPath)
+        if (!path1.exists()) {
+            throw new IllegalStateException("""${jarPath} doesn't exist! """)
+        }
+
+        sql """ CREATE FUNCTION assert(boolean, string) RETURNS string 
PROPERTIES (
+            "file"="file://${jarPath}",
+            "symbol"="org.apache.doris.udf.sanity.AssertUDF",
+            "type"="JAVA_UDF"
+        ); """
+
+        qt_select """ SELECT assert(true, "not OK"); """
+
+        sql """ DROP FUNCTION assert(boolean, string); """
+    } finally {
+        try_sql("DROP TABLE IF EXISTS ${tableName}")
+    }
+}
diff --git a/regression-test/suites/javaudf_p0/sketch/test_javaudf_md5.groovy 
b/regression-test/suites/javaudf_p0/sketch/test_javaudf_md5.groovy
new file mode 100644
index 0000000000..3694d283fb
--- /dev/null
+++ b/regression-test/suites/javaudf_p0/sketch/test_javaudf_md5.groovy
@@ -0,0 +1,58 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import org.codehaus.groovy.runtime.IOGroovyMethods
+
+import java.nio.charset.StandardCharsets
+import java.nio.file.Files
+import java.nio.file.Paths
+
+suite("test_javaudf_md5") {
+    def tableName = "test_javaudf_md5"
+    File path = new File("${context.file.parent}")
+    def jarPath = 
"""${path.getParent()}/jars/java-udf-case-jar-with-dependencies.jar"""
+
+    log.info("Jar path: ${jarPath}".toString())
+    try {
+        sql """ DROP TABLE IF EXISTS ${tableName} """
+        sql """
+        CREATE TABLE IF NOT EXISTS ${tableName} (
+            `col_1` varchar(10) NOT NULL
+            )
+            DISTRIBUTED BY HASH(col_1) PROPERTIES("replication_num" = "1");
+        """
+
+        sql """ INSERT INTO ${tableName} VALUES ("abc"), ("123"); """
+
+        File path1 = new File(jarPath)
+        if (!path1.exists()) {
+            throw new IllegalStateException("""${jarPath} doesn't exist! """)
+        }
+
+        sql """ CREATE FUNCTION md5(string) RETURNS string PROPERTIES (
+            "file"="file://${jarPath}",
+            "symbol"="org.apache.doris.udf.sketch.Md5",
+            "type"="JAVA_UDF"
+        ); """
+
+        qt_select """ SELECT md5(col_1) as a FROM ${tableName} ORDER BY a; """
+
+        sql """ DROP FUNCTION md5(string); """
+    } finally {
+        try_sql("DROP TABLE IF EXISTS ${tableName}")
+    }
+}


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

Reply via email to