fetch-concurrent-two-sources.td 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 FETCH-ing using multiple cursors from different sources works as expected
  12. #
  13. $ postgres-execute connection=postgres://mz_system:materialize@${testdrive.materialize-internal-sql-addr}
  14. ALTER SYSTEM SET min_timestamp_interval = '100ms'
  15. $ set int={"type": "record", "name": "field_int", "fields": [ {"name": "f1", "type": "int"} ] }
  16. $ kafka-create-topic topic=fetch-concurrent-two-sources
  17. > CREATE CONNECTION kafka_conn
  18. TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT);
  19. > CREATE SOURCE fetch_concurrent_two_sources1
  20. IN CLUSTER ${arg.single-replica-cluster}
  21. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-fetch-concurrent-two-sources-${testdrive.seed}')
  22. FORMAT AVRO USING SCHEMA '${int}'
  23. ENVELOPE NONE
  24. WITH (TIMESTAMP INTERVAL '100ms')
  25. > CREATE SOURCE fetch_concurrent_two_sources2
  26. IN CLUSTER ${arg.single-replica-cluster}
  27. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-fetch-concurrent-two-sources-${testdrive.seed}')
  28. FORMAT AVRO USING SCHEMA '${int}'
  29. ENVELOPE NONE
  30. WITH (TIMESTAMP INTERVAL '100ms')
  31. > CREATE MATERIALIZED VIEW fetch_concurrent_two_sources1_view AS SELECT * FROM fetch_concurrent_two_sources1 ORDER BY f1;
  32. > CREATE MATERIALIZED VIEW fetch_concurrent_two_sources2_view AS SELECT * FROM fetch_concurrent_two_sources2 ORDER BY f1;
  33. $ kafka-ingest format=avro topic=fetch-concurrent-two-sources schema=${int} timestamp=1
  34. {"f1": 12}
  35. $ kafka-ingest format=avro topic=fetch-concurrent-two-sources schema=${int} timestamp=2
  36. {"f1": 23}
  37. $ kafka-ingest format=avro topic=fetch-concurrent-two-sources schema=${int} timestamp=3
  38. {"f1": 34}
  39. > SELECT COUNT(*) FROM fetch_concurrent_two_sources1_view;
  40. 3
  41. > SELECT COUNT(*) FROM fetch_concurrent_two_sources2_view;
  42. 3
  43. > BEGIN
  44. > DECLARE c1 CURSOR FOR SELECT * FROM fetch_concurrent_two_sources1_view;
  45. > DECLARE c2 CURSOR FOR SELECT * FROM fetch_concurrent_two_sources2_view;
  46. > FETCH 1 c1;
  47. 12
  48. > FETCH 1 c2;
  49. 12
  50. > FETCH 1 c1;
  51. 23
  52. > FETCH 1 c2;
  53. 23
  54. > FETCH 1 c1;
  55. 34
  56. > FETCH 1 c2;
  57. 34