04-drop-column-nullable.td 1.7 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. # Test DROP COLUMN on nullable columns
  11. #
  12. $ postgres-execute connection=postgres://postgres:postgres@postgres
  13. CREATE TABLE alter_drop_column (f1 INTEGER PRIMARY KEy, col_null_no_default INTEGER, col_null_default INTEGER DEFAULT 999);
  14. INSERT INTO alter_drop_column VALUES (123, 234, 345);
  15. $ schema-registry-wait topic=postgres.public.alter_drop_column
  16. > CREATE CONNECTION IF NOT EXISTS csr_conn TO CONFLUENT SCHEMA REGISTRY (
  17. URL '${testdrive.schema-registry-url}'
  18. );
  19. > CREATE CONNECTION IF NOT EXISTS kafka_conn TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT);
  20. > CREATE SOURCE alter_drop_column
  21. FROM KAFKA CONNECTION kafka_conn (TOPIC 'postgres.public.alter_drop_column');
  22. > CREATE TABLE alter_drop_column_tbl FROM SOURCE alter_drop_column (REFERENCE "postgres.public.alter_drop_column")
  23. FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn
  24. ENVELOPE DEBEZIUM;
  25. > SELECT * FROM alter_drop_column_tbl;
  26. 123 234 345
  27. $ postgres-execute connection=postgres://postgres:postgres@postgres
  28. ALTER TABLE alter_drop_column DROP COLUMN col_null_default;
  29. INSERT INTO alter_drop_column VALUES (1234);
  30. # Prior to Debezium 1.6, NULLs would be returned for col_null_default in new rows.
  31. # Starting with Debezium 1.6, the 999 DEFAULT value will be returned instead.
  32. > SELECT * FROM alter_drop_column_tbl;
  33. 123 234 345
  34. 1234 <null> 999