Using the FROM clause - Cloud

Talend Data Shaping Language Reference Guide

Version
Cloud
Language
English (United States)
Product
Talend Cloud
Module
Data Shaping Language
Content
Design and Development

The FROM clause is used to iterate over an input collection defined by an identifier.

The FROM clause should be structured as follows:
FROM identifier  

The FROM clause can contain other keywords, such as AS and INDEX.

The AS keyword allows you to create an alias for a collection, it can then be used to refer to the elements in the collection in subsequent clauses. The alias must be unique throughout the query and should be defined as follows:
FROM identifier AS alias     
When using a FROM clause without an alias, all identifiers used in the query are treated as relative to the identifier in the FROM clause, except when it is followed by an UNNEST clause. For example, in the following query:
FROM customers
SELECT {
	name,
	id
}

The elements selected are customers.name and customers.id. If the full path was specified in the SELECT clause, the elements would be interpreted as customers.customers.name and customers.customers.id.

When working with nested collections that contain elements with the same identifier, an alias is needed to avoid issues with relative paths.

The INDEX keyword allows you to store the index of the current iteration in a variable. The variable must start with the $ character and cannot be a hierarchical identifier, for example, $item.index is not a valid variable. The variable must be unique throughout the query. The INDEX should be defined as follows:
FROM identifier INDEX $variable_name       
The following example is a valid FROM clause:
FROM customers AS c INDEX $i