page217
303
Testing Streams
When developing a test case, you carry out these steps:
1.
Create a staging table.
2.
Populate the staging table with test data.
3.
Run a
MERGE
statement.
4.
TRUNCATE
the staging table.
5.
Create five streams.
6.
Populate the staging table with test data.
If you examine the contents of a single stream, you observe a single record (step 6).
SELECT count(1),
metadata$action,
metadata$isupdate
FROM strm_part_customer_order_asia
WHERE region_name = 'ASIA'
GROUP BY metadata$action,
metadata$isupdate;
You should see 30,000
INSERT
s, as shown in Figure 8-20.
Figure 8-20.
Stream output
By design intent streams do not record
UPDATE
s but instead record
UPDATE
s as a
pair of
INSERT
and
DELETE
operations where
metadata$isupdate
is set to true. Where
metadata$isupdate
is set to
false
, this indicates the DML operations are not related.
Use
metadata$row_id
to correlate
INSERT
and
DELETE
pairs, an exercise left to you.
For this use case you can use the presence of data in a
STREAM
to trigger a
TASK
, which
calls a stored procedure where you consume from the stream.
Chapter 8
parallelization