The LOAD MODULE statement loads a previously created module into the project.
LOAD MODULE modulename AS moduleIdentifier in-clause out-clause [parameters-clause] [stores-clause];
moduleName | The name of the module, which must match the name of the previously created module. |
module identifier | The identifier name must be unique within the parent scope. |
IN clause | Binds the input streams or windows defined in the module to previously-created streams or windows in the parent scope. |
OUT clause | Exposes one or more output streams defined within the module to the parent scope using unique identifiers. |
PARAMETERS clause | Binds one or more parameters defined inside the module to an expression at load time, or binds parameters inside the module to another parameter within the main project. If the parameter has a default value defined, then no parameter binding is required. |
STORES clause | Binds a store in the module to a store within the parent scope. |
All streams in a loaded module have local visibility at runtime, meaning they cannot be subscribed to, published from, or queried. When a module is loaded on the server, all of the streams and windows within the module, and the output streams and windows created by exposing outputs to the parent scope, behave as if they have local visibility. Therefore, the streams and windows within a module and the exposed outputs of the module cannot be queried externally or subscribed to.
This example uses a module that processes raw stock trade information and outputs a list of trades with a price exceeding 1.00. The module loads into the main project using the LOAD MODULE statement.
CREATE MODULE FilterByPrice IN TradeData OUT FilteredTradeData BEGIN CREATE SCHEMA TradesSchema ( Id integer, TradeTime date, Venue string, Symbol string, Price float, Shares integer ); CREATE INPUT STREAM TradeData SCHEMA TradesSchema; CREATE OUTPUT STREAM FilteredTradeData SCHEMA TradesSchema AS SELECT * FROM TradeData WHERE TradeData.Price > 1.00; END; CREATE INPUT STREAM NYSEData SCHEMA TradesSchema; LOAD MODULE FilterByPrice AS FilterOver1 IN TradeData = NYSEData OUT FilteredTradeData = NYSEPriceOver1Data;