Closed
Description
- Scalar SQL UDFs (already done)
Databend already have the scalar UDFs:
CREATE FUNCTION mean2number AS (x, y) -> (x + y) / 2;
SELECT mean2number(150, 250);
+-------------------+
| ((150 + 250) / 2) |
+-------------------+
| 200 |
+-------------------+
- Tabular SQL UDFs (UDTFs)(TODO)
A user-defined table functions can apply to a sql query and returns 0, 1 or multi-rows, each result contains 1 or more columns.
A snow style UDTFs:
create function sum_range_func(l int, r int)
returns table (x integer)
as 'select sum(a) from test where a > l and a < r'
;
select * from table(sum_range_func(1,9));
Reference:
https://docs.snowflake.com/en/developer-guide/udf/sql/udf-sql-tabular-functions.html