StreamBase supports table delta streams, which are special-purpose output streams that track changes to Query Tables. If you enable a table delta stream for a Query Table, then every insert, update, or delete operation on the data in the table causes the delta stream to emit a tuple that represents the change.
Enable a delta stream with these steps:
-
Double-click the Query Table icon to open its Properties view.
-
In the Table Settings tab, select Yes for the Enable Delta Stream Port control.
-
Save the EventFlow module or click anywhere in the canvas. The Query Table now shows a connection port on its right corner.
-
Connect an Output Stream or other operator to this connection port to consume the table change information.
Studio assigns a name for the delta stream based on the pattern
, where tablename
_num
_deltanum
is the number of the table's output ports, which is almost always 1.
A table delta stream's schema has four fields:
Field | Data Type | Contents |
---|---|---|
operation | string | The operation type, one of insert , update , or delete .
|
modifyCount | long | An incrementing number that keeps a count of modifications to the Query Table since the module containing this table was started.
Each modification attempt causes the number to increment.
A failed modification (such as an update that results in no row changes) still increments the modification count. Thus, the
|
old | tuple | For delete and insert operations, a tuple showing the contents of the row deleted or the row before an update operation. |
new | tuple | For insert and update operations, a tuple showing the contents of the row inserted or the row after an update operation. |
When you enable a delta stream for a table, the schema for the delta stream's old
and new
fields is automatically set the same as the schema of the table itself:
-
If the table's schema is defined with a named schema or table schema, the
old
andnew
tuples are defined with those schemas. If you change the named or table schema, the Query Table and its delta stream tuples update at the same time. -
If your Query Table is defined with an unnamed schema, and you later change the schema of the Query Table, you must explicitly update the fields in the table delta stream to match.