pwj#

swordfish.function.pwj()#

Execuate prevailing window join.

The differences between pwj and wj are:

  • If rightTable doesn’t have a matching value for t+w1 (the left boundary of the window), wj will treat it as a null element in the window, whereas pwj will include the last value before t+w1 in the window.

  • If rightTable has multiple matching values for t+w1, wj will include all of them while pwj will only include the last row.

Parameters:
  • leftTable (Constant) – The table to be joined.

  • rightTable (Constant) – The table to be joined. It cannot be a DFS table.

  • window (Constant) – A pair of integers indicating the left bound and the right bound (both are inclusive) of the window relative to the records in the left table.

  • aggs (Constant) – Ametacode or a tuple of metacode indicating one or a list of aggregate functions/rightTable columns. For details please refer to Metaprogramming. If an aggregate function is specified, its parameters must be numeric columns of the right table. If a rightTable column is specified, the results for each window will be output in the form of array vectors.

  • matchingCols (Constant) – A string scalar/vector indicating matching columns.

  • rightMatchingCols (Constant, optional) – A string scalar/vector indicating all the matching columns in rightTable. This optional 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.