join

The join operator joins two arrays.

Synopsis

join(left_array,right_array);

Summary

The following table shows the relationship between input and output cells.

The join operator combines the attributes of two input arrays at matching dimension values. The two arrays must have the same dimension start coordinates and the same chunk overlap. The join result has the same dimension names as the first input. If the left-hand and right-hand arrays do not have the same dimension size, join returns an array with the same dimensions as the smaller input array. If a cell in either the left or right array is empty, the corresponding cell in the result is also empty.

Note the following:

  • join performs an inner join on dimension values.
  • SciDB matches Dimensions by their order rather than their name (first of left_array with first of right_array, and so on).
  • During the operation, compatibility of dimensions means the following:
    • Same number of dimensions
    • Same dimension boundaries for each corresponding pair
    • Same starting index value for each corresponding pair
    • Chunk sizes may differ, and if so, SciDB reconciles them by inserting a repart operator into the query plan.  This has a performance cost.
  • In the result array, the dimension names match the dimension names of left_array.
  • If the matching dimensions are not the same size, the smaller one appears in the result array.

Example

To join two arrays with different dimension lengths, do the following:

  1. Create a 3×3 array left_array containing value 1 in all cells:

    AFL% create array left_array <val:double>[i=0:2; j=0:2]; 
    AFL% store(build(left_array,1),left_array); 
  2. Create a 3×6 array right_array containing value 0 in all cells:

    AFL% create array right_array <val:double>[i=0:2; j=0:5];  
    AFL% store(build(right_array,0),right_array);  
  3. Join left_array and right_array:

    AFL% store(join(left_array,right_array),result_array); 


    The output is:

    {i,j} val,val_2
    {0,0} 1,0
    {0,1} 1,0
    {0,2} 1,0
    {1,0} 1,0
    {1,1} 1,0
    {1,2} 1,0
    {2,0} 1,0
    {2,1} 1,0
    {2,2} 1,0
    AFL% show(result_array);


    The output is:

    {i} schema
    {0} 'result_array<val:double,val_2:double> [i=0:2:0:1000; j=0:2:0:1000]'
  4. Remove the arrays:

    AFL% remove(left_array); remove(right_array); remove(result_array);

Â