ch .join()

Description:

A foreign-key-style join between a channel and a record sequence.

Syntax:

ch.join(C:.,T:K,x:F,…; …;…)

Note:

The function uses the key of table sequence/record sequence T to match C,field in channel ch, and add an F field to ch by joining T’s field expression x to for a new channel. K can be omitted or represented by #; when it is omitted, use T’s key; when represented by #, the key is pointed by a sequence number. This is an attached computation.

Options:

@i

Delete the whole record if the foreign key can’t be matched; by default make it null.

@o(F;)

Generate a new record by introducing the original record as a new field; field expression x can be represented by ~.

Parameters:

ch

Channel

C

Foreign key of a given channel; use comma to separate a composite key

T

Table sequence/record sequence

K

Key of the given table sequence/record sequence

x

A field expression of the given table sequence/record sequence

F

Name of the field expression

Return value:

Channel

Example:

 

A

 

1

=demo.cursor("select EID,NAME,SALARY from EMPLOYEE

 order by  EID" )

 

2

=demo.query("select *

from PERFORMANCE order by

  EMPLOYEEID").keys(EMPLOYEEID)

 

3

=channel()

Create a channel

4

=channel()

 

5

=channel()

 

6

=channel()

 

7

=A1.push(A3,A4,A5,A6)

Be ready to push data in A1’s cursor into channel A3,A4,A5 and A6, but the action needs to wait

8

=A3.join(EID,A2, BONUS+1:SALARY1)

A normal join, where a record can’t be matched with the foreign key is recorded as null

9

=A8.fetch()

Fetch and store the existing data in the channel

10

=A4.join@i(EID,A2: #1, #3+1:SALARY1)

#1 represents the first field, and #3 represents the third field

11

=A10.fetch()

 

12

=A5.join@i(EID,A2, BONUS+1:SALARY1)

Delete the whole record since it doesn’t match the foreign key

13

=A12.fetch()

 

14

=A6.join@o(F1;EID,A2,~.BONUS+1:SALARY1)

Make the original record as the F1 field

15

=A14.fetch()

 

16

=A1.fetch()

 

17

=A3.result()

18

=A4.result()

19

=A5.result()

Get the same result as A18

20

=A6.result()