avro-decode-bad-json.td 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  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 we get a meaningful error when JSON fails to decode.
  12. #
  13. $ set writer={"type": "record", "name": "value", "fields": [ { "name": "f1", "type": "string" } ] }
  14. $ set reader={"type": "record", "name": "value", "fields": [ { "name": "f1", "type": {"type": "string", "connect.name": "io.debezium.data.Json" } } ] }
  15. $ kafka-create-topic topic=avro-bad-json
  16. $ kafka-ingest format=avro topic=avro-bad-json schema=${writer} timestamp=1
  17. {"f1": "__debezium_unavailable_value"}
  18. > CREATE CONNECTION kafka_conn
  19. TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT);
  20. > CREATE SOURCE avro_bad_json
  21. IN CLUSTER ${arg.single-replica-cluster}
  22. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-avro-bad-json-${testdrive.seed}')
  23. FORMAT AVRO USING SCHEMA '${reader}'
  24. ENVELOPE NONE
  25. ! SELECT * FROM avro_bad_json
  26. contains: (got __debezium_unavailable_value)