90-decimal-handling-mode.td 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. # Start with decimal.handling.mode PRECISE
  11. #
  12. $ postgres-execute connection=postgres://postgres:postgres@postgres
  13. CREATE TABLE decimal_handling_mode_precise (f1 DECIMAL(10,3) PRIMARY KEY);
  14. INSERT INTO decimal_handling_mode_precise VALUES (1234567.890);
  15. $ schema-registry-wait topic=postgres.public.decimal_handling_mode_precise
  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 decimal_handling_mode_precise
  21. FROM KAFKA CONNECTION kafka_conn (TOPIC 'postgres.public.decimal_handling_mode_precise');
  22. > CREATE TABLE decimal_handling_mode_precise_tbl FROM SOURCE decimal_handling_mode_precise (REFERENCE "postgres.public.decimal_handling_mode_precise")
  23. FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn
  24. ENVELOPE DEBEZIUM;
  25. > SELECT f1, pg_typeof(f1) FROM decimal_handling_mode_precise_tbl
  26. 1234567.89 numeric
  27. #
  28. # Set decimal.handling.mode to DOUBLE
  29. #
  30. $ http-request method=PUT url=http://debezium:8083/connectors/psql-connector/config content-type=application/json
  31. {
  32. "connector.class": "io.debezium.connector.postgresql.PostgresConnector",
  33. "database.hostname": "postgres",
  34. "database.port": "5432",
  35. "database.user": "debezium",
  36. "database.password": "debezium",
  37. "database.dbname" : "postgres",
  38. "database.server.name": "postgres",
  39. "plugin.name": "pgoutput",
  40. "slot.name" : "tester",
  41. "database.history.kafka.bootstrap.servers": "kafka:9092",
  42. "database.history.kafka.topic": "schema-changes.history",
  43. "truncate.handling.mode": "include",
  44. "decimal.handling.mode": "double",
  45. "topic.prefix": "postgres"
  46. }
  47. # PUT requests do not take effect immediately, we need to sleep
  48. $ sleep-is-probably-flaky-i-have-justified-my-need-with-a-comment duration="10s"
  49. $ postgres-execute connection=postgres://postgres:postgres@postgres
  50. CREATE TABLE decimal_handling_mode_double (f1 DECIMAL(10,3) PRIMARY KEY);
  51. INSERT INTO decimal_handling_mode_double VALUES (2234567.890);
  52. $ schema-registry-wait topic=postgres.public.decimal_handling_mode_double
  53. > CREATE SOURCE decimal_handling_mode_double
  54. FROM KAFKA CONNECTION kafka_conn (TOPIC 'postgres.public.decimal_handling_mode_double');
  55. > CREATE TABLE decimal_handling_mode_double_tbl FROM SOURCE decimal_handling_mode_double (REFERENCE "postgres.public.decimal_handling_mode_double")
  56. FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn
  57. ENVELOPE DEBEZIUM;
  58. > SELECT f1, pg_typeof(f1) FROM decimal_handling_mode_double_tbl;
  59. 2234567.89 "double precision"
  60. #
  61. # Set decimal.handling.mode to STRING
  62. #
  63. $ http-request method=PUT url=http://debezium:8083/connectors/psql-connector/config content-type=application/json
  64. {
  65. "connector.class": "io.debezium.connector.postgresql.PostgresConnector",
  66. "database.hostname": "postgres",
  67. "database.port": "5432",
  68. "database.user": "debezium",
  69. "database.password": "debezium",
  70. "database.dbname" : "postgres",
  71. "database.server.name": "postgres",
  72. "plugin.name": "pgoutput",
  73. "slot.name" : "tester",
  74. "database.history.kafka.bootstrap.servers": "kafka:9092",
  75. "database.history.kafka.topic": "schema-changes.history",
  76. "truncate.handling.mode": "include",
  77. "provide.transaction.metadata": "true",
  78. "decimal.handling.mode": "string",
  79. "topic.prefix": "postgres"
  80. }
  81. $ sleep-is-probably-flaky-i-have-justified-my-need-with-a-comment duration="10s"
  82. $ postgres-execute connection=postgres://postgres:postgres@postgres
  83. CREATE TABLE decimal_handling_mode_string (f1 DECIMAL(10,3) PRIMARY KEY);
  84. INSERT INTO decimal_handling_mode_string VALUES (3234567.890);
  85. $ schema-registry-wait topic=postgres.public.decimal_handling_mode_string
  86. > CREATE SOURCE decimal_handling_mode_string
  87. FROM KAFKA CONNECTION kafka_conn (TOPIC 'postgres.public.decimal_handling_mode_string');
  88. > CREATE TABLE decimal_handling_mode_string_tbl FROM SOURCE decimal_handling_mode_string (REFERENCE "postgres.public.decimal_handling_mode_string")
  89. FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn
  90. ENVELOPE DEBEZIUM;
  91. > SELECT f1, pg_typeof(f1) FROM decimal_handling_mode_string_tbl;
  92. 3234567.890 text
  93. #
  94. # Restore default
  95. #
  96. $ http-request method=PUT url=http://debezium:8083/connectors/psql-connector/config content-type=application/json
  97. {
  98. "connector.class": "io.debezium.connector.postgresql.PostgresConnector",
  99. "database.hostname": "postgres",
  100. "database.port": "5432",
  101. "database.user": "debezium",
  102. "database.password": "debezium",
  103. "database.dbname" : "postgres",
  104. "database.server.name": "postgres",
  105. "plugin.name": "pgoutput",
  106. "slot.name" : "tester",
  107. "database.history.kafka.bootstrap.servers": "kafka:9092",
  108. "database.history.kafka.topic": "schema-changes.history",
  109. "truncate.handling.mode": "include",
  110. "decimal.handling.mode": "precise",
  111. "topic.prefix": "postgres"
  112. }
  113. $ sleep-is-probably-flaky-i-have-justified-my-need-with-a-comment duration="10s"