aj#
- swordfish.function.aj()#
The asof join function is used in non-synchronous join. It is similar to the left join function with the following differences:
Assume the last matching column is “time”. For a row in the left table with time=t, among the rows in the right table that match all other matching columns, if there is not a record with time=t, select the last row before time=t.
If there is only 1 joining column, the asof join function assumes the right table is sorted on the joining column. If there are multiple joining columns, the asof join function assumes the right table is sorted on the last joining column within each group defined by the other joining columns. The right table does not need to be sorted by the other joining columns. If these conditions are not met, unexpected results may be returned. The left table does not need to be sorted.
Note
If the left table of asof join is not a DFS table, its right table cannot be a DFS table either.
The data type of the last matching column is usually of temporal types. It can also be of integral types, UUID or IPADDR type.
If either the left table or the right table is a partitioned table, the joining columns except the last one must include all of the partitioning columns of the partitioned tables.
- Parameters:
leftTable (Constant) – A table
rightTable (Constant) – A table
matchingCols (Constant) – A STRING scalar/vector indicating matching columns.
rightMatchingCols (Constant, optional) – A STRING scalar/vector indicating all the matching columns in rightTable, by default DFLT. This argument must be specified if at least one of the matching columns has different names in leftTable and rightTable. The joining column names in the result will be the joining column names from the left table.