Skip to main content


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

PROJECT - Module

PROJECT( module, interface [, OPT | attributelist ] )

moduleThe MODULE structure containing the attribute definitions whose values to pass as the interface.
interfaceThe INTERFACE structure to pass.
OPTOptional. Suppresses the error message that is generated when an attribute defined in the interface is not also defined in the module.
attributelistOptional. A comma-delimited list of the specific attributes in the module to supply to the interface. This allows a specified list of attributes to be implemented, which is useful if you want closer control, or if the types of the parameters don't match.
Return:PROJECT returns a MODULE compatible with the interface.

The PROJECT function passes a module's attributes in the form of the interface to a function defined to accept parameters structured like the specified interface. This allows you to create a module for one interface with the values being provided by another interface. The attributes in the module must be compatible with the attributes in the interface (same type and same parameters, if any take parameters).


/*is broadly equivalent to
  SomeAttributeInY := x.someAttributeInY
  //... repeated for all attributes in Y ...

myService(myInterface myArgs) := FUNCTION
  childArgs := MODULE(PROJECT(myArgs,Iface,isDead,did,ssn,address))
    BOOLEAN isFCRA := myArgs.isFCRA OR myArgs.fakeFCRA
  RETURN childService(childArgs);

// you could directly pass PROJECT as a module parameter
// to an attribute:
myService(myInterface myArgs) := childService(PROJECT(myArgs, childInterface));

See Also: MODULE Structure, INTERFACE Structure, FUNCTION Structure, STORED