35-exclude-columns.td 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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_other
  26. FROM MYSQL CONNECTION mysqc
  27. FOR TABLES (public.t1);
  28. contains: unsupported type
  29. ! CREATE SOURCE da
  30. FROM MYSQL CONNECTION mysqc (
  31. EXCLUDE COLUMNS (t1.f2, t1.f3)
  32. )
  33. FOR TABLES (public.t1);
  34. contains:invalid EXCLUDE COLUMNS option value: column name 't1.f2' must have at least a table qualification
  35. > CREATE SOURCE da
  36. FROM MYSQL CONNECTION mysqc (
  37. EXCLUDE COLUMNS (public.t1.f2, public.t1.f3)
  38. )
  39. FOR TABLES (public.t1);
  40. # Insert the same data post-snapshot
  41. $ mysql-execute name=mysql
  42. USE public;
  43. INSERT INTO t1 SELECT * FROM t1;
  44. > SELECT * FROM t1;
  45. 1 "test"
  46. 1 "test"
  47. > SELECT f4 FROM t1;
  48. "test"
  49. "test"
  50. >[version>=14000] SHOW CREATE SOURCE t1;
  51. materialize.public.t1 "CREATE SUBSOURCE materialize.public.t1 (f1 pg_catalog.int4, f4 pg_catalog.varchar(64)) OF SOURCE materialize.public.da WITH (EXTERNAL REFERENCE = public.t1, EXCLUDE COLUMNS = (f2, f3));"
  52. >[version<14000] SHOW CREATE SOURCE t1;
  53. materialize.public.t1 "CREATE SUBSOURCE \"materialize\".\"public\".\"t1\" (\"f1\" \"pg_catalog\".\"int4\", \"f4\" \"pg_catalog\".\"varchar\"(64)) OF SOURCE \"materialize\".\"public\".\"da\" WITH (EXTERNAL REFERENCE = \"public\".\"t1\", EXCLUDE COLUMNS = (\"f2\", \"f3\"))"
  54. ! SELECT f2 FROM t1;
  55. contains:column "f2" does not exist
  56. # Remove one of the ignored columns, and we should still error
  57. $ mysql-execute name=mysql
  58. ALTER TABLE t1 DROP COLUMN f2;
  59. ! select * from t1;
  60. contains:incompatible schema change