keyedStreamTable#

swordfish.function.keyedStreamTable()#

This function creates a stream table with one or more columns serving as the primary key. It implements idempotent writes to prevent duplicate primary key insertions due to network issues or high-availability writes.

When new records are inserted into a keyed stream table, the system checks the values of primary key.

  • If the primary key of a new record is identical to an existing one in memory, the new record is not inserted, and the existing record remains unchanged.

  • If multiple new records with the same primary key (different from those in memory) are written simultaneously, only the first record is successfully inserted.

Note

The uniqueness of the primary key is limited to data in memory. If persistence is enabled for the keyed stream table, a limited number of records are stored in memory, with older data being persisted to disk. The primary key of incoming data could potentially duplicate those on disk.