Description:
Compute one or more expressions against each member in a sequence/record sequence and return a sequence composed of values of the expression.
Syntax:
A.run(x) |
Compute one expression only |
A.run(x1,x2,…xi) |
Compute multiple expressions |
Note:
The function computes expressions xi with each member in sequence/record sequence A and return the modified A. For example, when x is col1=col2+1, it will change the field value of col1.
Parameter:
A |
A sequence/ record sequence |
x |
An expression, which is generally a field name or a legal expression that is composed of field names, and in which "~" is used to reference the current record |
Option:
@m |
Use parallel algorithm to handle data-intensive or computation-intensive tasks; no definite order for the records in the result set |
@z |
Perform the inverse operation; only apply to non-pure sequences |
Return value:
Sequence/Record sequence
Example:
Use run function to modify the member values.
|
A |
|
1 |
=[1,2,3,4,5] |
|
2 |
=A1.run(~=~*~) |
[1,4,9,16,25], use "~" to reference the current member. |
Use run function to switch from EID to Name
|
A |
|
|
1 |
=demo.query("select * from EMPLOYEE").keys(EID) |
|
|
2 |
=demo.query("select * from DEPARTMENT") |
|
|
3 |
=A2.run(MANAGER=A1.select@1(EID==A2.MANAGER).NAME) |
|
|
4 |
=demo.query("select * from EMPLOYEE") |
|
|
5 |
=demo.query("select * from DEPARTMENT") |
|
|
6 |
=A5.run@m(MANAGER=A4.select@1(EID==A5.MANAGER).NAME) |
Use @m option to increase performance of big data handling. |
|
Use run function to link tables
|
A |
|
1 |
=demo.query("select * from EMPLOYEE") |
|
2 |
=demo.query("select * from DEPARTMENT") |
|
3 |
=A2.run(MANAGER=A1.select@1(EID== A2.MANAGER)) |
|
4 |
=A2.MANAGER.STATE |
California. When the field value is a record, the dot operator is used to reference a member within the record. |
Perform the inverse operation:
|
A |
|
1 |
=[1,2,3].run(~=iterate(~~+~)) |
[1,3,6]. |
2 |
=[1,2,3].run@z(~=iterate(~~+~)) |
Use @z option to perform the inverse operation and return result: [3,5,6]. |
Note:
Difference between A.(x) and A.run(x):
A.(x) evaluates expression x and returns a sequence composed of the values of this expression;
A.run(x) is modifies sequence/record sequence A through the computation of x and returns A which has been modified
Related function: