CREATE MODULE Statement

Create a module that contains specific functionality that you can load in a CCL project using the LOAD MODULE statement.

Syntax

CREATE MODULE moduleName
IN input1 [,...]
OUT output1[,...]
BEGIN
	statements;
END;

Components

moduleName

The name of the module.

input1

The input stream or window.

output1

The output stream or window.

Usage

All CCL statements are valid in a module except:

  • CREATE MODULE
  • ATTACH ADAPTER
  • ADAPTER START GROUPS

moduleName should be unique across all object names in the scope in which the statement exists. The names in the IN and OUT clauses must match the names of the streams or windows defined in the BEGIN-END block. All streams or windows with input visibility must be listed in the IN clause. All streams, windows, and delta streams (including those created by the flex operator), with output visibility must be listed in the OUT clause. The compiler generates an error if any input or output objects exist in the module and are not listed in their respective IN or OUT clause.

While you can use multiple CREATE statements within modules, such as the CREATE WINDOW and CREATE STREAM statements, the CREATE STORE statement uses a special syntax that cannot be used outside of a module. The syntax used within a module does not allow you to specify any store properties. The CREATE STORE syntax within a module is:
CREATE [DEFAULT] {MEMORY|LOG} STORE store1-inmodule;
Note: All CREATE MODULE statement compilation errors are fatal.

Restrictions

  • You cannot use the CREATE MODULE statement within the module definition.

Example

This example creates a simple module that filters data based on a column's values:
CREATE MODULE filter_module
IN moduleIn
OUT moduleOut
BEGIN
	CREATE SCHEMA filter_schema (Value INTEGER);
	CREATE INPUT STREAM moduleIn SCHEMA filter_schema;
	CREATE OUTPUT STREAM moduleOut SCHEMA filterSchema AS SELECT * FROM moduleIn WHERE moduleIn.Value > 10;
END;