PROJECT( recordset, transform [, PREFETCH [ (lookahead [, PARALLEL]) ] ] [, KEYED ] [, LOCAL ] [, UNORDERED | ORDERED( bool ) ] [, STABLE | UNSTABLE ] [, PARALLEL [ ( numthreads ) ] ] [, ALGORITHM( name ) ] )

PROJECT( recordset, record [, PREFETCH [ (lookahead [, PARALLEL]) ] ] [, KEYED ] [, LOCAL ] [, UNORDERED | ORDERED( bool ) ] [, STABLE | UNSTABLE ] [, PARALLEL [ ( numthreads ) ] ] [, ALGORITHM( name ) ] )

recordsetThe set of records to process. This may be a single-record in-line DATASET.
transformThe TRANSFORM function to call for each record in the recordset.
PREFETCHOptional. Allows index reads within the transform to be as efficient as keyed JOINs. Valid for use only in Roxie queries.
lookaheadOptional. Specifies the number of look-ahead reads. If omitted, the default is the value of the _PrefetchProjectPreload tag in the submitted query. If that is omitted, then it is taken from the value of defaultPrefetchProjectPreload specified in the RoxieTopology file when the Roxie was deployed. If that is omitted, it defaults to 10.
PARALLELOptional. Specifies the lookahead is done on a separate thread, in parallel with query execution.
KEYEDOptional. Specifies the activity is part of an index read operation, which allows the optimizer to generate optimal code for the operation.
LOCALOptional. Specifies the operation is performed on each supercomputer node independently, without requiring interaction with all other nodes to acquire data; the operation maintains the distribution of any previous DISTRIBUTE.
recordThe output RECORD structure to use for each record in the recordset.
UNORDEREDOptional. Specifies the output record order is not significant.
ORDEREDSpecifies the significance of the output record order.
boolWhen False, specifies the output record order is not significant. When True, specifies the default output record order.
STABLEOptional. Specifies the input record order is significant.
UNSTABLEOptional. Specifies the input record order is not significant.
PARALLELOptional. Try to evaluate this activity in parallel.
numthreadsOptional. Try to evaluate this activity using numthreads threads.
ALGORITHMOptional. Override the algorithm used for this activity.
nameThe algorithm to use for this activity. Must be from the list of supported algorithms for the SORT function's STABLE and UNSTABLE options.
Return:PROJECT returns a record set.

The PROJECT function processes through all records in the recordset performing the transform function on each record in turn.

The PROJECT(recordset,record) form is simply a shorthand synonym for:

PROJECT(recordset,TRANSFORM(record,SELF := LEFT)).

making it simple to move data from one structure to another without a TRANSFORM as long as all the fields in the output record structure are present in the input recordset.

TRANSFORM Function Requirements - PROJECT

The transform function must take at least one parameter: a LEFT record of the same format as the recordset. Optionally, it may take a second parameter: an integer COUNTER specifying the number of times the transform has been called for the recordset or the current group in the recordset (see the GROUP function). The second parameter form is useful for adding sequence numbers. The format of the resulting record set does not need to be the same as the input.


//form one example **********************************
Ages := RECORD
  STRING15 per_first_name;
  STRING25 per_last_name;
TodaysYear := 2001;

Ages CalcAges(person l) := TRANSFORM
  SELF.Age := TodaysYear - l.birthdate[1..4];
  SELF := l;
AgedRecs := PROJECT(person, CalcAges(LEFT));

//COUNTER example **********************************
SequencedAges := RECORD
  INTEGER8 Sequence := 0;

SequencedAges AddSequence(Ages l, INTEGER c) :=
  SELF.Sequence := c;
  SELF := l;
SequencedAgedRecs := PROJECT(AgedRecs,

//form two example **********************************
NewRec := RECORD
  STRING15 firstname;
  STRING25 lastname;
  STRING15 middlename;
NewRecs := PROJECT(People,NewRec);
//equivalent to:
//NewRecs := PROJECT(People,TRANSFORM(NewRec,SELF :=

//LOCAL example **********************************
  STRING1 Value1;
  STRING1 Value2;

SomeFile := DATASET([{'C','G'},{'C','C'},{'A','X'},

MyOutRec := RECORD
  STRING6 CatValues;

DistFile := DISTRIBUTE(SomeFile,HASH32(Value1,Value2));

MyOutRec CatThem(SomeFile L, INTEGER C) := TRANSFORM
  SELF.CatValues := L.Value1 + L.Value2 + '-' +
                    (Std.System.Thorlib.Node()+1) + '-' + (STRING)C;
  SELF := L;



/* CatRecs result set is:
Rec# Value1 Value2 CatValues
1      C      C      CC-1-1
2      B      G      BG-2-1
3      A      X      AX-2-2
4      A      B      AB-3-1
5      C      G      CG-3-2

See Also: TRANSFORM Structure, RECORD Structure, ROW, DATASET