avro-resolution-union-concrete.td 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. # Attempt to write a concrete type with a union source without a match
  12. #
  13. $ set union-int={"type": "record", "name": "schema_union", "fields": [ {"name": "f1", "type": [ "int" ] } ] }
  14. $ set concrete-double={"type": "record", "name": "schema_union", "fields": [ {"name": "f1", "type": "double" } ] }
  15. $ kafka-create-topic topic=resolution-union-concrete
  16. $ kafka-ingest format=avro topic=resolution-union-concrete schema=${union-int} timestamp=1
  17. {"f1": {"int": 123 } }
  18. > CREATE CONNECTION IF NOT EXISTS csr_conn TO CONFLUENT SCHEMA REGISTRY (
  19. URL '${testdrive.schema-registry-url}'
  20. );
  21. > CREATE CONNECTION kafka_conn
  22. TO KAFKA (BROKER '${testdrive.kafka-addr}', SECURITY PROTOCOL PLAINTEXT);
  23. > CREATE SOURCE resolution_union_concrete
  24. IN CLUSTER ${arg.single-replica-cluster}
  25. FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-resolution-union-concrete-${testdrive.seed}')
  26. > CREATE TABLE resolution_union_concrete_tbl FROM SOURCE resolution_union_concrete (REFERENCE "testdrive-resolution-union-concrete-${testdrive.seed}")
  27. FORMAT AVRO USING CONFLUENT SCHEMA REGISTRY CONNECTION csr_conn
  28. ENVELOPE NONE
  29. $ kafka-ingest format=avro topic=resolution-union-concrete schema=${concrete-double} timestamp=2
  30. {"f1": 123.456 }
  31. ! SELECT f1 FROM resolution_union_concrete_tbl
  32. contains:No matching schema in reader union for writer type `Double` for field `schema_union.f1`
  33. ! SELECT f1 FROM resolution_union_concrete_tbl
  34. contains:failed to resolve Avro schema (id =