mz-setup.td 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. $ kafka-create-topic topic=input_1
  10. $ kafka-ingest topic=input_1 format=bytes repeat=100
  11. A,B,0
  12. $ kafka-create-topic topic=input_2
  13. $ kafka-ingest topic=input_2 format=bytes repeat=100
  14. A,B,0
  15. > CREATE CONNECTION IF NOT EXISTS kafka_conn_1 TO KAFKA (BROKER 'toxiproxy:9092', SECURITY PROTOCOL PLAINTEXT);
  16. > CREATE CONNECTION IF NOT EXISTS kafka_conn_2 TO KAFKA (BROKER 'toxiproxy:8092', SECURITY PROTOCOL PLAINTEXT);
  17. > CREATE SOURCE input_1
  18. FROM KAFKA CONNECTION kafka_conn_1 (TOPIC 'testdrive-input_1-${testdrive.seed}')
  19. > CREATE TABLE input_1_tbl (city, state, zip) FROM SOURCE input_1 (REFERENCE "testdrive-input_1-${testdrive.seed}")
  20. FORMAT CSV WITH 3 COLUMNS
  21. > CREATE SOURCE input_2
  22. FROM KAFKA CONNECTION kafka_conn_2 (TOPIC 'testdrive-input_2-${testdrive.seed}')
  23. > CREATE TABLE input_2_tbl (city, state, zip) FROM SOURCE input_2 (REFERENCE "testdrive-input_2-${testdrive.seed}")
  24. FORMAT CSV WITH 3 COLUMNS
  25. > CREATE TABLE t (a int);
  26. > INSERT INTO t VALUES (1);
  27. > CREATE MATERIALIZED VIEW sum AS
  28. SELECT sum(count)
  29. FROM (
  30. SELECT count(*) FROM input_1_tbl
  31. UNION ALL SELECT count(*) FROM input_2_tbl
  32. UNION ALL SELECT count(*) FROM t
  33. ) AS x;
  34. > SET TRANSACTION_ISOLATION = 'STRICT SERIALIZABLE'
  35. > SET REAL_TIME_RECENCY TO TRUE
  36. > SELECT * FROM sum
  37. 201