89 lines
3.3 KiB
Plaintext
89 lines
3.3 KiB
Plaintext
> -- Important: using the same partition key for each row so the results of select from log table
|
|
> -- do not depend on how stream IDs are assigned to partition keys.
|
|
>
|
|
> -- Error messages contain a keyspace name. Make the output stable.
|
|
> CREATE KEYSPACE ks
|
|
> WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1};
|
|
OK
|
|
>
|
|
> -- create cdc enabled table
|
|
> create table ks.t (pk int, ck int, v int, primary key(pk, ck)) with cdc = {'enabled': true};
|
|
OK
|
|
>
|
|
> -- this write goes to the log
|
|
> insert into ks.t (pk, ck, v) values (0, 1, 100);
|
|
OK
|
|
>
|
|
> -- disable cdc. should retain the log
|
|
> alter table ks.t with cdc = {'enabled': false};
|
|
OK
|
|
>
|
|
> -- add more data to base - should not generate log
|
|
> insert into ks.t (pk, ck, v) values (0, 2, 200);
|
|
OK
|
|
>
|
|
> -- should still work, and give one row (0, 1, 100)
|
|
> select "cdc$batch_seq_no", "cdc$operation", "cdc$ttl", pk, ck, v from ks.t_scylla_cdc_log;
|
|
+--------------------+-----------------+-----------+------+------+-----+
|
|
| cdc$batch_seq_no | cdc$operation | cdc$ttl | pk | ck | v |
|
|
|--------------------+-----------------+-----------+------+------+-----|
|
|
| 0 | 2 | null | 0 | 1 | 100 |
|
|
+--------------------+-----------------+-----------+------+------+-----+
|
|
>
|
|
> -- lets add a column
|
|
> alter table ks.t add v2 text;
|
|
OK
|
|
>
|
|
> -- add more data
|
|
> insert into ks.t (pk, ck, v, v2) values (0, 3, 300, 'apa');
|
|
OK
|
|
>
|
|
> -- turn cdc back on
|
|
> alter table ks.t with cdc = {'enabled': true};
|
|
OK
|
|
>
|
|
> -- more data - this should also go to log.
|
|
> insert into ks.t (pk, ck, v, v2) values (0, 4, 400, 'snus');
|
|
OK
|
|
>
|
|
> -- gives two rows (0, 1, 100)+(0, 4, 400, 'snus')
|
|
> select "cdc$batch_seq_no", "cdc$operation", "cdc$ttl", pk, ck, v, v2 from ks.t_scylla_cdc_log;
|
|
+--------------------+-----------------+-----------+------+------+-----+------+
|
|
| cdc$batch_seq_no | cdc$operation | cdc$ttl | pk | ck | v | v2 |
|
|
|--------------------+-----------------+-----------+------+------+-----+------|
|
|
| 0 | 2 | null | 0 | 1 | 100 | null |
|
|
| 0 | 2 | null | 0 | 4 | 400 | snus |
|
|
+--------------------+-----------------+-----------+------+------+-----+------+
|
|
>
|
|
> -- disable cdc. should retain the log
|
|
> alter table ks.t with cdc = {'enabled': false};
|
|
OK
|
|
>
|
|
> -- remove older column
|
|
> alter table ks.t drop v;
|
|
OK
|
|
>
|
|
> -- add more data
|
|
> insert into ks.t (pk, ck, v2) values (0, 5, 'fisk');
|
|
OK
|
|
>
|
|
> -- turn cdc back on
|
|
> alter table ks.t with cdc = {'enabled': true};
|
|
OK
|
|
>
|
|
> insert into ks.t (pk, ck, v2) values (0, 6, 'aborre');
|
|
OK
|
|
>
|
|
> -- gives three rows (0, 1)+(0, 4, 'snus')+(0, 6, 'aborre')
|
|
> select "cdc$batch_seq_no", "cdc$operation", "cdc$ttl", pk, ck, v2 from ks.t_scylla_cdc_log;
|
|
+--------------------+-----------------+-----------+------+------+--------+
|
|
| cdc$batch_seq_no | cdc$operation | cdc$ttl | pk | ck | v2 |
|
|
|--------------------+-----------------+-----------+------+------+--------|
|
|
| 0 | 2 | null | 0 | 1 | null |
|
|
| 0 | 2 | null | 0 | 4 | snus |
|
|
| 0 | 2 | null | 0 | 6 | aborre |
|
|
+--------------------+-----------------+-----------+------+------+--------+
|
|
>
|
|
> DROP KEYSPACE ks;
|
|
OK
|