Skip to content

Commit a341309

Browse files
committed
support jsonb type
Signed-off-by: Runji Wang <[email protected]>
1 parent 677fe1a commit a341309

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ arrow-flight = "50"
132132
arrow-select = "50"
133133
arrow-ord = "50"
134134
arrow-row = "50"
135-
arrow-udf-js = { git = "https://github.com/risingwavelabs/arrow-udf.git", rev = "0cc8391" }
135+
arrow-udf-js = { git = "https://github.com/risingwavelabs/arrow-udf.git", rev = "70fae28" }
136136
arrow-udf-wasm = "0.1"
137137
arrow-array-deltalake = { package = "arrow-array", version = "48.0.1" }
138138
arrow-buffer-deltalake = { package = "arrow-buffer", version = "48.0.1" }

e2e_test/udf/js_udf.slt

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ $$;
55

66
statement ok
77
create function gcd(a int, b int) returns int language javascript as $$
8+
// required before we support `RETURNS NULL ON NULL INPUT`
89
if(a == null || b == null) {
910
return null;
1011
}
@@ -17,8 +18,24 @@ create function gcd(a int, b int) returns int language javascript as $$
1718
$$;
1819

1920
statement ok
20-
create function to_string(a boolean, b smallint, c int, d bigint, e real, f float, g varchar) returns varchar language javascript as $$
21-
return a.toString() + b.toString() + c.toString() + d.toString() + e.toString() + f.toString() + g.toString();
21+
create function to_string(a boolean, b smallint, c int, d bigint, e real, f float, g varchar, h bytea, i jsonb) returns varchar language javascript as $$
22+
return a.toString() + b.toString() + c.toString() + d.toString() + e.toString() + f.toString() + g.toString() + h.toString() + JSON.stringify(i);
23+
$$;
24+
25+
# show data types in javascript
26+
statement ok
27+
create function js_typeof(a boolean, b smallint, c int, d bigint, e real, f float, g varchar, h bytea, i jsonb) returns jsonb language javascript as $$
28+
return {
29+
boolean: typeof a,
30+
smallint: typeof b,
31+
int: typeof c,
32+
bigint: typeof d,
33+
real: typeof e,
34+
float: typeof f,
35+
varchar: typeof g,
36+
bytea: typeof h,
37+
jsonb: typeof i,
38+
};
2239
$$;
2340

2441
statement ok
@@ -39,9 +56,14 @@ select gcd(25, 15);
3956
5
4057

4158
query T
42-
select to_string(false, 1::smallint, 2, 3, 4.5, 6.7, 'abc');
59+
select to_string(false, 1::smallint, 2, 3, 4.5, 6.7, 'abc', '\x010203', '{"key": 1}');
60+
----
61+
false1234.56.7abc1,2,3{"key":1}
62+
63+
query T
64+
select js_typeof(false, 1::smallint, 2, 3, 4.5, 6.7, 'abc', '\x010203', '{"key": 1}');
4365
----
44-
false1234.56.7abc
66+
{"bigint": "number", "boolean": "boolean", "bytea": "object", "float": "number", "int": "number", "jsonb": "object", "real": "number", "smallint": "number", "varchar": "string"}
4567

4668
query I
4769
select series(5);
@@ -63,3 +85,6 @@ drop function to_string;
6385

6486
statement ok
6587
drop function series;
88+
89+
statement ok
90+
drop function js_typeof;

0 commit comments

Comments
 (0)