Skip to content

SQL UDFs #3994

Closed
Closed
@BohuTANG

Description

@BohuTANG
  • 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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions