fetch-tail-without-snapshot.td 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. $ set-arg-default single-replica-cluster=quickstart
  10. #
  11. # Make sure that the SNAPSHOT=FALSE option is observed
  12. #
  13. $ set-regex match=\d{13} replacement=<TIMESTAMP>
  14. $ set int={"type": "record", "name": "field_int", "fields": [ {"name": "f1", "type": "int"} ] }
  15. $ kafka-create-topic topic=tail-without-snapshot
  16. $ kafka-ingest format=avro topic=tail-without-snapshot schema=${int} timestamp=1
  17. {"f1": 123}
  18. {"f1": 234}
  19. {"f1": 345}
  20. > CREATE CONNECTION kafka_conn
  21. TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT);
  22. > CREATE SOURCE tail_without_snapshot
  23. IN CLUSTER ${arg.single-replica-cluster}
  24. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-tail-without-snapshot-${testdrive.seed}')
  25. > CREATE TABLE tail_without_snapshot_tbl FROM SOURCE tail_without_snapshot (REFERENCE "testdrive-tail-without-snapshot-${testdrive.seed}")
  26. FORMAT AVRO USING SCHEMA '${int}'
  27. ENVELOPE NONE
  28. > SELECT * FROM tail_without_snapshot_tbl;
  29. 123
  30. 234
  31. 345
  32. > BEGIN
  33. > DECLARE c CURSOR FOR SUBSCRIBE tail_without_snapshot_tbl WITH (SNAPSHOT = FALSE);
  34. > FETCH 1 FROM c WITH (timeout = '2s')
  35. $ kafka-ingest format=avro topic=tail-without-snapshot schema=${int} timestamp=1
  36. {"f1": 567}
  37. > FETCH 1 FROM c WITH (timeout = '60s')
  38. <TIMESTAMP> 1 567