ECL SYNTAX

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 is not case-sensitive but usually reserved keywords and built-in functions are written in ALL CAPS
  • White space is ignored, allowing formatting for readability as needed

Definitions

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.

  • The Definition operator (:= read as "is defined as") defines an expression
  • Definitions must be explicitly terminated with a semi-colon (;)

Syntax

[attrib_type] attrib_name := value
ValueDefinition
attrib_typeOptional. Compiler can infer it from definition.
attrib_nameThe name by which the definition will be invoked.
valueAssigned 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

Comments in ECL are supported using the following syntax.

Comment TypeSymbolExample
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.
*/

Field Access

You can use object.property to access dataset fields and definitions.

  • dataset.fieldName Referencing a field from a dataset
  • moduleName.definition Referencing an attribute from a module
MyDataset.FieldName;
MyModule.ExportedValue;

Statement Types

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

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;