types-temporal-with-tz.td 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 the temporal data types with time zone
  11. #
  12. > CREATE SECRET pgpass AS 'postgres'
  13. > CREATE CONNECTION pg TO POSTGRES (
  14. HOST postgres,
  15. DATABASE postgres,
  16. USER postgres,
  17. PASSWORD SECRET pgpass
  18. )
  19. # Insert data pre-snapshot
  20. $ postgres-execute connection=postgres://postgres:postgres@postgres
  21. ALTER USER postgres WITH replication;
  22. DROP SCHEMA IF EXISTS public CASCADE;
  23. DROP PUBLICATION IF EXISTS mz_source;
  24. CREATE SCHEMA public;
  25. CREATE TABLE time_table (f1 TIME WITH TIME ZONE);
  26. INSERT INTO time_table VALUES ('11:11:11.123456-09');
  27. INSERT INTO time_table VALUES ('11:11:11.123456+09');
  28. ALTER TABLE time_table REPLICA IDENTITY FULL;
  29. CREATE TABLE timestamp_table (f1 TIMESTAMPTZ);
  30. INSERT INTO timestamp_table VALUES ('2011-11-11 11:11:11.123456-09');
  31. INSERT INTO timestamp_table VALUES ('2011-11-11 11:11:11.123456+09');
  32. ALTER TABLE timestamp_table REPLICA IDENTITY FULL;
  33. CREATE PUBLICATION mz_source_time FOR TABLE time_table;
  34. CREATE PUBLICATION mz_source_timestamp FOR TABLE timestamp_table;
  35. > CREATE SOURCE mz_source_timestamp
  36. FROM POSTGRES CONNECTION pg (PUBLICATION 'mz_source_timestamp');
  37. > CREATE TABLE timestamp_table FROM SOURCE mz_source_timestamp (REFERENCE timestamp_table);
  38. > SELECT COUNT(*) > 0 FROM timestamp_table;
  39. true
  40. # Insert the same data post-snapshot
  41. $ postgres-execute connection=postgres://postgres:postgres@postgres
  42. INSERT INTO time_table SELECT * FROM time_table;
  43. INSERT INTO timestamp_table SELECT * FROM timestamp_table;
  44. > SELECT pg_typeof(f1) FROM timestamp_table LIMIT 1;
  45. "timestamp with time zone"
  46. > SELECT * FROM timestamp_table;
  47. "2011-11-11 02:11:11.123456 UTC"
  48. "2011-11-11 02:11:11.123456 UTC"
  49. "2011-11-11 20:11:11.123456 UTC"
  50. "2011-11-11 20:11:11.123456 UTC"
  51. > DROP SOURCE mz_source_timestamp CASCADE;
  52. > CREATE SOURCE mz_source
  53. FROM POSTGRES CONNECTION pg (PUBLICATION 'mz_source_time');
  54. # Mz does not support TIME WITH TIME ZOINE
  55. ! CREATE TABLE timestamp_table FROM SOURCE mz_source (REFERENCE time_table);
  56. contains:type "pg_catalog.timetz" does not exist