-
Notifications
You must be signed in to change notification settings - Fork 752
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add udf script compat
- Loading branch information
Showing
3 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
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 | ||
SELECT name FROM SYSTEM.USER_FUNCTIONS where name = 'gcd_js' ORDER BY name; | ||
---- | ||
gcd_js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
statement ok | ||
DROP FUNCTION IF EXISTS add_signed; | ||
|
||
statement ok | ||
DROP FUNCTION IF EXISTS gcd_js; | ||
|
||
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; | ||
} | ||
$$; |