two-source-schemas.td 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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-sql-timeout duration=1s
  10. #
  11. # Test that identically-named tables in two source schemas can be
  12. # successfully disambiguated and replicated
  13. #
  14. > CREATE SECRET mysqlpass AS '${arg.mysql-root-password}'
  15. > CREATE CONNECTION mysql_conn TO MYSQL (
  16. HOST mysql,
  17. USER root,
  18. PASSWORD SECRET mysqlpass
  19. )
  20. $ mysql-connect name=mysql url=mysql://root@mysql password=${arg.mysql-root-password}
  21. $ mysql-execute name=mysql
  22. DROP SCHEMA IF EXISTS schema1;
  23. CREATE SCHEMA schema1;
  24. CREATE TABLE schema1.t1 (f1 INTEGER);
  25. INSERT INTO schema1.t1 VALUES (1);
  26. DROP SCHEMA IF EXISTS schema2;
  27. CREATE SCHEMA schema2;
  28. CREATE TABLE schema2.t1 (f1 INTEGER);
  29. INSERT INTO schema2.t1 VALUES (2);
  30. INSERT INTO schema1.t1 SELECT * FROM schema1.t1;
  31. INSERT INTO schema2.t1 SELECT * FROM schema2.t1;
  32. ! CREATE SOURCE mz_source
  33. FROM MYSQL CONNECTION mysql_conn
  34. FOR ALL TABLES;
  35. contains:multiple subsources would be named t1
  36. # TODO: database-issues#7397
  37. # ! CREATE SOURCE mz_source
  38. # FROM MYSQL CONNECTION mysql_conn
  39. # FOR TABLES (t1);
  40. # contains:table t1 is ambiguous, consider specifying the schema
  41. > CREATE SOURCE mz_source
  42. FROM MYSQL CONNECTION mysql_conn
  43. FOR TABLES (schema1.t1);
  44. > SELECT * FROM t1;
  45. 1
  46. 1
  47. > DROP SOURCE mz_source CASCADE;
  48. > CREATE SOURCE mz_source
  49. FROM MYSQL CONNECTION mysql_conn
  50. FOR TABLES (schema1.t1 AS t1_1, schema2.t1 AS t1_2);
  51. > SELECT * FROM t1_1;
  52. 1
  53. 1
  54. > SELECT * FROM t1_2;
  55. 2
  56. 2
  57. $ mysql-execute name=mysql
  58. DROP SCHEMA schema1;
  59. DROP SCHEMA schema2;
  60. > DROP SOURCE mz_source CASCADE;