avro-decode-multi-record.td 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  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. # Root union schemas are expanded to multiple columns
  12. #
  13. $ set multi-record=[{"type": "record", "name": "f1", "fields": [ {"name": "f1", "type": "int"} ] }, {"type": "record", "name": "f2", "fields": [ {"name": "f2", "type": "int"} ] } ]
  14. $ kafka-create-topic topic=avro-decode-type-multi-record
  15. $ kafka-ingest format=avro topic=avro-decode-type-multi-record schema=${multi-record} timestamp=1
  16. {"f1": {"f1":123}}
  17. > CREATE CONNECTION kafka_conn
  18. TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT);
  19. > CREATE SOURCE avro_decode_type_multi_record
  20. IN CLUSTER ${arg.single-replica-cluster}
  21. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-avro-decode-type-multi-record-${testdrive.seed}')
  22. > CREATE TABLE avro_decode_type_multi_record_tbl FROM SOURCE avro_decode_type_multi_record (REFERENCE "testdrive-avro-decode-type-multi-record-${testdrive.seed}")
  23. FORMAT AVRO USING SCHEMA '${multi-record}'
  24. ENVELOPE NONE
  25. > SELECT (f1).f1, (f2).f2 FROM avro_decode_type_multi_record_tbl
  26. 123 <null>