Shapers

Shapers that are used by AEs are called from table functions to dynamically declare the return table metadata, specifically the number of columns, the column names, types, and precision or scale.

Shapers are invoked when a table function is declared as returning TABLE(ANY). For local AEs, a new instance of the AE process is created on the host to return metadata describing the return table. The new instance is called only to provide this information and is not used for processing data. The AE instance is called before any data is retrieved, which means it receives metadata about the input arguments and can also retrieve any arguments that are constant. For remote AEs, a notification is sent to an instance of the remote AE running on the host. If no remote AE instance exists on the host with an address that matches the SQL table function, the SQL table function returns an error.

If an AE is registered as a SQL table function that is declared with return value TABLE(ANY), the AE must be written to perform both "shaping" and data processing. The same process instance never performs both, except in the case of a remote AE. Each AE language has an API function that indicates whether the AE is being used as a shaper or as a normal data processor.