Changes to foreach Statement

The behavior of a foreach operation (also called projection) has changed.
Important

Important

This change may break existing SAQL code. Update existing code to use this new behavior.

Unique Names Required in a Projection

Using a name multiple times in a projection throws an error.

In the previous release, this query produced only the last projected alias in the result set. In this release, the last line is invalid and throws an error:
l = load "0Fbxx000000002qCAA/0Fcxx000000002WCAQ";
r = load "0Fbyy000000002qCAA/0Fcyy000000002WCAQ";
l = foreach l generate 'value'/'divisor' as 'value' , category as category;
r = foreach r generate 'value'/'divisor' as 'value' , category as category;
cg = cogroup l by category right, r by category;
cg = foreach cg generate r.category as 'category', sum(r.value) as sumrval, sum(l::value) as sumrval;

Consistent Projection of Constants

In this release, constant projection is consistent between preprojection and postprojection. A foreach operation returns rows based on filtered dataset size.

For example, this query returns all the rows in the loaded dataset:
q = load "0Fbxx000000002qCAA/0Fcxx000000002WCAQ";
q = foreach q generate 1 as num;
In the previous release, it returned one row.