ECL syntax is characterized by its English-like readability and declarative nature. Developers use it to define data transformation workflows by specifying operations on datasets. ECL scripts can consist of modules and functions that manipulate data through a sequence of transformations, including filters, joins, sorts, and aggregations. One of ECL's unique features is its ability to optimize and parallelize these transformations across distributed computing resources, making it well-suited for big data processing tasks.
ECL definitions are the basic building blocks of ECL. A definition specifies what needs to be done rather than how it is to be done.
:=
read as "is defined as") defines an expression;
)Syntax
[attrib_type] attrib_name := value
Value | Definition |
---|---|
attrib_type | Optional. Compiler can infer it from definition. |
attrib_name | The name by which the definition will be invoked. |
value | Assigned value to the definition. |
Example
// attrib_name Val1 is defined and value 12 is assigned to it Val1 := 12; // attrib_name Val2 is defined and value 65 is assigned to it Val2 := 65; // attrib_name Result is defined and the summation of Val1 and Val2 is assigned to it Result := Val1 + Val2;
Comments in ECL are supported using the following syntax.
Comment Type | Symbol | Example |
---|---|---|
Single Line | // | // This is a single-line comment. |
Multi Line | /* */ | /* This is a multi-line comment. */ |
Example
// This is a single-line comment. /* This is a multi-line comment. */
You can use object.property to access dataset fields and definitions.
dataset.fieldName
Referencing a field from a datasetmoduleName.definition
Referencing an attribute from a moduleMyDataset.FieldName; MyModule.ExportedValue;
In ECL, coding revolves around two main approaches: Definitions and Actions. These provide the structure to define data intricacies using Definitions and execute tasks effectively through Actions, forming the foundation for robust ECL solutions.
Example
/* Actions vs Definitions */ // Definitions STRING Def1 := 'Concatenating two Definitions '; STRING Def2 := 'and performing an OUTPUT Action.'; // Action: String Concatenation Def1 + Def2; // Definitions Val1 := 12; Val2 := 50; SomeResult := Val1 + Val2; // Action: Print Result SomeResult;
Action simply means "do something". Actions trigger execution of a workunit that produce output in the workunit. Actions do NOT have a return value.
Example
// Action OUTPUT('This is an Action.'); // Action SUM(1,2);
Example
/* Actions vs Definitions */ // Defining an attribute str := 'Hello Word'; // Performing an OUTPUT Action OUTPUT(str, NAMED('My_First_Program')); // Defining an Action NumOne := MAX(1,2,5,6); // Performing an OUTPUT Action OUTPUT(NumOne, NAMED('ActionThis')); // Simple Actions 'My first ECL code'; 1 + 4 + 5; 2 * 3;