Skip to content

Commit

Permalink
chore: add udf compat
Browse files Browse the repository at this point in the history
  • Loading branch information
TCeason committed Jan 7, 2025
1 parent 99cb6e1 commit 8c9d7a7
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .github/actions/test_compat_fuse/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <old-query-ver> <meta-ver> <test-suite>
Expand All @@ -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
Expand Down
18 changes: 18 additions & 0 deletions tests/compat_fuse/compat-logictest/udf/fuse_compat_read
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions tests/compat_fuse/compat-logictest/udf/fuse_compat_write
Original file line number Diff line number Diff line change
@@ -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;
}
$$;

0 comments on commit 8c9d7a7

Please sign in to comment.