mz-setup.td 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. $ mysql-connect name=mysql url=mysql://root@mysql password=${arg.mysql-root-password}
  10. $ mysql-execute name=mysql
  11. DROP DATABASE IF EXISTS public;
  12. CREATE DATABASE public;
  13. USE public;
  14. CREATE TABLE table_a (x int, y int);
  15. CREATE TABLE table_b (x int, y int);
  16. INSERT INTO table_a SELECT 1,2 FROM mysql.time_zone t1, mysql.time_zone t2 LIMIT 100;
  17. INSERT INTO table_b SELECT 1,2 FROM mysql.time_zone t1, mysql.time_zone t2 LIMIT 100;
  18. > CREATE SECRET mysqlpass AS '${arg.mysql-root-password}'
  19. > CREATE CONNECTION mysql_conn_1 TO MYSQL (
  20. HOST toxiproxy,
  21. PORT 3306,
  22. USER root,
  23. PASSWORD SECRET mysqlpass
  24. )
  25. > CREATE CONNECTION mysql_conn_2 TO MYSQL (
  26. HOST toxiproxy,
  27. PORT 2306,
  28. USER root,
  29. PASSWORD SECRET mysqlpass
  30. )
  31. > CREATE SOURCE mysql_source1
  32. FROM MYSQL CONNECTION mysql_conn_1
  33. FOR TABLES (public.table_a);
  34. > CREATE SOURCE mysql_source2
  35. FROM MYSQL CONNECTION mysql_conn_2
  36. FOR TABLES (public.table_b);
  37. > CREATE TABLE t (a int);
  38. > INSERT INTO t VALUES (1);
  39. > CREATE MATERIALIZED VIEW sum AS
  40. SELECT sum(count)
  41. FROM (
  42. SELECT count(*) FROM table_a
  43. UNION ALL SELECT count(*) FROM table_b
  44. UNION ALL SELECT count(*) FROM t
  45. ) AS x;