fetch-concurrent-two-sources.td 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. WITH (TIMESTAMP INTERVAL '100ms')
  23. > CREATE TABLE fetch_concurrent_two_sources1_tbl FROM SOURCE fetch_concurrent_two_sources1 (REFERENCE "testdrive-fetch-concurrent-two-sources-${testdrive.seed}")
  24. FORMAT AVRO USING SCHEMA '${int}'
  25. ENVELOPE NONE
  26. > CREATE SOURCE fetch_concurrent_two_sources2
  27. IN CLUSTER ${arg.single-replica-cluster}
  28. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-fetch-concurrent-two-sources-${testdrive.seed}')
  29. WITH (TIMESTAMP INTERVAL '100ms')
  30. > CREATE TABLE fetch_concurrent_two_sources2_tbl FROM SOURCE fetch_concurrent_two_sources2 (REFERENCE "testdrive-fetch-concurrent-two-sources-${testdrive.seed}")
  31. FORMAT AVRO USING SCHEMA '${int}'
  32. ENVELOPE NONE
  33. > CREATE MATERIALIZED VIEW fetch_concurrent_two_sources1_view AS SELECT * FROM fetch_concurrent_two_sources1_tbl ORDER BY f1;
  34. > CREATE MATERIALIZED VIEW fetch_concurrent_two_sources2_view AS SELECT * FROM fetch_concurrent_two_sources2_tbl ORDER BY f1;
  35. $ kafka-ingest format=avro topic=fetch-concurrent-two-sources schema=${int} timestamp=1
  36. {"f1": 12}
  37. $ kafka-ingest format=avro topic=fetch-concurrent-two-sources schema=${int} timestamp=2
  38. {"f1": 23}
  39. $ kafka-ingest format=avro topic=fetch-concurrent-two-sources schema=${int} timestamp=3
  40. {"f1": 34}
  41. > SELECT COUNT(*) FROM fetch_concurrent_two_sources1_view;
  42. 3
  43. > SELECT COUNT(*) FROM fetch_concurrent_two_sources2_view;
  44. 3
  45. > BEGIN
  46. > DECLARE c1 CURSOR FOR SELECT * FROM fetch_concurrent_two_sources1_view;
  47. > DECLARE c2 CURSOR FOR SELECT * FROM fetch_concurrent_two_sources2_view;
  48. > FETCH 1 c1;
  49. 12
  50. > FETCH 1 c2;
  51. 12
  52. > FETCH 1 c1;
  53. 23
  54. > FETCH 1 c2;
  55. 23
  56. > FETCH 1 c1;
  57. 34
  58. > FETCH 1 c2;
  59. 34