UDTF(); the number of arguments inside represent the total number of input and output columns.
out0, out1, .... It's possible to use aliases to reference input and output columns in further SQL constructions. For example:
fahrenheit2celciusis defined on a table with one column as input. The final line
return 5means that a table with only 5 rows is returned.
set_output_row_sizefrom the module
rbc.externals.heavydbis required. The function must be called before any assignment on output columns.
Cursorin the UDTF definition as shown above is required.
TableFunctionManagerin the signature of a UDTF enables parallel execution of table functions. Without this argument, table functions are executed on a single thread; more importantly, the execution is not thread-safe. To enable threaded execution, the function signature the extra argument for the
TableFunctionManagerand the function
set_output_row_sizemust be called on the manager to ensure thread safety.
ColumnList. In the following example, the mean over each column is returned. It's possible to have multiple
ColumnListparameters. Two helper attributes are available to get the number of rows and column, respectively
mathmodule. These functions are defined in
rbc.stdlib, so, to get the full list of supported functions, inspect that module:
fahrenheit2celsiushas been decorated with
rbc.externaldescribes functions known to the server. Those functions on the server can be used when constructing new UDFs or UDTFs by using the function
rbc.external.external. In the following example,
log2is a function which is known on by the database server. To use
log2with a UDF or a UDTF defined using RBC, it needs to be typed using a C-like syntax similar to the one used when decorating functions for RBC.