diff --git a/.github/actions/test_compat_fuse/action.yml b/.github/actions/test_compat_fuse/action.yml index d93aa6da52a6..3233f821e5e2 100644 --- a/.github/actions/test_compat_fuse/action.yml +++ b/.github/actions/test_compat_fuse/action.yml @@ -17,6 +17,13 @@ runs: path: ./bins/current artifacts: sqllogictests,meta,query + - name: Start UDF Server + shell: bash + run: | + pip install databend-udf>=0.2.6 + python3 tests/udf/udf_server.py & + sleep 3 + - name: Test compatibility shell: bash # test-*.sh @@ -31,6 +38,8 @@ runs: bash ./tests/compat_fuse/test_compat_fuse.sh 1.2.318 1.2.527 rbac bash ./tests/compat_fuse/test_compat_fuse_forward.sh 1.2.307 1.2.527 rbac bash ./tests/compat_fuse/test_compat_fuse_forward.sh 1.2.318 1.2.527 rbac + bash ./tests/compat_fuse/test_compat_fuse.sh 1.2.680 1.2.680 udf + bash ./tests/compat_fuse/test_compat_fuse_forward.sh 1.2.680 1.2.680 udf - name: Upload failure if: failure() uses: ./.github/actions/artifact_failure diff --git a/tests/compat_fuse/compat-logictest/udf/fuse_compat_read b/tests/compat_fuse/compat-logictest/udf/fuse_compat_read new file mode 100644 index 000000000000..197fdb24a296 --- /dev/null +++ b/tests/compat_fuse/compat-logictest/udf/fuse_compat_read @@ -0,0 +1,18 @@ +query F +select number, gcd_js(number * 3, number * 6) from numbers(5) where number > 0 order by 1 +---- +1 3 +2 6 +3 9 +4 12 + +query T +call add_signed(1,1,1,1); +---- +4 + +query T +SELECT definition FROM SYSTEM.USER_FUNCTIONS where name = 'add_signed' ORDER BY name; +---- + (Int8 NULL, Int16 NULL, Int32 NULL, Int64 NULL) RETURNS Int64 NULL LANGUAGE python HANDLER = add_signed ADDRESS = http://0.0.0.0:8815 + (String NULL) RETURNS String NULL LANGUAGE python HANDLER = ping ADDRESS = http://0.0.0.0:8815 diff --git a/tests/compat_fuse/compat-logictest/udf/fuse_compat_write b/tests/compat_fuse/compat-logictest/udf/fuse_compat_write new file mode 100644 index 000000000000..8e2087fe6955 --- /dev/null +++ b/tests/compat_fuse/compat-logictest/udf/fuse_compat_write @@ -0,0 +1,17 @@ +statement ok +DROP FUNCTION IF EXISTS add_signed; + +statement ok +CREATE FUNCTION add_signed (TINYINT, SMALLINT, INT, BIGINT) RETURNS BIGINT LANGUAGE python HANDLER = 'add_signed' ADDRESS = 'http://0.0.0.0:8815' + +statement ok +CREATE OR REPLACE FUNCTION gcd_js (INT, INT) RETURNS BIGINT LANGUAGE javascript HANDLER = 'gcd_js' AS $$ +export function gcd_js(a, b) { + while (b != 0) { + let t = b; + b = a % b; + a = t; + } + return a; +} +$$;