28-types-uuid.td 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. # Make sure that the UUID type is replicated correctly
  11. #
  12. $ postgres-execute connection=postgres://postgres:postgres@postgres
  13. CREATE TABLE uuid_type (pk_col UUID PRIMARY KEY, nopk_col UUID);
  14. ALTER TABLE uuid_type REPLICA IDENTITY FULL;
  15. INSERT INTO uuid_type VALUES ('a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11', 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11');
  16. $ schema-registry-wait topic=postgres.public.uuid_type
  17. > CREATE CONNECTION IF NOT EXISTS csr_conn TO CONFLUENT SCHEMA REGISTRY (
  18. URL '${testdrive.schema-registry-url}'
  19. );
  20. > CREATE CONNECTION IF NOT EXISTS kafka_conn TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT);
  21. > CREATE SOURCE uuid_type
  22. FROM KAFKA CONNECTION kafka_conn (TOPIC 'postgres.public.uuid_type');
  23. > CREATE TABLE uuid_type_tbl FROM SOURCE uuid_type (REFERENCE "postgres.public.uuid_type")
  24. FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn
  25. ENVELOPE DEBEZIUM;
  26. #
  27. # UUID columns arrive as string from Debezium without a logicalType
  28. # Debezium ticket: DBZ-3555 UUID columns from Postgres are not registered as logicalType uuid in the Schema Registry
  29. #
  30. # The relevant part of the schema looks like this:
  31. #
  32. # {
  33. # "type" : {
  34. # "connect.version" : 1,
  35. # "type" : "string",
  36. # "connect.name" : "io.debezium.data.Uuid"
  37. # },
  38. # "name" : "pk_col"
  39. # }
  40. #
  41. > SELECT pk_col, nopk_col, pg_typeof(pk_col) FROM uuid_type_tbl;
  42. a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11 a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11 text
  43. $ postgres-execute connection=postgres://postgres:postgres@postgres
  44. UPDATE uuid_type SET nopk_col = 'b0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11';
  45. > SELECT pk_col, nopk_col FROM uuid_type_tbl;
  46. a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11 b0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11