35-exclude-columns.td 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. #
  10. # Test mysql TEXT COLUMNS support
  11. #
  12. > CREATE SECRET mysqlpass AS '${arg.mysql-root-password}'
  13. > CREATE CONNECTION mysqc TO MYSQL (
  14. HOST mysql,
  15. USER root,
  16. PASSWORD SECRET mysqlpass
  17. )
  18. $ mysql-connect name=mysql url=mysql://root@mysql password=${arg.mysql-root-password}
  19. $ mysql-execute name=mysql
  20. DROP DATABASE IF EXISTS public;
  21. CREATE DATABASE public;
  22. USE public;
  23. CREATE TABLE t1 (f1 INTEGER, f2 GEOMETRY, f3 POINT, f4 VARCHAR(64));
  24. INSERT INTO t1 VALUES (1, ST_GeomFromText('LINESTRING(0 0,1 1,2 2)'), ST_GeomFromText('POINT(1 1)'), 'test');
  25. > CREATE SOURCE da
  26. FROM MYSQL CONNECTION mysqc;
  27. ! CREATE TABLE t1 FROM SOURCE da (REFERENCE public.t1);
  28. contains: unsupported type
  29. ! CREATE TABLE t1 FROM SOURCE da (REFERENCE public.t1) WITH (TEXT COLUMNS (f2), EXCLUDE COLUMNS (f2, f3));
  30. contains: duplicated column name references in table
  31. > CREATE TABLE t1 FROM SOURCE da (REFERENCE public.t1) WITH (EXCLUDE COLUMNS (f2, f3));
  32. # Insert the same data post-snapshot
  33. $ mysql-execute name=mysql
  34. USE public;
  35. INSERT INTO t1 SELECT * FROM t1;
  36. > SELECT * FROM t1;
  37. 1 "test"
  38. 1 "test"
  39. > SELECT f4 FROM t1;
  40. "test"
  41. "test"
  42. $ set-regex match="DETAILS = '[a-f0-9]+'" replacement=<DETAILS>
  43. > SHOW CREATE TABLE t1;
  44. materialize.public.t1 "CREATE TABLE materialize.public.t1 (f1 pg_catalog.int4, f4 pg_catalog.varchar(64)) FROM SOURCE materialize.public.da (REFERENCE = public.t1) WITH (EXCLUDE COLUMNS = (f2, f3), <DETAILS>);"
  45. ! SELECT f2 FROM t1;
  46. contains:column "f2" does not exist
  47. # Remove one of the ignored columns, and we should still error
  48. $ mysql-execute name=mysql
  49. ALTER TABLE t1 DROP COLUMN f2;
  50. ! select * from t1;
  51. contains:incompatible schema change