09-add-nullability.td 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. # Remove NOT NULL constraint from column
  11. #
  12. $ postgres-execute connection=postgres://postgres:postgres@postgres
  13. CREATE TABLE alter_allow_nullability (f1 INTEGER NOT NULL, f2 INTEGER PRIMARY KEY);
  14. ALTER TABLE alter_allow_nullability REPLICA IDENTITY FULL;
  15. INSERT INTO alter_allow_nullability VALUES (123, 0),(234, 1);
  16. $ schema-registry-wait topic=postgres.public.alter_allow_nullability
  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 alter_allow_nullability
  22. FROM KAFKA CONNECTION kafka_conn (TOPIC 'postgres.public.alter_allow_nullability');
  23. > CREATE TABLE alter_allow_nullability_tbl FROM SOURCE alter_allow_nullability (REFERENCE "postgres.public.alter_allow_nullability")
  24. FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn
  25. ENVELOPE DEBEZIUM;
  26. > SELECT f1 FROM alter_allow_nullability_tbl;
  27. 123
  28. 234
  29. $ postgres-execute connection=postgres://postgres:postgres@postgres
  30. ALTER TABLE alter_allow_nullability ALTER COLUMN f1 DROP NOT NULL;
  31. INSERT INTO alter_allow_nullability VALUES (NULL, 2);
  32. UPDATE alter_allow_nullability SET f1 = NULL WHERE f1 = 123;
  33. DELETE FROM alter_allow_nullability WHERE f1 = 234;
  34. ! SELECT * FROM alter_allow_nullability_tbl;
  35. contains:Decode error: Decoding error: Reader expected variant at index 1, got 0