LOAD MODULE Statement

The LOAD MODULE statement loads a previously created module into the project. The CREATE MODULE statement can either be in the current CCL file or in an imported CCL file (see IMPORT statement).

Syntax

LOAD MODULE moduleName AS moduleIdentifier
	in_clause
	out_clause
	[parameters_clause]
	[stores_clause]
    [references_clause]
    [partition_clause];

Components

moduleName

The name of the module that must match the name of the previously created module.

moduleIdentifier

The name used to identify this instance of the module: it 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.

partition_clause

(Optional) Creates a specified number of parallel instances of the module. The partition type specifies how to partition the input for the module. See the PARTITION BY Clause for more information.

references_clause Binds one or more references defined inside the module to references defined in the main project. If the module has no references, then this clause is not required.

Usage

The LOAD MODULE statement is used to create an instance of a previously defined module in the current project. The IN, OUT and optional PARAMETERS, REFERENCES, and STORES clauses bind the module to elements in the calling project. The same module may be "loaded" multiple times in a single project.

Before a module can be loaded, it must be defined in a CREATE MODULE statement in either the same project or an imported CCL file.

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.

LOAD MODULE supports:
  • IN clause
  • OUT clause
  • PARAMETERS clause
  • PARTITION clause
  • REFERENCES clause
  • STORES clause
Note: All LOAD MODULE statement compilation errors are fatal.

Example

This example defines a module that processes raw stock trade information and outputs a list of trades with a price exceeding 1.00. The project then creates an instance of the module using the LOAD MODULE statement. The LOAD MODULE statement binds the project input stream "NYSEData" to the input stream of the module (TradeData) and creates a local stream called "NYSEPriceOver1Data" that is bound to the output stream of the module (FilteredTradeData).

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;