MERGE

MERGE(recordsetlist , SORTED( fieldlist ) [, DEDUP ] [, LOCAL ] [, UNORDERED | ORDERED( bool ) ] [, STABLE | UNSTABLE ] [, PARALLEL [ ( numthreads ) ] ] [, ALGORITHM( name ) ] )

MERGE(recordsetset , fieldlist , SORTED( fieldlist ) [, DEDUP ] [, LOCAL ] [, UNORDERED | ORDERED( bool ) ] [, STABLE | UNSTABLE ] [, PARALLEL [ ( numthreads ) ] ] [, ALGORITHM( name ) ] )

recordsetlistA comma-delimited list of the datasets or indexes to merge, which must all be in exactly the same format and sort order.
SORTEDSpecifies the sort order of the recordsetlist.
fieldlistA comma-delimited list of the fields that define the sort order.
DEDUPOptional. Specifies the result contains only records with unique values in the fields that specify the sort order fieldlist.
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.
recordsetsetA SET ( [ds1,ds2,ds3] ) of the datasets or indexes to merge, which must all be in exactly the same format.
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:MERGE returns a record set.

The MERGE function returns a single dataset or index containing all the records from the datasets or indexes named in the recordsetlist or recordsetset. This is particularly useful for incremental data updates as it allows you to merge a smaller set of new records into an existing large dataset or index without having to re-process all the source data again.

The recordsetset form makes merging a variable number of datasets possible when used inside a GRAPH function.

To write a MERGEd index to disk, you must use the BUILD action.

Example:

ds1 := SORTED(DATASET([{1,'A'},{1,'B'},{1,'C'},{1,'D'},{1,'E'},
                       {1,'F'},{1,'G'},{1,'H'},{1,'I'},{1,'J'}],
                      {INTEGER1 number,STRING1 Letter}),
              letter,number);
ds2 := SORTED(DATASET([{2,'A'},{2,'B'},{2,'C'},{2,'D'},{2,'E'},
                       {2,'F'},{2,'G'},{2,'H'},{2,'I'},{2,'J'}],
                      {INTEGER1 number,STRING1 Letter}),
              letter,number);
    
ds3 := MERGE(ds1,ds2,SORTED(letter,number));

SetDS := [ds1,ds2];
ds4 := MERGE(SetDS,SORTED(letter,number));

OUTPUT(ds3);
OUTPUT(ds4);

See Also: BUILD