uuid.td 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. FORMAT AVRO USING SCHEMA '${schema}'
  36. > SHOW COLUMNS FROM data
  37. name nullable type comment
  38. ------------------------------
  39. u false uuid ""
  40. > SELECT * FROM data
  41. "16fd95b0-65b7-4249-9b66-1547cd95923d"
  42. "b141698b-fb7f-492d-bc8a-0d159641c7a3"
  43. > SELECT '85907cb9-ac9b-4e35-84b8-60dc69368aca'::uuid
  44. "85907cb9-ac9b-4e35-84b8-60dc69368aca"
  45. > SELECT '85907cb9-ac9b-4e35-84b8-60dc69368aca'::uuid::text
  46. "85907cb9-ac9b-4e35-84b8-60dc69368aca"
  47. > CREATE CONNECTION IF NOT EXISTS csr_conn TO CONFLUENT SCHEMA REGISTRY (
  48. URL '${testdrive.schema-registry-url}'
  49. );
  50. > CREATE SINK uuid_sink_${testdrive.seed}
  51. IN CLUSTER ${arg.single-replica-cluster}
  52. FROM data
  53. INTO KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-sink-data-${testdrive.seed}')
  54. FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn
  55. ENVELOPE DEBEZIUM
  56. $ kafka-verify-data format=avro sort-messages=true sink=materialize.public.uuid_sink_${testdrive.seed}
  57. {"before": null, "after": {"row":{"u": "16fd95b0-65b7-4249-9b66-1547cd95923d"}}}
  58. {"before": null, "after": {"row":{"u": "b141698b-fb7f-492d-bc8a-0d159641c7a3"}}}