Advanced Table Functions in Greenplum

Advanced Table Functions

Greenplum Database supports table functions with TABLE value expressions. The input rows for advanced table function can be sorted by using an ORDER BY clause, and redistributed by using a SCATTER BY clause to specify a column, multiple columns, or an expression for which rows with the specified characteristics are all available to the same process. This usage is similar to using a DISTRIBUTED BY clause when creating a table; however, the redistribution occurs when a query is executed.

The following command uses a SCATTER BY clause:

SELECT * FROM f( TABLE(SELECT * FROM input_table ORDER BY x SCATTER BY y) ); 

Note: The table functions with TABLE value parameters are parallelized automatically over the nodes of the cluster based on the distribution of data.