Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions be/src/vec/aggregate_functions/aggregate_function_java_udaf.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ struct AggregateJavaUdafData {
{
TJavaUdfExecutorCtorParams ctor_params;
ctor_params.__set_fn(fn);
ctor_params.__set_location(local_location);

if (!fn.hdfs_location.empty() && !fn.checksum.empty()) {
ctor_params.__set_location(local_location);
}
jbyteArray ctor_params_bytes;

// Pushed frame will be popped when jni_frame goes out-of-scope.
Expand Down Expand Up @@ -274,7 +275,13 @@ class AggregateJavaUdaf final
//So need to check as soon as possible, before call Data function
Status check_udaf(const TFunction& fn) {
auto function_cache = UserFunctionCache::instance();
return function_cache->get_jarpath(fn.id, fn.hdfs_location, fn.checksum, &_local_location);
// get jar path if both file path location and checksum are null
if (!fn.hdfs_location.empty() && !fn.checksum.empty()) {
return function_cache->get_jarpath(fn.id, fn.hdfs_location, fn.checksum,
&_local_location);
} else {
return Status::OK();
}
}

void create(AggregateDataPtr __restrict place) const override {
Expand Down
10 changes: 7 additions & 3 deletions be/src/vec/functions/function_java_udf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,15 @@ Status JavaFunctionCall::open(FunctionContext* context, FunctionContext::Functio
{
std::string local_location;
auto function_cache = UserFunctionCache::instance();
RETURN_IF_ERROR(function_cache->get_jarpath(fn_.id, fn_.hdfs_location, fn_.checksum,
&local_location));
TJavaUdfExecutorCtorParams ctor_params;
ctor_params.__set_fn(fn_);
ctor_params.__set_location(local_location);
// get jar path if both file path location and checksum are null
if (!fn_.hdfs_location.empty() && !fn_.checksum.empty()) {
RETURN_IF_ERROR(function_cache->get_jarpath(fn_.id, fn_.hdfs_location, fn_.checksum,
&local_location));
ctor_params.__set_location(local_location);
}

jbyteArray ctor_params_bytes;

// Pushed frame will be popped when jni_frame goes out-of-scope.
Expand Down
2 changes: 1 addition & 1 deletion bin/start_fe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ done
# add custom_libs to CLASSPATH
if [[ -d "${DORIS_HOME}/custom_lib" ]]; then
for f in "${DORIS_HOME}/custom_lib"/*.jar; do
CLASSPATH="${f}:${CLASSPATH}"
CLASSPATH="${CLASSPATH}:${f}"
done
fi

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public static void translateToNereidsFunction(String dbName, org.apache.doris.ca
JavaUdaf udaf = new JavaUdaf(fnName, aggregate.getId(), dbName, aggregate.getBinaryType(), sig,
intermediateType,
aggregate.getNullableMode(),
aggregate.getLocation().getLocation(),
aggregate.getLocation() == null ? null : aggregate.getLocation().getLocation(),
aggregate.getSymbolName(),
aggregate.getInitFnSymbol(),
aggregate.getUpdateFnSymbol(),
Expand Down Expand Up @@ -182,7 +182,7 @@ public Function getCatalogFunction() {
signature.returnType.toCatalogDataType(),
signature.hasVarArgs,
intermediateType.toCatalogDataType(),
URI.create(objectFile),
objectFile == null ? null : URI.create(objectFile),
initFn,
updateFn,
mergeFn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public static void translateToNereidsFunction(String dbName, org.apache.doris.ca

JavaUdf udf = new JavaUdf(fnName, scalar.getId(), dbName, scalar.getBinaryType(), sig,
scalar.getNullableMode(),
scalar.getLocation().getLocation(),
scalar.getLocation() == null ? null : scalar.getLocation().getLocation(),
scalar.getSymbolName(),
scalar.getPrepareFnSymbol(),
scalar.getCloseFnSymbol(),
Expand All @@ -154,7 +154,7 @@ public Function getCatalogFunction() {
signature.argumentsTypes.stream().map(DataType::toCatalogDataType).toArray(Type[]::new),
signature.returnType.toCatalogDataType(),
signature.hasVarArgs,
URI.create(objectFile),
objectFile == null ? null : URI.create(objectFile),
symbol,
prepareFn,
closeFn
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !select_default --
1 1 abcdefg1 poiuytre1abcdefg
2 2 abcdefg2 poiuytre2abcdefg
0 3 abcdefg3 poiuytre3abcdefg
1 4 abcdefg4 poiuytre4abcdefg
2 5 abcdefg5 poiuytre5abcdefg
0 6 abcdefg6 poiuytre6abcdefg
1 7 abcdefg7 poiuytre7abcdefg
2 8 abcdefg8 poiuytre8abcdefg
9 9 abcdefg9 poiuytre9abcdefg

-- !select1 --
18

-- !select2 --
0 0
1 3
2 6
9 9
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !java_udf_all_types --
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// 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_javaudaf_custom_lib_mysum_int") {
def tableName = "test_javaudaf_custom_lib_mysum_int"
try {
sql """ DROP TABLE IF EXISTS ${tableName} """
sql """
CREATE TABLE IF NOT EXISTS ${tableName} (
`user_id` INT NOT NULL COMMENT "用户id",
`char_col` CHAR NOT NULL COMMENT "",
`varchar_col` VARCHAR(10) NOT NULL COMMENT "",
`string_col` STRING NOT NULL COMMENT ""
)
DISTRIBUTED BY HASH(user_id) PROPERTIES("replication_num" = "1");
"""
StringBuilder sb = new StringBuilder()
int i = 1
for (; i < 9; i ++) {
sb.append("""
(${i % 3}, '${i}','abcdefg${i}','poiuytre${i}abcdefg'),
""")
}
sb.append("""
(${i}, '${i}','abcdefg${i}','poiuytre${i}abcdefg')
""")
sql """ INSERT INTO ${tableName} VALUES
${sb.toString()}
"""
qt_select_default """ SELECT * FROM ${tableName} t ORDER BY char_col; """

sql """ CREATE AGGREGATE FUNCTION c_udaf_my_sum_int(int) RETURNS BigInt PROPERTIES (
"symbol"="org.apache.doris.udf.MySumInt",
"always_nullable"="false",
"type"="JAVA_UDF"
); """

qt_select1 """ SELECT c_udaf_my_sum_int(user_id) result FROM ${tableName}; """
qt_select2 """ select user_id, c_udaf_my_sum_int(user_id) from ${tableName} group by user_id order by user_id; """
} finally {
try_sql("DROP FUNCTION IF EXISTS c_udaf_my_sum_int(int);")
try_sql("DROP TABLE IF EXISTS ${tableName}")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// 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_custom_lib_all_types") {
def tableName = "test_javaudf_custom_lib_all_types"
try {
sql """ DROP TABLE IF EXISTS ${tableName} """
sql """
CREATE TABLE IF NOT EXISTS ${tableName} (
int_col int,
string_col string
)
DISTRIBUTED BY HASH(int_col) PROPERTIES("replication_num" = "1");
"""
StringBuilder sb = new StringBuilder()
int i = 1
for (; i < 10; i++) {
sb.append("""
(${i},${i%2}),
""")
}
sb.append("""
(${i},null)
""")
sql """ INSERT INTO ${tableName} VALUES
${sb.toString()}
"""

sql """DROP FUNCTION IF EXISTS c_echo_int(int);"""
sql """CREATE FUNCTION c_echo_int(int) RETURNS int PROPERTIES (
"symbol"="org.apache.doris.udf.Echo\$EchoInt",
"type"="JAVA_UDF"
);"""

qt_java_udf_all_types """select
int_col,
c_echo_int(int_col)
from ${tableName} order by int_col;"""
} finally {
try_sql """DROP FUNCTION IF EXISTS c_echo_int(int);"""
try_sql("""DROP TABLE IF EXISTS ${tableName};""")
}
}
32 changes: 22 additions & 10 deletions run-regression-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Usage: $0 <shell_options> <framework_options>
Eg.
$0 build regression test framework and run all suite which in default group
$0 --run test_select run a suite which named as test_select
$0 --run 'test*' run all suite which named start with 'test', note that you must quota with ''
$0 --compile only compile regression framework
$0 --run -s test_select run a suite which named as test_select
$0 --run test_select -genOut generate output file for test_select if not exist
$0 --run -g default run all suite in the group which named as default
Expand All @@ -65,7 +65,7 @@ Default config file: \${DORIS_HOME}/regression-test/conf/regression-conf.groovy
"
exit 1
}

ONLY_COMPILE=0
CLEAN=0
WRONG_CMD=0
TEAMCITY=0
Expand Down Expand Up @@ -96,6 +96,11 @@ else
shift
shift
;;
--compile)
RUN=1
ONLY_COMPILE=1
shift
;;
--run)
RUN=1
shift
Expand Down Expand Up @@ -178,6 +183,11 @@ if ! test -f ${RUN_JAR:+${RUN_JAR}}; then
cd "${DORIS_HOME}"/regression-test/java-udf-src
"${MVN_CMD}" package
cp target/java-udf-case-jar-with-dependencies.jar "${DORIS_HOME}"/regression-test/suites/javaudf_p0/jars/
# be and fe dir is compiled output
mkdir -p "${DORIS_HOME}"/output/fe/custom_lib/
mkdir -p "${DORIS_HOME}"/output/be/custom_lib/
cp target/java-udf-case-jar-with-dependencies.jar "${DORIS_HOME}"/output/fe/custom_lib/
cp target/java-udf-case-jar-with-dependencies.jar "${DORIS_HOME}"/output/be/custom_lib/
cd "${DORIS_HOME}"
fi

Expand Down Expand Up @@ -205,11 +215,13 @@ if [[ "${TEAMCITY}" -eq 1 ]]; then
JAVA_OPTS="${JAVA_OPTS} -DstdoutAppenderType=teamcity -Xmx2048m"
fi

"${JAVA}" -DDORIS_HOME="${DORIS_HOME}" \
-DLOG_PATH="${LOG_OUTPUT_FILE}" \
-Dfile.encoding="UTF-8" \
-Dlogback.configurationFile="${LOG_CONFIG_FILE}" \
${JAVA_OPTS:+${JAVA_OPTS}} \
-jar ${RUN_JAR:+${RUN_JAR}} \
-cf "${CONFIG_FILE}" \
${REGRESSION_OPTIONS_PREFIX:+${REGRESSION_OPTIONS_PREFIX}} "$@"
if [[ "${ONLY_COMPILE}" -eq 0 ]]; then
"${JAVA}" -DDORIS_HOME="${DORIS_HOME}" \
-DLOG_PATH="${LOG_OUTPUT_FILE}" \
-Dfile.encoding="UTF-8" \
-Dlogback.configurationFile="${LOG_CONFIG_FILE}" \
${JAVA_OPTS:+${JAVA_OPTS}} \
-jar ${RUN_JAR:+${RUN_JAR}} \
-cf "${CONFIG_FILE}" \
${REGRESSION_OPTIONS_PREFIX:+${REGRESSION_OPTIONS_PREFIX}} "$@"
fi