uuid.td 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. $ set-arg-default single-replica-cluster=quickstart
  10. # This test exercises UUIDs at the boundary (e.g., by sending them
  11. # through pgwire). Operations on UUIDs are more thoroughly tested in
  12. # uuid.slt.
  13. $ set schema={
  14. "name": "row",
  15. "type": "record",
  16. "fields": [
  17. {
  18. "name": "u",
  19. "type": {
  20. "type": "string",
  21. "logicalType": "uuid"
  22. }
  23. }
  24. ]
  25. }
  26. $ kafka-create-topic topic=data
  27. $ kafka-ingest format=avro topic=data schema=${schema}
  28. {"u": "16fd95b0-65b7-4249-9b66-1547cd95923d"}
  29. {"u": "b141698b-fb7f-492d-bc8a-0d159641c7a3"}
  30. > CREATE CONNECTION kafka_conn
  31. TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT);
  32. > CREATE SOURCE data
  33. IN CLUSTER ${arg.single-replica-cluster}
  34. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-data-${testdrive.seed}')
  35. > CREATE TABLE data_tbl FROM SOURCE data (REFERENCE "testdrive-data-${testdrive.seed}")
  36. FORMAT AVRO USING SCHEMA '${schema}'
  37. > SHOW COLUMNS FROM data_tbl
  38. name nullable type comment
  39. ------------------------------
  40. u false uuid ""
  41. > SELECT * FROM data_tbl
  42. "16fd95b0-65b7-4249-9b66-1547cd95923d"
  43. "b141698b-fb7f-492d-bc8a-0d159641c7a3"
  44. > SELECT '85907cb9-ac9b-4e35-84b8-60dc69368aca'::uuid
  45. "85907cb9-ac9b-4e35-84b8-60dc69368aca"
  46. > SELECT '85907cb9-ac9b-4e35-84b8-60dc69368aca'::uuid::text
  47. "85907cb9-ac9b-4e35-84b8-60dc69368aca"
  48. > CREATE CONNECTION IF NOT EXISTS csr_conn TO CONFLUENT SCHEMA REGISTRY (
  49. URL '${testdrive.schema-registry-url}'
  50. );
  51. > CREATE SINK uuid_sink_${testdrive.seed}
  52. IN CLUSTER ${arg.single-replica-cluster}
  53. FROM data_tbl
  54. INTO KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-sink-data-${testdrive.seed}')
  55. FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn
  56. ENVELOPE DEBEZIUM
  57. $ kafka-verify-data format=avro sort-messages=true sink=materialize.public.uuid_sink_${testdrive.seed}
  58. {"before": null, "after": {"row":{"u": "16fd95b0-65b7-4249-9b66-1547cd95923d"}}}
  59. {"before": null, "after": {"row":{"u": "b141698b-fb7f-492d-bc8a-0d159641c7a3"}}}