avro-decode-uuid.td 1.2 KB

123456789101112131415161718192021222324252627282930313233
  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. #
  11. # Check that the UUID type is properly decoded
  12. #
  13. $ set uuid={"type": "record", "name": "field_null", "fields": [ { "name": "f1", "type": { "logicalType": "uuid", "type": "string" } } ] }
  14. $ kafka-create-topic topic=avro-types-uuid
  15. $ kafka-ingest format=avro topic=avro-types-uuid schema=${uuid} timestamp=1
  16. {"f1": "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11"}
  17. > CREATE CONNECTION kafka_conn
  18. TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT);
  19. > CREATE SOURCE avro_types_uuid
  20. IN CLUSTER ${arg.single-replica-cluster}
  21. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-avro-types-uuid-${testdrive.seed}')
  22. FORMAT AVRO USING SCHEMA '${uuid}'
  23. ENVELOPE NONE
  24. > SELECT pg_typeof(f1), f1 FROM avro_types_uuid
  25. uuid a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11