two-source-schemas.td 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 FROM MYSQL CONNECTION mysql_conn;
  33. > CREATE TABLE t1 FROM SOURCE mz_source (REFERENCE schema1.t1);
  34. ! CREATE TABLE t1 FROM SOURCE mz_source (REFERENCE schema2.t1);
  35. contains:catalog item 't1' already exists
  36. # TODO: database-issues#7397
  37. # CREATE TABLE t1 FROM SOURCE mz_source (REFERENCE t1);
  38. # contains:table t1 is ambiguous, consider specifying the schema
  39. > SELECT * FROM t1;
  40. 1
  41. 1
  42. > DROP SOURCE mz_source CASCADE;
  43. > CREATE SOURCE mz_source FROM MYSQL CONNECTION mysql_conn;
  44. > CREATE TABLE t1_1 FROM SOURCE mz_source (REFERENCE schema1.t1);
  45. > CREATE TABLE t1_2 FROM SOURCE mz_source (REFERENCE schema2.t1);
  46. > SELECT * FROM t1_1;
  47. 1
  48. 1
  49. > SELECT * FROM t1_2;
  50. 2
  51. 2
  52. $ mysql-execute name=mysql
  53. DROP SCHEMA schema1;
  54. DROP SCHEMA schema2;
  55. > DROP SOURCE mz_source CASCADE;