tableUpsert#

swordfish.function.tableUpsert()#

Insert rows into a table if the values with the key do not already exist, or update them if they do.

Parameters:
  • obj (Constant) – A keyed table, indexed table, or a DFS table.

  • newData (Constant) – An in-memory table.

  • ignoreNull (Constant, optional) – A Boolean value, by default DFLT. If set to true, for the null values in newData, the corresponding elements in obj are not updated.

  • keyColNames (Constant, optional) – A STRING scalar/vector, by default DFLT. When obj is a DFS table, keyColNames are considered as the key columns.

  • sortColumns (Constant, optional) –

    A STRING scalar or vector, by default DFLT. The updated partitions will be sorted on sortColumns (only within each partition, not across partitions).

    Note

    • sortColumns is supported in upser_ only with the OLAP engine.

    • To specify sortColumns, obj must be a DFS table.

    • When obj is an empty table, setting sortColumns has no effect. That is, the system will not sort the inserted data.

Returns:

A LONG pair. The first element represents the number of inserted records, and the second represents the number of updated records.

Return type:

Constant